org.gradle.api.distribution.DistributionContainer Java Examples

The following examples show how to use org.gradle.api.distribution.DistributionContainer. 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: TransportPlugin.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Configures default dependencies for the main and test source sets
 */
private void configureBaseSourceSets(Project project, SourceSet mainSourceSet, SourceSet testSourceSet) {
  addDependencyConfigurationsToSourceSet(project, mainSourceSet, Defaults.MAIN_SOURCE_SET_DEPENDENCY_CONFIGURATIONS);
  addDependencyConfigurationsToSourceSet(project, testSourceSet, Defaults.TEST_SOURCE_SET_DEPENDENCY_CONFIGURATIONS);

  // Configure the default distribution task configured by the distribution plugin, else build fails
  DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class);
  distributions.getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME)
      .getContents()
      .from(project.getTasks().named(mainSourceSet.getJarTaskName()));
}
 
Example #3
Source File: DistributionPackaging.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public List<TaskProvider<? extends Task>> configurePackagingTasks(Project project, Platform platform,
    SourceSet platformSourceSet, SourceSet mainSourceSet) {
  // Create a thin JAR to be included in the distribution
  final TaskProvider<Jar> platformThinJarTask = createThinJarTask(project, platformSourceSet, platform.getName());

  /*
    Include the thin JAR and all the runtime dependencies into the distribution for a given platform

    distributions {
      <platformName> {
        contents {
          from <platformThinJarTask>
          from project.configurations.<platformRuntimeClasspath>
        }
      }
    }
   */
  DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class);
  distributions.register(platform.getName(), distribution -> {
    distribution.setBaseName(project.getName());
    distribution.getContents()
        .from(platformThinJarTask)
        .from(getConfigurationForSourceSet(project, platformSourceSet, RUNTIME_CLASSPATH));
  });

  // Explicitly set classifiers for the created distributions or else leads to Maven packaging issues due to multiple
  // artifacts with the same classifier
  project.getTasks().named(platform.getName() + "DistTar", Tar.class, tar -> tar.setClassifier(platform.getName()));
  project.getTasks().named(platform.getName() + "DistZip", Zip.class, zip -> zip.setClassifier(platform.getName()));
  return ImmutableList.of(project.getTasks().named(platform.getName() + "DistTar", Tar.class),
      project.getTasks().named(platform.getName() + "DistZip", Zip.class));
}
 
Example #4
Source File: PlayDistributionPlugin.java    From playframework with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPluginManager().apply(PlayApplicationPlugin.class);
    project.getPluginManager().apply(DistributionPlugin.class);

    TaskProvider<Task> stageLifecycleTask = createStageLifecycleTask(project);
    TaskProvider<Task> distLifecycleTask = createDistLifecycleTasks(project);

    DistributionContainer distributionContainer = (DistributionContainer) project.getExtensions().getByName("distributions");

    distributionContainer.all(distribution -> {
        createDistributionContentTasks(project, distribution);
        createDistributionZipTasks(project, distribution, stageLifecycleTask, distLifecycleTask);
    });
}