@Override public void visitFile(final FileVisitDetails fileDetails) { final File outputFileDir = new File(destinationDir, fileDetails.getRelativePath().getParent().getPathString()); // Copy the raw form FileOperations fileOperations = (ProjectInternal) getProject(); fileOperations.copy(new Action<CopySpec>() { @Override public void execute(CopySpec copySpec) { copySpec.from(fileDetails.getFile()).into(outputFileDir); } }); // Capture the relative file relativeFiles.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath())); }
private void configureDescriptorGeneration(final Project project, final GradlePluginDevelopmentExtension extension) { final GeneratePluginDescriptors generatePluginDescriptors = project.getTasks().create(GENERATE_PLUGIN_DESCRIPTORS_TASK_NAME, GeneratePluginDescriptors.class); generatePluginDescriptors.conventionMapping("declarations", new Callable<List<PluginDeclaration>>() { @Override public List<PluginDeclaration> call() throws Exception { return Lists.newArrayList(extension.getPlugins()); } }); generatePluginDescriptors.conventionMapping("outputDirectory", new Callable<File>() { @Override public File call() throws Exception { return new File(project.getBuildDir(), generatePluginDescriptors.getName()); } }); Copy processResources = (Copy) project.getTasks().getByName(PROCESS_RESOURCES_TASK); CopySpec copyPluginDescriptors = processResources.getRootSpec().addChild(); copyPluginDescriptors.into("META-INF/gradle-plugins"); copyPluginDescriptors.from(new Callable<File>() { @Override public File call() throws Exception { return generatePluginDescriptors.getOutputDirectory(); } }); processResources.dependsOn(generatePluginDescriptors); }
private CopySpec configureDistSpec(CopySpec distSpec) { Task jar = project.getTasks().getAt(JavaPlugin.JAR_TASK_NAME); Task startScripts = project.getTasks().getAt(TASK_START_SCRIPTS_NAME); CopySpec libChildSpec = project.copySpec(); libChildSpec.into("lib"); libChildSpec.from(jar); libChildSpec.from(project.getConfigurations().getByName("runtime")); CopySpec binChildSpec = project.copySpec(); binChildSpec.into("bin"); binChildSpec.from(startScripts); binChildSpec.setFileMode(0755); CopySpec childSpec = project.copySpec(); childSpec.from(project.file("src/dist")); childSpec.with(libChildSpec); childSpec.with(binChildSpec); distSpec.with(childSpec); distSpec.with(pluginConvention.getApplicationDistribution()); return distSpec; }
public CopySpec rename(final Closure closure) { delegate.rename(new Transformer<String, String>() { @Override public String transform(String s) { Object res = closure.call(s); return res == null ? null : res.toString(); } }); return this; }
public CopySpec with(CopySpec... copySpecs) { for (CopySpec copySpec : copySpecs) { CopySpecInternal copySpecInternal; if (copySpec instanceof CopySpecSource) { CopySpecSource copySpecSource = (CopySpecSource) copySpec; copySpecInternal = copySpecSource.getRootSpec(); } else { copySpecInternal = (CopySpecInternal) copySpec; } addChildSpec(copySpecInternal); } return this; }
public CopySpec from(Object sourcePath, Action<? super CopySpec> configureAction) { if (configureAction == null) { from(sourcePath); return this; } else { CopySpecInternal child = addChild(); child.from(sourcePath); CopySpecWrapper wrapper = instantiator.newInstance(CopySpecWrapper.class, child); configureAction.execute(wrapper); return wrapper; } }
public CopySpec filesMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { if (!patterns.iterator().hasNext()) { throw new InvalidUserDataException("must provide at least one pattern to match"); } List<Spec> matchers = new ArrayList<Spec>(); for (String pattern : patterns) { matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern)); } Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()])); return eachFile(new MatchingCopyAction(unionMatcher, action)); }
public CopySpec filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { if (!patterns.iterator().hasNext()) { throw new InvalidUserDataException("must provide at least one pattern to not match"); } List<Spec> matchers = new ArrayList<Spec>(); for (String pattern : patterns) { matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern)); } Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()])); return eachFile(new MatchingCopyAction(Specs.<RelativePath>negate(unionMatcher), action)); }
public CopySpec filter(final Transformer<String, String> transformer) { appendCopyAction(new Action<FileCopyDetails>() { public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(transformer); } }); return this; }
private DestinationRootCopySpec createCopySpec(Action<? super CopySpec> action) { DefaultCopySpec copySpec = new DefaultCopySpec(this.fileResolver, instantiator); DestinationRootCopySpec destinationRootCopySpec = new DestinationRootCopySpec(fileResolver, copySpec); CopySpec wrapped = instantiator.newInstance(CopySpecWrapper.class, destinationRootCopySpec); action.execute(wrapped); return destinationRootCopySpec; }
@Internal public CopySpec getMetaInf() { return metaInf.addChild(); }
/** * A location for dependency libraries to include in the 'lib' directory of the EAR archive. */ @Internal public CopySpec getLib() { return ((CopySpecInternal) lib).addChild(); }
public CopySpec exclude(Closure excludeSpec) { return getDelegateCopySpec().exclude(excludeSpec); }
/** * {@inheritDoc} */ public AbstractCopyTask from(Object sourcePath, Action<? super CopySpec> configureAction) { getMainSpec().from(sourcePath, configureAction); return this; }
/** * {@inheritDoc} */ public CopySpec with(CopySpec... sourceSpecs) { getMainSpec().with(sourceSpecs); return this; }
/** * {@inheritDoc} */ public CopySpec into(Object destPath, Action<? super CopySpec> copySpec) { getMainSpec().into(destPath, copySpec); return this; }
public CopySpec exclude(String... excludes) { return getDelegateCopySpec().exclude(excludes); }
public CopySpec into(Object destPath, Action<? super CopySpec> copySpec) { return getDelegateCopySpec().into(destPath, copySpec); }
public WorkResult sync(Action<? super CopySpec> action) { return getFileOperations().sync(action); }
public DefaultPlayDistribution(String name, CopySpec contents, PlayApplicationBinarySpec binary) { super(name, contents); this.binary = binary; }
public CopySpec copySpec(Action<? super CopySpec> action) { return Actions.with(copySpec(), action); }
public CopySpec copySpec() { return getFileOperations().copySpec(); }
@Override public CopySpec copySpec(Closure closure) { return Actions.with(copySpec(), ConfigureUtil.configureUsing(closure)); }
public CopySpecWrapper(CopySpec delegate) { this.delegate = delegate; }
public CopySpec filesMatching(String pattern, Action<? super FileCopyDetails> action) { delegate.filesMatching(pattern, action); return this; }
public CopySpec filesMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { delegate.filesMatching(patterns, action); return this; }
public CopySpec filesNotMatching(String pattern, Action<? super FileCopyDetails> action) { delegate.filesNotMatching(pattern, action); return this; }
public CopySpec filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { delegate.filesNotMatching(patterns, action); return this; }
public CopySpec with(CopySpec... sourceSpecs) { delegate.with(sourceSpecs); return this; }
public CopySpec eachFile(Closure closure) { return getDelegateCopySpec().eachFile(closure); }
public CopySpec from(Object sourcePath, final Closure c) { return delegate.from(sourcePath, new ClosureBackedAction<CopySpec>(c)); }
public CopySpec setIncludes(Iterable<String> includes) { delegate.setIncludes(includes); return this; }
public CopySpec getContents() { return contents; }
public CopySpec eachFile(Action<? super FileCopyDetails> action) { return getDelegateCopySpec().eachFile(action); }
public CopySpec include(Iterable<String> includes) { delegate.include(includes); return this; }
public CopySpec include(Spec<FileTreeElement> includeSpec) { delegate.include(includeSpec); return this; }
public CopySpec exclude(String... excludes) { delegate.exclude(excludes); return this; }
public CopySpec exclude(Iterable<String> excludes) { delegate.exclude(excludes); return this; }
public CopySpec exclude(Spec<FileTreeElement> excludeSpec) { delegate.exclude(excludeSpec); return this; }
public CopySpec exclude(Closure excludeSpec) { delegate.exclude(excludeSpec); return this; }