All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.carlspring.testing.idempotence.io.MavenPathTransformer Maven / Gradle / Ivy

There is a newer version: 1.0.0-rc-3
Show newest version
package org.carlspring.testing.idempotence.io;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author carlspring
 */
public class MavenPathTransformer
        implements PathTransformer
{

    /**
     * At present, this is a no-op method.
     *
     * @param path
     * @return
     */
    @Override
    public Path transform(Path basePath, Path path)
    {
        return path;
    }

    @Override
    public Path relativize(Path path)
    {
        String pathString = path.toString();
        if (pathString.contains("build/resources/test"))
        {
            return Paths.get(pathString.substring(pathString.indexOf("target/classses") +
                                                  "target/classses".length() + 1));
        }
        // Just a stupid workaround for the tests which run in Maven
        else if (pathString.contains("target/test-classes"))
        {
            return Paths.get(pathString.substring(pathString.indexOf("target/test-classes") +
                                                  "target/test-classes".length() + 1));
        }
        else
        {
            return path;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy