Java Code Examples for org.gradle.util.GFileUtils#relativePath()

The following examples show how to use org.gradle.util.GFileUtils#relativePath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GradleBuildOutcomeSetTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addFileBuildOutcome(GradleFileBuildOutcome outcome, ProjectOutcomes rootProject, Set<BuildOutcome> translatedOutcomes) {
    if (zipArchiveTypes.contains(outcome.getTypeIdentifier())) {
        File originalFile = outcome.getFile();
        String relativePath = GFileUtils.relativePath(rootProject.getProjectDirectory(), originalFile);

        LocallyAvailableResource resource = null;
        if (originalFile.exists()) {
            String filestoreDestination = String.format("%s/%s/%s", fileStorePrefix, outcome.getTaskPath(), originalFile.getName());
            resource = fileStore.move(filestoreDestination, originalFile);
        }

        BuildOutcome buildOutcome = new GeneratedArchiveBuildOutcome(outcome.getTaskPath(), outcome.getDescription(), resource, relativePath);
        translatedOutcomes.add(buildOutcome);
    } else {
        translatedOutcomes.add(new UnknownBuildOutcome(outcome.getTaskPath(), outcome.getDescription()));
    }
}
 
Example 2
Source File: GradleBuildOutcomeSetTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addFileBuildOutcome(GradleFileBuildOutcome outcome, ProjectOutcomes rootProject, Set<BuildOutcome> translatedOutcomes) {
    if (zipArchiveTypes.contains(outcome.getTypeIdentifier())) {
        File originalFile = outcome.getFile();
        String relativePath = GFileUtils.relativePath(rootProject.getProjectDirectory(), originalFile);

        LocallyAvailableResource resource = null;
        if (originalFile.exists()) {
            String filestoreDestination = String.format("%s/%s/%s", fileStorePrefix, outcome.getTaskPath(), originalFile.getName());
            resource = fileStore.move(filestoreDestination, originalFile);
        }

        BuildOutcome buildOutcome = new GeneratedArchiveBuildOutcome(outcome.getTaskPath(), outcome.getDescription(), resource, relativePath);
        translatedOutcomes.add(buildOutcome);
    } else {
        translatedOutcomes.add(new UnknownBuildOutcome(outcome.getTaskPath(), outcome.getDescription()));
    }
}
 
Example 3
Source File: GradleBuildOutcomeSetTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addFileBuildOutcome(GradleFileBuildOutcome outcome, ProjectOutcomes rootProject, Set<BuildOutcome> translatedOutcomes) {
    if (zipArchiveTypes.contains(outcome.getTypeIdentifier())) {
        File originalFile = outcome.getFile();
        String relativePath = GFileUtils.relativePath(rootProject.getProjectDirectory(), originalFile);

        LocallyAvailableResource resource = null;
        if (originalFile.exists()) {
            String filestoreDestination = String.format("%s/%s/%s", fileStorePrefix, outcome.getTaskPath(), originalFile.getName());
            resource = fileStore.move(filestoreDestination, originalFile);
        }

        BuildOutcome buildOutcome = new GeneratedArchiveBuildOutcome(outcome.getTaskPath(), outcome.getDescription(), resource, relativePath);
        translatedOutcomes.add(buildOutcome);
    } else {
        translatedOutcomes.add(new UnknownBuildOutcome(outcome.getTaskPath(), outcome.getDescription()));
    }
}
 
Example 4
Source File: GradleBuildOutcomeSetTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addFileBuildOutcome(GradleFileBuildOutcome outcome, ProjectOutcomes rootProject, Set<BuildOutcome> translatedOutcomes) {
    if (zipArchiveTypes.contains(outcome.getTypeIdentifier())) {
        File originalFile = outcome.getFile();
        String relativePath = GFileUtils.relativePath(rootProject.getProjectDirectory(), originalFile);

        LocallyAvailableResource resource = null;
        if (originalFile.exists()) {
            String filestoreDestination = String.format("%s/%s/%s", fileStorePrefix, outcome.getTaskPath(), originalFile.getName());
            resource = fileStore.move(filestoreDestination, originalFile);
        }

        BuildOutcome buildOutcome = new GeneratedArchiveBuildOutcome(outcome.getTaskPath(), outcome.getDescription(), resource, relativePath);
        translatedOutcomes.add(buildOutcome);
    } else {
        translatedOutcomes.add(new UnknownBuildOutcome(outcome.getTaskPath(), outcome.getDescription()));
    }
}
 
Example 5
Source File: GradleBuildComparison.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private BuildComparisonResultRenderer<Writer> createResultRenderer(Charset encoding, final File reportDir, final Map<String, String> hostAttributes) {
    return new GradleBuildComparisonResultHtmlRenderer(
            comparisonResultRenderers,
            outcomeRenderers,
            encoding,
            sourceBuildExecuter,
            targetBuildExecuter,
            hostAttributes,
            new Transformer<String, File>() {
                public String transform(File original) {
                    return GFileUtils.relativePath(reportDir, original);
                }
            }
    );
}
 
Example 6
Source File: SourceToNameConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public String getClassName(File javaSourceClass) {
    List<File> dirs = sourceDirs.getSourceDirs();
    for (File sourceDir : dirs) {
        if (javaSourceClass.getAbsolutePath().startsWith(sourceDir.getAbsolutePath())) { //perf tweak only
            String relativePath = GFileUtils.relativePath(sourceDir, javaSourceClass);
            if (!relativePath.startsWith("..")) {
                return relativePath.replaceAll("/", ".").replaceAll("\\.java$", "");
            }
        }
    }
    throw new IllegalArgumentException(format("Unable to find source java class: '%s' because it does not belong to any of the source dirs: '%s'",
            javaSourceClass, dirs));

}
 
Example 7
Source File: GradleBuildComparison.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private BuildComparisonResultRenderer<Writer> createResultRenderer(Charset encoding, final File reportDir, final Map<String, String> hostAttributes) {
    return new GradleBuildComparisonResultHtmlRenderer(
            comparisonResultRenderers,
            outcomeRenderers,
            encoding,
            sourceBuildExecuter,
            targetBuildExecuter,
            hostAttributes,
            new Transformer<String, File>() {
                public String transform(File original) {
                    return GFileUtils.relativePath(reportDir, original);
                }
            }
    );
}
 
Example 8
Source File: InputOutputMapper.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JavaSourceClass toJavaSourceClass(File javaSourceClass) {
    for (File sourceDir : sourceDirs) {
        if (javaSourceClass.getAbsolutePath().startsWith(sourceDir.getAbsolutePath())) { //perf tweak only
            String relativePath = GFileUtils.relativePath(sourceDir, javaSourceClass);
            if (!relativePath.startsWith("..")) {
                return new JavaSourceClass(relativePath, compileDestination);
            }
        }
    }
    throw new IllegalArgumentException(format("Unable to find source java class: '%s' because it does not belong to any of the source dirs: '%s'",
            javaSourceClass, sourceDirs));

}
 
Example 9
Source File: GradleBuildComparison.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private BuildComparisonResultRenderer<Writer> createResultRenderer(Charset encoding, final File reportDir, final Map<String, String> hostAttributes) {
    return new GradleBuildComparisonResultHtmlRenderer(
            comparisonResultRenderers,
            outcomeRenderers,
            encoding,
            sourceBuildExecuter,
            targetBuildExecuter,
            hostAttributes,
            new Transformer<String, File>() {
                public String transform(File original) {
                    return GFileUtils.relativePath(reportDir, original);
                }
            }
    );
}
 
Example 10
Source File: SourceToNameConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public String getClassName(File javaSourceClass) {
    List<File> dirs = sourceDirs.getSourceDirs();
    for (File sourceDir : dirs) {
        if (javaSourceClass.getAbsolutePath().startsWith(sourceDir.getAbsolutePath())) { //perf tweak only
            String relativePath = GFileUtils.relativePath(sourceDir, javaSourceClass);
            if (!relativePath.startsWith("..")) {
                return relativePath.replaceAll("/", ".").replaceAll("\\.java$", "");
            }
        }
    }
    throw new IllegalArgumentException(format("Unable to find source java class: '%s' because it does not belong to any of the source dirs: '%s'",
            javaSourceClass, dirs));

}
 
Example 11
Source File: GradleBuildComparison.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private BuildComparisonResultRenderer<Writer> createResultRenderer(Charset encoding, final File reportDir, final Map<String, String> hostAttributes) {
    return new GradleBuildComparisonResultHtmlRenderer(
            comparisonResultRenderers,
            outcomeRenderers,
            encoding,
            sourceBuildExecuter,
            targetBuildExecuter,
            hostAttributes,
            new Transformer<String, File>() {
                public String transform(File original) {
                    return GFileUtils.relativePath(reportDir, original);
                }
            }
    );
}
 
Example 12
Source File: InputOutputMapper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JavaSourceClass toJavaSourceClass(File javaSourceClass) {
    for (File sourceDir : sourceDirs) {
        if (javaSourceClass.getAbsolutePath().startsWith(sourceDir.getAbsolutePath())) { //perf tweak only
            String relativePath = GFileUtils.relativePath(sourceDir, javaSourceClass);
            if (!relativePath.startsWith("..")) {
                return new JavaSourceClass(relativePath, compileDestination);
            }
        }
    }
    throw new IllegalArgumentException(format("Unable to find source java class: '%s' because it does not belong to any of the source dirs: '%s'",
            javaSourceClass, sourceDirs));

}