use of org.gradle.api.file.CopySpec in project gradle by gradle.
the class Ear method lib.
/**
* Adds dependency libraries to include in the 'lib' directory of the EAR archive.
*
* <p>The given action is executed to configure a {@code CopySpec}.</p>
*
* @param configureAction The action.
* @return The created {@code CopySpec}
* @since 3.5
*/
public CopySpec lib(Action<? super CopySpec> configureAction) {
CopySpec copySpec = getLib();
configureAction.execute(copySpec);
return copySpec;
}
use of org.gradle.api.file.CopySpec in project gradle by gradle.
the class DefaultCopySpec method filesMatching.
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));
}
use of org.gradle.api.file.CopySpec in project gradle by gradle.
the class PlayDistributionPlugin method createDistributionContentTasks.
@Mutate
void createDistributionContentTasks(ModelMap<Task> tasks, @Path("buildDir") final File buildDir, @Path("distributions") final PlayDistributionContainer distributions, final PlayPluginConfigurations configurations) {
for (final PlayDistribution distribution : distributions.withType(PlayDistribution.class)) {
final PlayApplicationBinarySpec binary = distribution.getBinary();
if (binary == null) {
throw new InvalidUserCodeException(String.format("Play Distribution '%s' does not have a configured Play binary.", distribution.getName()));
}
final File distJarDir = new File(buildDir, "distributionJars/" + distribution.getName());
final String jarTaskName = "create" + StringUtils.capitalize(distribution.getName()) + "DistributionJar";
tasks.create(jarTaskName, Jar.class, new Action<Jar>() {
@Override
public void execute(Jar jar) {
jar.setDescription("Assembles an application jar suitable for deployment for the " + binary + ".");
jar.dependsOn(binary.getTasks().withType(Jar.class));
jar.from(jar.getProject().zipTree(binary.getJarFile()));
jar.setDestinationDir(distJarDir);
jar.setArchiveName(binary.getJarFile().getName());
Map<String, Object> classpath = Maps.newHashMap();
classpath.put("Class-Path", new PlayManifestClasspath(configurations.getPlayRun(), binary.getAssetsJarFile()));
jar.getManifest().attributes(classpath);
}
});
final Task distributionJar = tasks.get(jarTaskName);
final File scriptsDir = new File(buildDir, "scripts/" + distribution.getName());
String createStartScriptsTaskName = "create" + StringUtils.capitalize(distribution.getName() + "StartScripts");
tasks.create(createStartScriptsTaskName, CreateStartScripts.class, new Action<CreateStartScripts>() {
@Override
public void execute(CreateStartScripts createStartScripts) {
createStartScripts.setDescription("Creates OS specific scripts to run the " + binary + ".");
createStartScripts.setClasspath(distributionJar.getOutputs().getFiles());
createStartScripts.setMainClassName("play.core.server.NettyServer");
createStartScripts.setApplicationName(distribution.getName());
createStartScripts.setOutputDir(scriptsDir);
}
});
Task createStartScripts = tasks.get(createStartScriptsTaskName);
CopySpecInternal distSpec = (CopySpecInternal) distribution.getContents();
CopySpec libSpec = distSpec.addChild().into("lib");
libSpec.from(distributionJar);
libSpec.from(binary.getAssetsJarFile());
libSpec.from(configurations.getPlayRun().getAllArtifacts());
libSpec.eachFile(new PrefixArtifactFileNames(configurations.getPlayRun()));
CopySpec binSpec = distSpec.addChild().into("bin");
binSpec.from(createStartScripts);
binSpec.setFileMode(0755);
CopySpec confSpec = distSpec.addChild().into("conf");
confSpec.from("conf").exclude("routes");
distSpec.from("README");
}
}
use of org.gradle.api.file.CopySpec in project gradle by gradle.
the class JavaLibraryDistributionPlugin method apply.
@Override
public void apply(final ProjectInternal project) {
this.project = project;
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(DistributionPlugin.class);
DefaultDistributionContainer defaultDistributionContainer = (DefaultDistributionContainer) project.getExtensions().findByName("distributions");
CopySpec contentSpec = defaultDistributionContainer.getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME).getContents();
Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
CopySpec childSpec = project.copySpec();
childSpec.from(jar);
childSpec.from(project.file("src/dist"));
CopySpec libSpec = project.copySpec();
libSpec.into("lib");
libSpec.from(project.getConfigurations().getByName("runtime"));
childSpec.with(libSpec);
contentSpec.with(childSpec);
}
use of org.gradle.api.file.CopySpec in project gradle by gradle.
the class ApplicationPlugin method configureDistSpec.
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(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
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;
}
Aggregations