Java Code Examples for org.gradle.util.CollectionUtils#join()

The following examples show how to use org.gradle.util.CollectionUtils#join() . 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: BaseDirFileResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public String resolveAsRelativePath(Object path) {
    List<String> basePath = Arrays.asList(StringUtils.split(baseDir.getAbsolutePath(), "/" + File.separator));
    File targetFile = resolve(path);
    List<String> targetPath = new ArrayList<String>(Arrays.asList(StringUtils.split(targetFile.getAbsolutePath(),
            "/" + File.separator)));

    // Find and remove common prefix
    int maxDepth = Math.min(basePath.size(), targetPath.size());
    int prefixLen = 0;
    while (prefixLen < maxDepth && basePath.get(prefixLen).equals(targetPath.get(prefixLen))) {
        prefixLen++;
    }
    basePath = basePath.subList(prefixLen, basePath.size());
    targetPath = targetPath.subList(prefixLen, targetPath.size());

    for (int i = 0; i < basePath.size(); i++) {
        targetPath.add(0, "..");
    }
    if (targetPath.isEmpty()) {
        return ".";
    }
    return CollectionUtils.join(File.separator, targetPath);
}
 
Example 2
Source File: BaseDirFileResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public String resolveAsRelativePath(Object path) {
    List<String> basePath = Arrays.asList(StringUtils.split(baseDir.getAbsolutePath(), "/" + File.separator));
    File targetFile = resolve(path);
    List<String> targetPath = new ArrayList<String>(Arrays.asList(StringUtils.split(targetFile.getAbsolutePath(),
            "/" + File.separator)));

    // Find and remove common prefix
    int maxDepth = Math.min(basePath.size(), targetPath.size());
    int prefixLen = 0;
    while (prefixLen < maxDepth && basePath.get(prefixLen).equals(targetPath.get(prefixLen))) {
        prefixLen++;
    }
    basePath = basePath.subList(prefixLen, basePath.size());
    targetPath = targetPath.subList(prefixLen, targetPath.size());

    for (int i = 0; i < basePath.size(); i++) {
        targetPath.add(0, "..");
    }
    if (targetPath.isEmpty()) {
        return ".";
    }
    return CollectionUtils.join(File.separator, targetPath);
}
 
Example 3
Source File: ReferenceDetectingVisitor.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends Expression> void extractReferencePath(T expression, Action<T> action) {
    boolean topLevel = referenceStack.isEmpty();
    action.execute(expression);
    if (topLevel) {
        if (referenceEncountered) {
            String path = CollectionUtils.join(".", referenceStack);
            expression.setNodeMetaData(AST_NODE_REFERENCE_PATH_KEY, path);
            referenceEncountered = false;
        }
        referenceStack.clear();
    }
}
 
Example 4
Source File: ManifestUtil.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static String createManifestClasspath(File jarFile, Collection<File> classpath) {
    List<String> paths = new ArrayList<String>(classpath.size());
    for (File file : classpath) {
        String path = constructRelativeClasspathUri(jarFile, file);
        paths.add(path);
    }

    return CollectionUtils.join(" ", paths);
}
 
Example 5
Source File: ReferenceDetectingVisitor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends Expression> void extractReferencePath(T expression, Action<T> action) {
    boolean topLevel = referenceStack.isEmpty();
    action.execute(expression);
    if (topLevel) {
        if (referenceEncountered) {
            String path = CollectionUtils.join(".", referenceStack);
            expression.setNodeMetaData(AST_NODE_REFERENCE_PATH_KEY, path);
            referenceEncountered = false;
        }
        referenceStack.clear();
    }
}
 
Example 6
Source File: DefaultTemporaryFileProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public File createTemporaryFile(String prefix, @Nullable String suffix, String... path) {
    File dir = new File(baseDirFactory.create(), CollectionUtils.join("/", path));
    GFileUtils.mkdirs(dir);
    try {
        return File.createTempFile(prefix, suffix, dir);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 7
Source File: DefaultTemporaryFileProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public File createTemporaryDirectory(@Nullable String prefix, @Nullable String suffix, @Nullable String... path) {
    File dir = new File(baseDirFactory.create(), CollectionUtils.join("/", path));
    GFileUtils.mkdirs(dir);
    try {
        // TODO: This is not a great paradigm for creating a temporary directory.
        // See http://guava-libraries.googlecode.com/svn/tags/release08/javadoc/com/google/common/io/Files.html#createTempDir%28%29 for an alternative.
        File tmpDir = File.createTempFile("gradle", "projectDir", dir);
        tmpDir.delete();
        tmpDir.mkdir();
        return tmpDir;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 8
Source File: DefaultGradleBuildInvocationSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
    return "{"
            + "dir: '" + getProjectDir().getAbsolutePath() + "'"
            + ", tasks: '" + CollectionUtils.join(" ", getTasks()) + "'"
            + ", arguments: '" + CollectionUtils.join(" ", getArguments()) + "'"
            + ", gradleVersion: " + getGradleVersion()
            + "}";
}
 
Example 9
Source File: ManifestUtil.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static String createManifestClasspath(File jarFile, Collection<File> classpath) {
    List<String> paths = new ArrayList<String>(classpath.size());
    for (File file : classpath) {
        String path = constructRelativeClasspathUri(jarFile, file);
        paths.add(path);
    }

    return CollectionUtils.join(" ", paths);
}
 
Example 10
Source File: ManifestUtil.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static String createManifestClasspath(File jarFile, Collection<File> classpath) {
    List<String> paths = new ArrayList<String>(classpath.size());
    for (File file : classpath) {
        String path = constructRelativeClasspathUri(jarFile, file);
        paths.add(path);
    }

    return CollectionUtils.join(" ", paths);
}
 
Example 11
Source File: DefaultTemporaryFileProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public File createTemporaryDirectory(@Nullable String prefix, @Nullable String suffix, @Nullable String... path) {
    File dir = new File(baseDirFactory.create(), CollectionUtils.join("/", path));
    GFileUtils.mkdirs(dir);
    try {
        // TODO: This is not a great paradigm for creating a temporary directory.
        // See http://guava-libraries.googlecode.com/svn/tags/release08/javadoc/com/google/common/io/Files.html#createTempDir%28%29 for an alternative.
        File tmpDir = File.createTempFile("gradle", "projectDir", dir);
        tmpDir.delete();
        tmpDir.mkdir();
        return tmpDir;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 12
Source File: DefaultTemporaryFileProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public File createTemporaryFile(String prefix, @Nullable String suffix, String... path) {
    File dir = new File(baseDirFactory.create(), CollectionUtils.join("/", path));
    GFileUtils.mkdirs(dir);
    try {
        return File.createTempFile(prefix, suffix, dir);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 13
Source File: DefaultTemporaryFileProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public File createTemporaryFile(String prefix, @Nullable String suffix, String... path) {
    File dir = new File(baseDirFactory.create(), CollectionUtils.join("/", path));
    GFileUtils.mkdirs(dir);
    try {
        return File.createTempFile(prefix, suffix, dir);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 14
Source File: DependencyResolverIdentifier.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static String joinPatterns(List<String> patterns) {
    return CollectionUtils.join(",", patterns);
}
 
Example 15
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private String createPropertyStringFromList(List<String> valueList) {
    return valueList == null || valueList.isEmpty() ? null : CollectionUtils.join(",", valueList);
}
 
Example 16
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private String createPropertyStringFromList(List<String> valueList) {
    return valueList == null || valueList.isEmpty() ? null : CollectionUtils.join(",", valueList);
}
 
Example 17
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private String createPropertyStringFromList(List<String> valueList) {
    return valueList == null || valueList.isEmpty() ? null : CollectionUtils.join(",", valueList);
}
 
Example 18
Source File: DependencyResolverIdentifier.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static String joinPatterns(List<String> patterns) {
    return CollectionUtils.join(",", patterns);
}
 
Example 19
Source File: DependencyResolverIdentifier.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static String joinPatterns(List<String> patterns) {
    return CollectionUtils.join(",", patterns);
}
 
Example 20
Source File: ScopeVisitor.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private String getPath(List<String> scope, Expression propertyPathExpression) {
    String propertyPath = propertyPathExpression.getText();
    String scopePath = CollectionUtils.join(".", scope);
    return scopePath.length() > 0 ? String.format("%s.%s", scopePath, propertyPath) : propertyPath;
}