org.gradle.api.distribution.Distribution Java Examples

The following examples show how to use org.gradle.api.distribution.Distribution. 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: StartScriptsMutator.java    From gradle-modules-plugin with MIT License 5 votes vote down vote up
public void movePatchedLibs() {
    var patchedJarNames = helper().modularityExtension().optionContainer().getPatchModuleContainer().patchedJarNames();
    if (patchedJarNames.isEmpty()) {
        return;
    }

    Distribution mainDistribution = helper().extension("distributions", DistributionContainer.class)
            .getByName("main");
    mainDistribution.contents(
            copySpec -> copySpec.filesMatching(patchedJarNames, this::updateRelativePath)
    );
}
 
Example #2
Source File: PlayDistributionPlugin.java    From playframework with Apache License 2.0 5 votes vote down vote up
private void createDistributionZipTasks(Project project, Distribution distribution, TaskProvider<Task> stageLifecycleTask, TaskProvider<Task> distLifecycleTask) {
    final String capitalizedDistName = capitalizeDistributionName(distribution.getName());
    final String stageTaskName = "stage" + capitalizedDistName + "Dist";
    final File stageDir = new File(project.getBuildDir(), "stage");
    final String baseName = (distribution.getBaseName() != null && "".equals(distribution.getBaseName())) ? distribution.getBaseName() : distribution.getName();

    TaskProvider<Sync> stageSyncTask = project.getTasks().register(stageTaskName, Sync.class, sync -> {
        sync.setDescription("Copies the '" + distribution.getName() + "' distribution to a staging directory.");
        sync.setDestinationDir(stageDir);

        sync.into(baseName, copySpec -> copySpec.with(distribution.getContents()));
    });

    stageLifecycleTask.configure(task -> task.dependsOn(stageSyncTask));

    final String distributionZipTaskName = "create" + capitalizedDistName + "ZipDist";
    TaskProvider<Zip> distZipTask = project.getTasks().register(distributionZipTaskName, Zip.class, zip -> {
        zip.setDescription("Packages the '" + distribution.getName() + "' distribution as a zip file.");
        zip.setBaseName(baseName);
        zip.setDestinationDir(new File(project.getBuildDir(), "distributions"));
        zip.from(stageSyncTask);
    });

    final String distributionTarTaskName = "create" + capitalizedDistName + "TarDist";
    TaskProvider<Tar> distTarTask = project.getTasks().register(distributionTarTaskName, Tar.class, tar -> {
        tar.setDescription("Packages the '" + distribution.getName() + "' distribution as a tar file.");
        tar.setBaseName(baseName);
        tar.setDestinationDir(new File(project.getBuildDir(), "distributions"));
        tar.from(stageSyncTask);
    });

    distLifecycleTask.configure(task -> {
        task.dependsOn(distZipTask);
        task.dependsOn(distTarTask);
    });
}
 
Example #3
Source File: DefaultDistributionContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDistributionContainer(Class<Distribution> type, Instantiator instantiator, FileOperations fileOperations) {
    super(type, instantiator);
    this.fileOperations = fileOperations;
}
 
Example #4
Source File: DefaultDistributionContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Distribution doCreate(String name) {
    return getInstantiator().newInstance(DefaultDistribution.class, name, fileOperations.copySpec(Actions.doNothing()));
}
 
Example #5
Source File: DefaultDistributionContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDistributionContainer(Class<Distribution> type, Instantiator instantiator, FileOperations fileOperations) {
    super(type, instantiator);
    this.fileOperations = fileOperations;
}
 
Example #6
Source File: DefaultDistributionContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Distribution doCreate(String name) {
    return getInstantiator().newInstance(DefaultDistribution.class, name, fileOperations.copySpec(Actions.doNothing()));
}
 
Example #7
Source File: PlayDistributionPlugin.java    From playframework with Apache License 2.0 4 votes vote down vote up
private void createDistributionContentTasks(Project project, Distribution distribution) {
    PlayExtension playExtension = (PlayExtension) project.getExtensions().getByName(PlayApplicationPlugin.PLAY_EXTENSION_NAME);
    TaskProvider<Jar> mainJarTask = project.getTasks().named(JAR_TASK_NAME, Jar.class);
    TaskProvider<Jar> assetsJarTask = project.getTasks().named(PlayApplicationPlugin.ASSETS_JAR_TASK_NAME, Jar.class);

    final File distJarDir = new File(project.getBuildDir(), "distributionJars/" + distribution.getName());
    final String capitalizedDistName = capitalizeDistributionName(distribution.getName());
    final String jarTaskName = "create" + capitalizedDistName + "DistributionJar";

    TaskProvider<Jar> distributionJarTask = project.getTasks().register(jarTaskName, Jar.class, jar -> {
        jar.setDescription("Assembles an application jar suitable for deployment.");
        jar.dependsOn(mainJarTask, assetsJarTask);
        jar.from(project.zipTree(mainJarTask.get().getArchivePath()));
        jar.setDestinationDir(distJarDir);
        jar.setBaseName(mainJarTask.get().getBaseName());

        Map<String, Object> classpath = new HashMap<>();
        classpath.put("Class-Path", new PlayManifestClasspath(project.getConfigurations().getByName(RUNTIME_CLASSPATH_CONFIGURATION_NAME), assetsJarTask.get().getArchivePath()));
        jar.getManifest().attributes(classpath);
    });

    final File scriptsDir = new File(project.getBuildDir(), "scripts");
    String createStartScriptsTaskName = "create" + capitalizedDistName + "StartScripts";
    TaskProvider<CreateStartScripts> createStartScriptsTask = project.getTasks().register(createStartScriptsTaskName, CreateStartScripts.class, createStartScripts -> {
        createStartScripts.setDescription("Creates OS specific scripts to run the distribution.");
        createStartScripts.setClasspath(distributionJarTask.get().getOutputs().getFiles());
        createStartScripts.setMainClassName(getMainClass(playExtension.getPlatform()));
        createStartScripts.setApplicationName(distribution.getName());
        createStartScripts.setOutputDir(scriptsDir);
    });

    CopySpec distSpec = distribution.getContents();
    distSpec.into("lib", copySpec -> {
        copySpec.from(distributionJarTask);
        copySpec.from(assetsJarTask.get().getArchivePath());
        copySpec.from(project.getConfigurations().getByName(RUNTIME_CLASSPATH_CONFIGURATION_NAME));
        copySpec.eachFile(new PrefixArtifactFileNames(project.getConfigurations().getByName(RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
    });

    distSpec.into("bin", copySpec -> {
        copySpec.from(createStartScriptsTask);
        copySpec.setFileMode(0755);
    });

    distSpec.into("conf", copySpec -> copySpec.from("conf").exclude("routes"));
    distSpec.from("README");
}
 
Example #8
Source File: DefaultDistributionContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDistributionContainer(Class<Distribution> type, Instantiator instantiator, FileOperations fileOperations) {
    super(type, instantiator);
    this.fileOperations = fileOperations;
}
 
Example #9
Source File: DefaultDistributionContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Distribution doCreate(String name) {
    return getInstantiator().newInstance(DefaultDistribution.class, name, fileOperations.copySpec(Actions.doNothing()));
}
 
Example #10
Source File: DefaultDistributionContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDistributionContainer(Class<Distribution> type, Instantiator instantiator, FileOperations fileOperations) {
    super(type, instantiator);
    this.fileOperations = fileOperations;
}
 
Example #11
Source File: DefaultDistributionContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Distribution doCreate(String name) {
    return getInstantiator().newInstance(DefaultDistribution.class, name, fileOperations.copySpec(Actions.doNothing()));
}