Java Code Examples for org.gradle.api.file.CopySpec
The following examples show how to use
org.gradle.api.file.CopySpec. These examples are extracted from open source projects.
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 Project: javaide Source File: LibraryCache.java License: GNU General Public License v3.0 | 6 votes |
public static void unzipAar(final File bundle, final File folderOut, final Project project) throws IOException { FileUtils.deleteFolder(folderOut); folderOut.mkdirs(); project.copy(new Action<CopySpec>() { @Override public void execute(CopySpec copySpec) { copySpec.from(project.zipTree(bundle)); copySpec.into(new Object[]{folderOut}); copySpec.filesMatching("**/*.jar", new Action<FileCopyDetails>() { @Override public void execute(FileCopyDetails details) { setRelativePath(details, new RelativePath(false, FD_JARS).plus(details.getRelativePath())); } }); } }); }
Example 2
Source Project: shipkit Source File: JavaLibraryPlugin.java License: MIT License | 6 votes |
@Override public void apply(final Project project) { project.getPlugins().apply("java"); final CopySpec license = project.copySpec(copy -> copy.from(project.getRootDir()).include("LICENSE")); ((Jar) project.getTasks().getByName("jar")).with(license); final Jar sourcesJar = project.getTasks().create(SOURCES_JAR_TASK, Jar.class, jar -> { jar.from(JavaPluginUtil.getMainSourceSet(project).getAllSource()); jar.setClassifier("sources"); jar.with(license); }); final Task javadocJar = project.getTasks().create(JAVADOC_JAR_TASK, Jar.class, jar -> { jar.from(project.getTasks().getByName("javadoc")); jar.setClassifier("javadoc"); jar.with(license); }); project.getArtifacts().add("archives", sourcesJar); project.getArtifacts().add("archives", javadocJar); }
Example 3
Source Project: pushfish-android Source File: FileCopier.java License: BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example 4
Source Project: pushfish-android Source File: DefaultConfigurableFileTree.java License: BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult copy(final Closure closure) { return fileCopier.copy(new Action<CopySpec>() { public void execute(CopySpec copySpec) { copySpec.from(DefaultConfigurableFileTree.this); ConfigureUtil.configure(closure, copySpec); } }); }
Example 5
Source Project: Pushjet-Android Source File: DefaultConfigurableFileTree.java License: BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult copy(final Closure closure) { return fileCopier.copy(new Action<CopySpec>() { public void execute(CopySpec copySpec) { copySpec.from(DefaultConfigurableFileTree.this); ConfigureUtil.configure(closure, copySpec); } }); }
Example 6
Source Project: gradle-plugins Source File: WarOverlayPlugin.java License: MIT License | 5 votes |
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) { War warTask = overlay.getWarTask(); String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName()); String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName()); File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName())); Action<CopySpec> extractOverlay = copySpec -> { copySpec.into(destinationDir); copySpec.from(warTree); }; Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay); overlay.getWarCopySpec().from(extractOverlayTask); if (overlay.isEnableCompilation()) { if (!destinationDir.exists() || isEmpty(destinationDir)) { project.sync(extractOverlay); } project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask); ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes")) .builtBy(extractOverlayTask); project.getDependencies().add(getClasspathConfigurationName(overlay), classes); FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree() .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**")); project.getDependencies().add(getClasspathConfigurationName(overlay), libs); } }
Example 7
Source Project: gradle-plugins Source File: WarOverlayPlugin.java License: MIT License | 5 votes |
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) { War warTask = overlay.getWarTask(); String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName()); String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName()); File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName())); Action<CopySpec> extractOverlay = copySpec -> { copySpec.into(destinationDir); copySpec.from(warTree); }; Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay); overlay.getWarCopySpec().from(extractOverlayTask); if (overlay.isEnableCompilation()) { if (!destinationDir.exists() || isEmpty(destinationDir)) { project.sync(extractOverlay); } project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask); ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes")) .builtBy(extractOverlayTask); project.getDependencies().add(getClasspathConfigurationName(overlay), classes); FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree() .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**")); project.getDependencies().add(getClasspathConfigurationName(overlay), libs); } }
Example 8
Source Project: pushfish-android Source File: Jar.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec getMetaInf() { return metaInf.addChild(); }
Example 9
Source Project: pushfish-android Source File: AntGroovydoc.java License: BSD 2-Clause "Simplified" License | 4 votes |
public void execute(final FileCollection source, File destDir, boolean use, String windowTitle, String docTitle, String header, String footer, String overview, boolean includePrivate, final Set<Groovydoc.Link> links, final Iterable<File> groovyClasspath, Iterable<File> classpath, Project project) { final File tmpDir = new File(project.getBuildDir(), "tmp/groovydoc"); FileOperations fileOperations = (ProjectInternal) project; fileOperations.delete(tmpDir); fileOperations.copy(new Action<CopySpec>() { public void execute(CopySpec copySpec) { copySpec.from(source).into(tmpDir); } }); final Map<String, Object> args = Maps.newLinkedHashMap(); args.put("sourcepath", tmpDir.toString()); args.put("destdir", destDir); args.put("use", use); args.put("private", includePrivate); putIfNotNull(args, "windowtitle", windowTitle); putIfNotNull(args, "doctitle", docTitle); putIfNotNull(args, "header", header); putIfNotNull(args, "footer", footer); putIfNotNull(args, "overview", overview); List<File> combinedClasspath = ImmutableList.<File>builder() .addAll(classpath) .addAll(groovyClasspath) .build(); ant.withClasspath(combinedClasspath).execute(new Closure<Object>(this, this) { @SuppressWarnings("UnusedDeclaration") public Object doCall(Object it) { final GroovyObjectSupport antBuilder = (GroovyObjectSupport) it; antBuilder.invokeMethod("taskdef", ImmutableMap.of( "name", "groovydoc", "classname", "org.codehaus.groovy.ant.Groovydoc" )); antBuilder.invokeMethod("groovydoc", new Object[]{args, new Closure<Object>(this, this) { public Object doCall(Object ignore) { for (Groovydoc.Link link : links) { antBuilder.invokeMethod("link", new Object[]{ ImmutableMap.of( "packages", Joiner.on(",").join(link.getPackages()), "href", link.getUrl() ) }); } return null; } }}); return null; } }); }
Example 10
Source Project: Pushjet-Android Source File: DefaultDistribution.java License: BSD 2-Clause "Simplified" License | 4 votes |
public DefaultDistribution(String name, CopySpec contents) { this.name = name; this.contents = contents; }
Example 11
Source Project: Pushjet-Android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Action<? super CopySpec> action) { return fileOperations.copySpec(action); }
Example 12
Source Project: pushfish-android Source File: AbstractProject.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult copy(Action<? super CopySpec> action) { return getFileOperations().copy(action); }
Example 13
Source Project: Pushjet-Android Source File: FileCopier.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult sync(Action<? super CopySpec> action) { DestinationRootCopySpec copySpec = createCopySpec(action); File destinationDir = copySpec.getDestinationDir(); return doCopy(copySpec, new SyncCopyActionDecorator(destinationDir, getCopyVisitor(destinationDir))); }
Example 14
Source Project: pushfish-android Source File: AbstractProject.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Closure closure) { return copySpec(new ClosureBackedAction<CopySpec>(closure)); }
Example 15
Source Project: Pushjet-Android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Closure closure) { return fileOperations.copySpec(closure); }
Example 16
Source Project: Pushjet-Android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult copy(Action<? super CopySpec> action) { return fileOperations.copy(action); }
Example 17
Source Project: Pushjet-Android Source File: DefaultDistribution.java License: BSD 2-Clause "Simplified" License | 4 votes |
public DefaultDistribution(String name, CopySpec contents) { this.name = name; this.contents = contents; }
Example 18
Source Project: pushfish-android Source File: DestinationRootCopySpec.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public CopySpec into(Object destinationDir) { this.destinationDir = destinationDir; return this; }
Example 19
Source Project: Pushjet-Android Source File: FileCopier.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult copy(Action<? super CopySpec> action) { DestinationRootCopySpec copySpec = createCopySpec(action); File destinationDir = copySpec.getDestinationDir(); return doCopy(copySpec, getCopyVisitor(destinationDir)); }
Example 20
Source Project: pushfish-android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult copy(Action<? super CopySpec> action) { return fileOperations.copy(action); }
Example 21
Source Project: Pushjet-Android Source File: AbstractProject.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Closure closure) { return fileOperations.copySpec(closure); }
Example 22
Source Project: pushfish-android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Closure closure) { return fileOperations.copySpec(new ClosureBackedAction<CopySpec>(closure)); }
Example 23
Source Project: pushfish-android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Action<? super CopySpec> action) { return fileOperations.copySpec(action); }
Example 24
Source Project: pushfish-android Source File: DefaultDistribution.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec getContents() { return contents; }
Example 25
Source Project: pushfish-android Source File: DefaultDistribution.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec contents(Action<? super CopySpec> action) { action.execute(contents); return contents; }
Example 26
Source Project: Pushjet-Android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Closure closure) { return fileOperations.copySpec(new ClosureBackedAction<CopySpec>(closure)); }
Example 27
Source Project: pushfish-android Source File: AbstractProject.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult sync(Action<? super CopySpec> action) { return fileOperations.sync(action); }
Example 28
Source Project: Pushjet-Android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult sync(Action<? super CopySpec> action) { return fileOperations.sync(action); }
Example 29
Source Project: pushfish-android Source File: AbstractProject.java License: BSD 2-Clause "Simplified" License | 4 votes |
public CopySpec copySpec(Action<? super CopySpec> action) { return fileOperations.copySpec(action); }
Example 30
Source Project: Pushjet-Android Source File: DefaultScript.java License: BSD 2-Clause "Simplified" License | 4 votes |
public WorkResult sync(Action<? super CopySpec> action) { return fileOperations.sync(action); }