本文整理汇总了Java中org.gradle.api.file.FileTreeElement类的典型用法代码示例。如果您正苦于以下问题:Java FileTreeElement类的具体用法?Java FileTreeElement怎么用?Java FileTreeElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileTreeElement类属于org.gradle.api.file包,在下文中一共展示了FileTreeElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createExcludeSpec
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public Spec<FileTreeElement> createExcludeSpec(PatternSet patternSet) {
List<Spec<FileTreeElement>> allExcludeSpecs = new ArrayList<Spec<FileTreeElement>>(2 + patternSet.getExcludeSpecs().size());
if (!patternSet.getExcludes().isEmpty()) {
allExcludeSpecs.add(createSpec(patternSet.getExcludes(), false, patternSet.isCaseSensitive()));
}
List<String> defaultExcludes = Arrays.asList(DirectoryScanner.getDefaultExcludes());
if (!defaultExcludes.isEmpty()) {
allExcludeSpecs.add(createSpec(defaultExcludes, false, patternSet.isCaseSensitive()));
}
allExcludeSpecs.addAll(patternSet.getExcludeSpecs());
if (allExcludeSpecs.isEmpty()) {
return Specs.satisfyNone();
} else {
return Specs.union(allExcludeSpecs);
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:PatternSpecFactory.java
示例2: configureSourceSetDefaults
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
public void execute(SourceSet sourceSet) {
final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), sourceDirectorySetFactory);
new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);
groovySourceSet.getGroovy().srcDir("src/" + sourceSet.getName() + "/groovy");
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
public boolean isSatisfiedBy(FileTreeElement element) {
return groovySourceSet.getGroovy().contains(element.getFile());
}
});
sourceSet.getAllJava().source(groovySourceSet.getGroovy());
sourceSet.getAllSource().source(groovySourceSet.getGroovy());
String compileTaskName = sourceSet.getCompileTaskName("groovy");
GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
javaBasePlugin.configureForSourceSet(sourceSet, compile);
compile.dependsOn(sourceSet.getCompileJavaTaskName());
compile.setDescription("Compiles the " + sourceSet.getName() + " Groovy source.");
compile.setSource(groovySourceSet.getGroovy());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:GroovyBasePlugin.java
示例3: DefaultSourceSet
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public DefaultSourceSet(String name, FileResolver fileResolver) {
this.name = name;
displayName = GUtil.toWords(this.name);
String javaSrcDisplayName = String.format("%s Java source", displayName);
javaSource = new DefaultSourceDirectorySet(javaSrcDisplayName, fileResolver);
javaSource.getFilter().include("**/*.java");
allJavaSource = new DefaultSourceDirectorySet(javaSrcDisplayName, fileResolver);
allJavaSource.getFilter().include("**/*.java");
allJavaSource.source(javaSource);
String resourcesDisplayName = String.format("%s resources", displayName);
resources = new DefaultSourceDirectorySet(resourcesDisplayName, fileResolver);
resources.getFilter().exclude(new Spec<FileTreeElement>() {
public boolean isSatisfiedBy(FileTreeElement element) {
return javaSource.contains(element.getFile());
}
});
String allSourceDisplayName = String.format("%s source", displayName);
allSource = new DefaultSourceDirectorySet(allSourceDisplayName, fileResolver);
allSource.source(resources);
allSource.source(javaSource);
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:27,代码来源:DefaultSourceSet.java
示例4: configureSourceSetDefaults
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
public void execute(SourceSet sourceSet) {
final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver);
new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);
groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName()));
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
public boolean isSatisfiedBy(FileTreeElement element) {
return groovySourceSet.getGroovy().contains(element.getFile());
}
});
sourceSet.getAllJava().source(groovySourceSet.getGroovy());
sourceSet.getAllSource().source(groovySourceSet.getGroovy());
String compileTaskName = sourceSet.getCompileTaskName("groovy");
GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
javaBasePlugin.configureForSourceSet(sourceSet, compile);
compile.dependsOn(sourceSet.getCompileJavaTaskName());
compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName()));
compile.setSource(groovySourceSet.getGroovy());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
}
});
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:27,代码来源:GroovyBasePlugin.java
示例5: configureSourceSetDefaults
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(final SourceSet sourceSet) {
String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
scalaDirectorySet.srcDir(new Callable<File>() {
@Override
public File call() throws Exception {
return project.file("src/" + sourceSet.getName() + "/scala");
}
});
sourceSet.getAllJava().source(scalaDirectorySet);
sourceSet.getAllSource().source(scalaDirectorySet);
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
@Override
public boolean isSatisfiedBy(FileTreeElement element) {
return scalaDirectorySet.contains(element.getFile());
}
});
configureScalaCompile(project, javaPlugin, sourceSet);
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:ScalaBasePlugin.java
示例6: createSpec
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
@Override
protected Spec<FileTreeElement> createSpec(final Collection<String> patterns, final boolean include, final boolean caseSensitive) {
final SpecKey key = new SpecKey(ImmutableList.copyOf(patterns), include, caseSensitive);
try {
return Cast.uncheckedCast(specInstanceCache.get(key, new Callable<Spec<FileTreeElement>>() {
@Override
public Spec<FileTreeElement> call() throws Exception {
Spec<FileTreeElement> spec = CachingPatternSpecFactory.super.createSpec(patterns, include, caseSensitive);
return new CachingSpec(key, spec);
}
}));
} catch (ExecutionException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:CachingPatternSpecFactory.java
示例7: isSatisfiedBy
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
@Override
public boolean isSatisfiedBy(final FileTreeElement element) {
CacheKey cacheKey = new CacheKey(element.getRelativePath(), key);
try {
return specResultCache.get(cacheKey, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return spec.isSatisfiedBy(element);
}
});
} catch (ExecutionException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:15,代码来源:CachingPatternSpecFactory.java
示例8: createIncludeSpec
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public Spec<FileTreeElement> createIncludeSpec(PatternSet patternSet) {
List<Spec<FileTreeElement>> allIncludeSpecs = new ArrayList<Spec<FileTreeElement>>(1 + patternSet.getIncludeSpecs().size());
if (!patternSet.getIncludes().isEmpty()) {
allIncludeSpecs.add(createSpec(patternSet.getIncludes(), true, patternSet.isCaseSensitive()));
}
allIncludeSpecs.addAll(patternSet.getIncludeSpecs());
return Specs.union(allIncludeSpecs);
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:12,代码来源:PatternSpecFactory.java
示例9: createSpec
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
protected Spec<FileTreeElement> createSpec(Collection<String> patterns, boolean include, boolean caseSensitive) {
if (patterns.isEmpty()) {
return include ? Specs.<FileTreeElement>satisfyAll() : Specs.<FileTreeElement>satisfyNone();
}
List<Spec<RelativePath>> matchers = new ArrayList<Spec<RelativePath>>(patterns.size());
for (String pattern : patterns) {
Spec<RelativePath> patternMatcher = PatternMatcherFactory.getPatternMatcher(include, caseSensitive, pattern);
matchers.add(patternMatcher);
}
return new RelativePathSpec(Specs.union(matchers));
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:PatternSpecFactory.java
示例10: SingleIncludePatternFileTree
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public SingleIncludePatternFileTree(File baseDir, String includePattern, Spec<FileTreeElement> excludeSpec) {
this.baseDir = baseDir;
if (includePattern.endsWith("/") || includePattern.endsWith("\\")) {
includePattern += "**";
}
this.includePattern = includePattern;
this.patternSegments = Arrays.asList(includePattern.split("[/\\\\]"));
this.excludeSpec = excludeSpec;
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:SingleIncludePatternFileTree.java
示例11: walkDir
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
@Override
public void walkDir(File file, RelativePath path, FileVisitor visitor, Spec<? super FileTreeElement> spec, AtomicBoolean stopFlag, boolean postfix) {
File[] children = file.listFiles();
if (children == null) {
if (file.isDirectory() && !file.canRead()) {
throw new GradleException(String.format("Could not list contents of directory '%s' as it is not readable.", file));
}
// else, might be a link which points to nothing, or has been removed while we're visiting, or ...
throw new GradleException(String.format("Could not list contents of '%s'.", file));
}
List<FileVisitDetails> dirs = new ArrayList<FileVisitDetails>();
for (int i = 0; !stopFlag.get() && i < children.length; i++) {
File child = children[i];
boolean isFile = child.isFile();
RelativePath childPath = path.append(isFile, child.getName());
FileVisitDetails details = new DefaultFileVisitDetails(child, childPath, stopFlag, fileSystem, fileSystem, !isFile);
if (DirectoryFileTree.isAllowed(details, spec)) {
if (isFile) {
visitor.visitFile(details);
} else {
dirs.add(details);
}
}
}
// now handle dirs
for (int i = 0; !stopFlag.get() && i < dirs.size(); i++) {
FileVisitDetails dir = dirs.get(i);
if (postfix) {
walkDir(dir.getFile(), dir.getRelativePath(), visitor, spec, stopFlag, postfix);
visitor.visitDir(dir);
} else {
visitor.visitDir(dir);
walkDir(dir.getFile(), dir.getRelativePath(), visitor, spec, stopFlag, postfix);
}
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:38,代码来源:DefaultDirectoryWalker.java
示例12: visitFrom
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
/**
* Process the specified file or directory. If it is a directory, then its contents
* (but not the directory itself) will be checked with {@link #isAllowed(FileTreeElement, Spec)} and notified to
* the listener. If it is a file, the file will be checked and notified.
*/
public void visitFrom(FileVisitor visitor, File fileOrDirectory, RelativePath path) {
AtomicBoolean stopFlag = new AtomicBoolean();
Spec<FileTreeElement> spec = patternSet.getAsSpec();
if (fileOrDirectory.exists()) {
if (fileOrDirectory.isFile()) {
processSingleFile(fileOrDirectory, visitor, spec, stopFlag);
} else {
walkDir(fileOrDirectory, path, visitor, spec, stopFlag);
}
} else {
LOGGER.info("file or directory '{}', not found", fileOrDirectory);
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:DirectoryFileTree.java
示例13: processSingleFile
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
private void processSingleFile(File file, FileVisitor visitor, Spec<FileTreeElement> spec, AtomicBoolean stopFlag) {
RelativePath path = new RelativePath(true, file.getName());
FileVisitDetails details = new DefaultFileVisitDetails(file, path, stopFlag, fileSystem, fileSystem, false);
if (isAllowed(details, spec)) {
visitor.visitFile(details);
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:DirectoryFileTree.java
示例14: getAllExcludeSpecs
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public List<Spec<FileTreeElement>> getAllExcludeSpecs() {
List<Spec<FileTreeElement>> result = new ArrayList<Spec<FileTreeElement>>();
if (parentResolver != null) {
result.addAll(parentResolver.getAllExcludeSpecs());
}
result.addAll(patternSet.getExcludeSpecs());
return result;
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DefaultCopySpec.java
示例15: getAllIncludeSpecs
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public List<Spec<FileTreeElement>> getAllIncludeSpecs() {
List<Spec<FileTreeElement>> result = new ArrayList<Spec<FileTreeElement>>();
if (parentResolver != null) {
result.addAll(parentResolver.getAllIncludeSpecs());
}
result.addAll(patternSet.getIncludeSpecs());
return result;
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DefaultCopySpec.java
示例16: DefaultSourceSet
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
public DefaultSourceSet(String name, SourceDirectorySetFactory sourceDirectorySetFactory) {
this.name = name;
displayName = GUtil.toWords(this.name);
namingScheme = new ClassDirectoryBinaryNamingScheme(name);
String javaSrcDisplayName = displayName + " Java source";
javaSource = sourceDirectorySetFactory.create(javaSrcDisplayName);
javaSource.getFilter().include("**/*.java");
allJavaSource = sourceDirectorySetFactory.create(javaSrcDisplayName);
allJavaSource.getFilter().include("**/*.java");
allJavaSource.source(javaSource);
String resourcesDisplayName = displayName + " resources";
resources = sourceDirectorySetFactory.create(resourcesDisplayName);
resources.getFilter().exclude(new Spec<FileTreeElement>() {
public boolean isSatisfiedBy(FileTreeElement element) {
return javaSource.contains(element.getFile());
}
});
String allSourceDisplayName = displayName + " source";
allSource = sourceDirectorySetFactory.create(allSourceDisplayName);
allSource.source(resources);
allSource.source(javaSource);
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:28,代码来源:DefaultSourceSet.java
示例17: getMaindexSpec
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
private static Spec<FileTreeElement> getMaindexSpec(PatternSet patternSet) {
Spec<FileTreeElement> maindexSpec = null;
if (patternSet != null) {
Spec<FileTreeElement> includeSpec = null;
Spec<FileTreeElement> excludeSpec = null;
if (!patternSet.getIncludes().isEmpty()) {
includeSpec = patternSet.getAsIncludeSpec();
}
if (!patternSet.getExcludes().isEmpty()) {
excludeSpec = patternSet.getAsExcludeSpec();
}
if (includeSpec != null && excludeSpec != null) {
maindexSpec = new OrSpec<>(includeSpec, new NotSpec<>(excludeSpec));
} else {
if (excludeSpec != null) { // only exclude
maindexSpec = new NotSpec<>(excludeSpec);
} else if (includeSpec != null) { // only include
maindexSpec = includeSpec;
}
}
}
// if (maindexSpec == null) {
// maindexSpec = Specs.satisfyAll();
// }
return maindexSpec;
}
开发者ID:ceabie,项目名称:DexKnifePlugin,代码行数:33,代码来源:DexSplitTools.java
示例18: getMainClassesFromJar
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
/**
* Gets main classes from jar.
*
* @param jarMergingOutputFile the jar merging output file
* @param mainDexPattern the main dex pattern
* @param adtMainCls the filter mapping of suggest classes
* @param logFilter
* @return the main classes from jar
* @throws Exception the exception
* @author ceabie
*/
private static ArrayList<String> getMainClassesFromJar(
File jarMergingOutputFile, PatternSet mainDexPattern, Map<String, Boolean> adtMainCls, boolean logFilter)
throws Exception {
ZipFile clsFile = new ZipFile(jarMergingOutputFile);
Spec<FileTreeElement> asSpec = getMaindexSpec(mainDexPattern);
ClassFileTreeElement treeElement = new ClassFileTreeElement();
// lists classes from jar.
ArrayList<String> mainDexList = new ArrayList<>();
Enumeration<? extends ZipEntry> entries = clsFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
String entryName = entry.getName();
if (entryName.endsWith(CLASS_SUFFIX)) {
treeElement.setClassPath(entryName);
if (isAtMainDex(adtMainCls, entryName, treeElement, asSpec, logFilter)) {
mainDexList.add(entryName);
}
}
}
clsFile.close();
return mainDexList;
}
开发者ID:ceabie,项目名称:DexKnifePlugin,代码行数:39,代码来源:DexSplitTools.java
示例19: getMainClassesFromMapping
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
/**
* Gets main classes from mapping.
*
* @param mapping the mapping file
* @param mainDexPattern the main dex pattern
* @param recommendMainCls the filter mapping of suggest classes
* @param logFilter
* @return the main classes from mapping
* @throws Exception the exception
* @author ceabie
*/
private static List<String> getMainClassesFromMapping(
File mapping,
PatternSet mainDexPattern,
Map<String, Boolean> recommendMainCls, boolean logFilter) throws Exception {
String line;
List<String> mainDexList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new FileReader(mapping)); // all classes
ClassFileTreeElement filterElement = new ClassFileTreeElement();
Spec<FileTreeElement> asSpec = getMaindexSpec(mainDexPattern);
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.endsWith(":")) {
int flagPos = line.indexOf(MAPPING_FLAG);
if (flagPos != -1) {
String sOrgCls = line.substring(0, flagPos).replace('.', '/') + CLASS_SUFFIX;
String sMapCls = line.substring(flagPos + MAPPING_FLAG_LEN, line.length() - 1)
.replace('.', '/') + CLASS_SUFFIX;
filterElement.setClassPath(sOrgCls);
if (isAtMainDex(recommendMainCls, sMapCls, filterElement, asSpec, logFilter)) {
mainDexList.add(sMapCls);
}
}
}
}
reader.close();
return mainDexList;
}
开发者ID:ceabie,项目名称:DexKnifePlugin,代码行数:47,代码来源:DexSplitTools.java
示例20: isAtMainDex
import org.gradle.api.file.FileTreeElement; //导入依赖的package包/类
private static boolean isAtMainDex(
Map<String, Boolean> mainCls, String sMapCls,
ClassFileTreeElement treeElement, Spec<FileTreeElement> asSpec, boolean logFilter) {
boolean isRecommend = false;
// adt推荐
if (mainCls != null) {
Boolean value = mainCls.get(sMapCls);
if (value != null) {
isRecommend = value;
}
}
// 全局过滤
boolean inGlobalFilter = asSpec != null && asSpec.isSatisfiedBy(treeElement);
if (logFilter) {
String ret;
if (isRecommend && inGlobalFilter) {
ret = "true";
} else if (isRecommend) {
ret = "Recommend";
} else if (inGlobalFilter) {
ret = "Global";
} else {
ret = "false";
}
String s = "AtMainDex: " + treeElement.getPath() + " [" + ret + "]";
if (isRecommend || inGlobalFilter) {
System.err.println(s);
} else {
System.out.println(s);
}
}
// 合并结果
return isRecommend || inGlobalFilter;
}
开发者ID:ceabie,项目名称:DexKnifePlugin,代码行数:41,代码来源:DexSplitTools.java
注:本文中的org.gradle.api.file.FileTreeElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论