Java Code Examples for org.gradle.api.plugins.BasePlugin

The following examples show how to use org.gradle.api.plugins.BasePlugin. 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: pushfish-android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(BasePlugin.class);

    final EarPluginConvention earPluginConvention = instantiator.newInstance(EarPluginConvention.class, fileResolver, instantiator);
    project.getConvention().getPlugins().put("ear", earPluginConvention);
    earPluginConvention.setLibDirName("lib");
    earPluginConvention.setAppDirName("src/main/application");

    wireEarTaskConventions(project, earPluginConvention);
    configureConfigurations(project);

    PluginContainer plugins = project.getPlugins();

    setupEarTask(project, earPluginConvention);

    configureWithJavaPluginApplied(project, earPluginConvention, plugins);
    configureWithNoJavaPluginApplied(project, earPluginConvention);
}
 
Example 2
Source Project: pushfish-android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(BasePlugin.class);

    final EarPluginConvention earPluginConvention = instantiator.newInstance(EarPluginConvention.class, fileResolver);
    project.getConvention().getPlugins().put("ear", earPluginConvention);
    earPluginConvention.setLibDirName("lib");
    earPluginConvention.setAppDirName("src/main/application");

    wireEarTaskConventions(project, earPluginConvention);
    configureConfigurations(project);

    PluginContainer plugins = project.getPlugins();

    setupEarTask(project, earPluginConvention);

    configureWithJavaPluginApplied(project, earPluginConvention, plugins);
    configureWithNoJavaPluginApplied(project, earPluginConvention);
}
 
Example 3
Source Project: javaide   Source File: ProductFlavorData.java    License: GNU General Public License v3.0 6 votes vote down vote up
ProductFlavorData(
        @NonNull T productFlavor,
        @NonNull DefaultAndroidSourceSet sourceSet,
        @NonNull Project project) {
    super(sourceSet, project);

    this.productFlavor = productFlavor;

    if (!BuilderConstants.MAIN.equals(sourceSet.getName())) {
        String sourceSetName = StringHelper.capitalize(sourceSet.getName());
        assembleTask = project.getTasks().create("assemble" + sourceSetName);
        assembleTask.setDescription("Assembles all " + sourceSetName + " builds.");
        assembleTask.setGroup(BasePlugin.BUILD_GROUP);
    } else {
        assembleTask = null;
    }
}
 
Example 4
Source Project: jpa2ddl   Source File: GeneratePlugin.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
	GeneratePluginExtension generatePluginExtension = project.getExtensions().create(EXTENSION_NAME,
			GeneratePluginExtension.class, project);

	GenerateTask generateTask = project.getTasks().create(TASK_NAME, GenerateTask.class);
	generateTask.setGroup(BasePlugin.BUILD_GROUP);
	generateTask.setDescription("Generates DDL scripts based on JPA model.");
	generateTask.setExtension(generatePluginExtension);
	generateTask.dependsOn(JavaBasePlugin.BUILD_TASK_NAME);


	project.afterEvaluate(evaluatedProject -> {
		fillDefaults(evaluatedProject, generatePluginExtension);
		SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
		Set<File> paths;
		if (sourceSets != null) {
			UnionFileCollection mainClasspath = (UnionFileCollection) sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
			paths = mainClasspath.getFiles();
		} else {
			paths = new HashSet<>();
		}
		generateTask.setOutputClassesDirs(paths);
	});
}
 
Example 5
Source Project: curiostack   Source File: CodelabsPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {
  project.getRootProject().getPlugins().apply(CodelabsSetupPlugin.class);
  project.getPlugins().apply(BasePlugin.class);

  var setupClaat = DownloadToolUtil.getSetupTask(project, "claat");
  var exportDocs =
      project
          .getTasks()
          .register(
              "exportDocs",
              ExportDocsTask.class,
              t -> {
                t.dependsOn(setupClaat);

                var mdFileTree = project.fileTree("src");
                mdFileTree.exclude("build").include("**/*.md");

                t.getMdFiles().set(mdFileTree);
                t.getOutputDir().set(project.file("build/site"));
              });

  project.getTasks().named("assemble").configure(t -> t.dependsOn(exportDocs));
}
 
Example 6
Source Project: curiostack   Source File: CurioGenericCiPlugin.java    License: MIT License 6 votes vote down vote up
private static void doAddToMasterBuild(Project project, Object task) {
  project
      .getRootProject()
      .getPlugins()
      .withType(
          CurioGenericCiPlugin.class,
          unused -> {
            if (getCiState(project).isMasterBuild()) {
              project
                  .getPlugins()
                  .withType(
                      BasePlugin.class,
                      unused2 ->
                          project.getTasks().named("build").configure(t -> t.dependsOn(task)));
            }
          });
}
 
Example 7
Source Project: curiostack   Source File: CurioGenericCiPlugin.java    License: MIT License 6 votes vote down vote up
private static void doAddToReleaseBuild(Project project, Object task) {
  project
      .getRootProject()
      .getPlugins()
      .withType(
          CurioGenericCiPlugin.class,
          unused -> {
            if (getCiState(project).isReleaseBuild()) {
              project
                  .getPlugins()
                  .withType(
                      BasePlugin.class,
                      unused2 ->
                          project.getTasks().named("build").configure(t -> t.dependsOn(task)));
            }
          });
}
 
Example 8
Source Project: curiostack   Source File: CurioGenericCiPlugin.java    License: MIT License 6 votes vote down vote up
private static void doAddToBranchBuild(Project project, Object task) {
  project
      .getRootProject()
      .getPlugins()
      .withType(
          CurioGenericCiPlugin.class,
          unused -> {
            var state = getCiState(project);
            if (!state.isReleaseBuild() && !state.isMasterBuild()) {
              project
                  .getPlugins()
                  .withType(
                      BasePlugin.class,
                      unused2 ->
                          project.getTasks().named("build").configure(t -> t.dependsOn(task)));
            }
          });
}
 
Example 9
Source Project: gradle-plugins   Source File: SourcesJarPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {

    project.getLogger().warn("io.freefair.sources-jar is deprecated. Use java.withSourcesJar() instead");

    project.getPluginManager().withPlugin("java", appliedPlugin -> {
        sourcesJar = project.getTasks().register("sourcesJar", Jar.class, sourcesJar -> {
            sourcesJar.setDescription("Assembles a jar archive containing the sources.");
            sourcesJar.getArchiveClassifier().set("sources");
            sourcesJar.setGroup(BasePlugin.BUILD_GROUP);

            sourcesJar.dependsOn(project.getTasks().named(JavaPlugin.CLASSES_TASK_NAME));

            JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
            DefaultSourceSet mainSourceSet = (DefaultSourceSet) javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
            sourcesJar.from(mainSourceSet.getAllSource());
        });

        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, sourcesJar);
    });
}
 
Example 10
Source Project: gradle-plugins   Source File: JSassJavaPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().apply(JSassWebjarsPlugin.class);

    project.getPlugins().apply(JavaPlugin.class);

    File baseDestinationDir = new File(project.getBuildDir(), "jsass");

    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
        String taskName = sourceSet.getCompileTaskName("Sass");

        TaskProvider<SassCompile> sassCompileTaskProvider = project.getTasks().register(taskName, SassCompile.class, sassCompile -> {
            sassCompile.setSource(sourceSet.getResources());
            sassCompile.getDestinationDir().set(new File(baseDestinationDir, sourceSet.getName()));
            sassCompile.setGroup(BasePlugin.BUILD_GROUP);
            sassCompile.setDescription("Compile sass and scss files for the " + sourceSet.getName() + " source set");
        });

        project.getTasks().named(sourceSet.getProcessResourcesTaskName(), ProcessResources.class)
                .configure(processResources -> processResources.from(sassCompileTaskProvider));
    });
}
 
Example 11
Source Project: gradle-plugins   Source File: JSassWarPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {

    project.getPlugins().apply(JSassWebjarsPlugin.class);
    project.getPlugins().apply(WarPlugin.class);

    TaskProvider<SassCompile> sassCompileTaskProvider = project.getTasks().register("compileWebappSass", SassCompile.class, compileWebappSass -> {
        compileWebappSass.setGroup(BasePlugin.BUILD_GROUP);
        compileWebappSass.setDescription("Compile sass and scss files for the webapp");

        WarPluginConvention warPluginConvention = project.getConvention().getPlugin(WarPluginConvention.class);
        compileWebappSass.source(warPluginConvention.getWebAppDir());

        compileWebappSass.getDestinationDir().set(new File(project.getBuildDir(), "jsass/webapp"));
    });

    project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class)
            .configure(war -> war.from(sassCompileTaskProvider));
}
 
Example 12
Source Project: app-gradle-plugin   Source File: RunExtension.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the appengine service directory for this project and modifies the task dependencies of
 * run/start to ensure {@code serviceProject} is built first.
 */
public File projectAsService(Project serviceProject) {
  if (!serviceProject.equals(project)) {
    project.evaluationDependsOn(serviceProject.getPath());
  }
  project
      .getTasks()
      .findByName(AppEngineStandardPlugin.RUN_TASK_NAME)
      .dependsOn(serviceProject.getTasks().findByPath(BasePlugin.ASSEMBLE_TASK_NAME));
  project
      .getTasks()
      .findByName(AppEngineStandardPlugin.START_TASK_NAME)
      .dependsOn(serviceProject.getTasks().findByPath(BasePlugin.ASSEMBLE_TASK_NAME));
  return serviceProject
      .getTasks()
      .findByName(AppEngineStandardPlugin.EXPLODE_WAR_TASK_NAME)
      .getOutputs()
      .getFiles()
      .getSingleFile();
}
 
Example 13
Source Project: app-gradle-plugin   Source File: AppEngineStandardPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private void createExplodedWarTask() {
  project
      .getTasks()
      .create(
          EXPLODE_WAR_TASK_NAME,
          ExplodeWarTask.class,
          explodeWar -> {
            explodeWar.setExplodedAppDirectory(explodedWarDir);
            explodeWar.dependsOn(WarPlugin.WAR_TASK_NAME);
            explodeWar.setGroup(APP_ENGINE_STANDARD_TASK_GROUP);
            explodeWar.setDescription("Explode a war into a directory");

            project.afterEvaluate(
                project ->
                    explodeWar.setWarFile(
                        ((War) project.getTasks().getByPath(WarPlugin.WAR_TASK_NAME))
                            .getArchivePath()));
          });
  project.getTasks().getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(EXPLODE_WAR_TASK_NAME);
}
 
Example 14
Source Project: app-gradle-plugin   Source File: AppEngineAppYamlPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private void createStageTask() {
  StageAppYamlTask stageTask =
      project
          .getTasks()
          .create(
              STAGE_TASK_NAME,
              StageAppYamlTask.class,
              stageTask1 -> {
                stageTask1.setGroup(APP_ENGINE_APP_YAML_TASK_GROUP);
                stageTask1.setDescription(
                    "Stage an App Engine app.yaml based project for deployment");
                stageTask1.dependsOn(BasePlugin.ASSEMBLE_TASK_NAME);

                project.afterEvaluate(project -> stageTask1.setStagingConfig(stageExtension));
              });
  project
      .getTasks()
      .getByName(AppEngineCorePluginConfiguration.DEPLOY_TASK_NAME)
      .dependsOn(stageTask);
  project
      .getTasks()
      .getByName(AppEngineCorePluginConfiguration.DEPLOY_ALL_TASK_NAME)
      .dependsOn(stageTask);
}
 
Example 15
Source Project: gradle-plugins   Source File: SourcesJarPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {

    project.getLogger().warn("io.freefair.sources-jar is deprecated. Use java.withSourcesJar() instead");

    project.getPluginManager().withPlugin("java", appliedPlugin -> {
        sourcesJar = project.getTasks().register("sourcesJar", Jar.class, sourcesJar -> {
            sourcesJar.setDescription("Assembles a jar archive containing the sources.");
            sourcesJar.getArchiveClassifier().set("sources");
            sourcesJar.setGroup(BasePlugin.BUILD_GROUP);

            sourcesJar.dependsOn(project.getTasks().named(JavaPlugin.CLASSES_TASK_NAME));

            JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
            DefaultSourceSet mainSourceSet = (DefaultSourceSet) javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
            sourcesJar.from(mainSourceSet.getAllSource());
        });

        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, sourcesJar);
    });
}
 
Example 16
Source Project: gradle-plugins   Source File: JSassJavaPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().apply(JSassWebjarsPlugin.class);

    project.getPlugins().apply(JavaPlugin.class);

    File baseDestinationDir = new File(project.getBuildDir(), "jsass");

    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
        String taskName = sourceSet.getCompileTaskName("Sass");

        TaskProvider<SassCompile> sassCompileTaskProvider = project.getTasks().register(taskName, SassCompile.class, sassCompile -> {
            sassCompile.setSource(sourceSet.getResources());
            sassCompile.getDestinationDir().set(new File(baseDestinationDir, sourceSet.getName()));
            sassCompile.setGroup(BasePlugin.BUILD_GROUP);
            sassCompile.setDescription("Compile sass and scss files for the " + sourceSet.getName() + " source set");
        });

        project.getTasks().named(sourceSet.getProcessResourcesTaskName(), ProcessResources.class)
                .configure(processResources -> processResources.from(sassCompileTaskProvider));
    });
}
 
Example 17
Source Project: gradle-plugins   Source File: JSassWarPlugin.java    License: MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {

    project.getPlugins().apply(JSassWebjarsPlugin.class);
    project.getPlugins().apply(WarPlugin.class);

    TaskProvider<SassCompile> sassCompileTaskProvider = project.getTasks().register("compileWebappSass", SassCompile.class, compileWebappSass -> {
        compileWebappSass.setGroup(BasePlugin.BUILD_GROUP);
        compileWebappSass.setDescription("Compile sass and scss files for the webapp");

        WarPluginConvention warPluginConvention = project.getConvention().getPlugin(WarPluginConvention.class);
        compileWebappSass.source(warPluginConvention.getWebAppDir());

        compileWebappSass.getDestinationDir().set(new File(project.getBuildDir(), "jsass/webapp"));
    });

    project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class)
            .configure(war -> war.from(sassCompileTaskProvider));
}
 
Example 18
Source Project: Pushjet-Android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(BasePlugin.class);

    final EarPluginConvention earPluginConvention = instantiator.newInstance(EarPluginConvention.class, fileResolver, instantiator);
    project.getConvention().getPlugins().put("ear", earPluginConvention);
    earPluginConvention.setLibDirName("lib");
    earPluginConvention.setAppDirName("src/main/application");

    wireEarTaskConventions(project, earPluginConvention);
    configureConfigurations(project);

    PluginContainer plugins = project.getPlugins();

    setupEarTask(project, earPluginConvention);

    configureWithJavaPluginApplied(project, earPluginConvention, plugins);
    configureWithNoJavaPluginApplied(project, earPluginConvention);
}
 
Example 19
Source Project: Pushjet-Android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void apply(final Project project) {
    project.getPlugins().apply(BasePlugin.class);

    final EarPluginConvention earPluginConvention = instantiator.newInstance(EarPluginConvention.class, fileResolver);
    project.getConvention().getPlugins().put("ear", earPluginConvention);
    earPluginConvention.setLibDirName("lib");
    earPluginConvention.setAppDirName("src/main/application");

    wireEarTaskConventions(project, earPluginConvention);
    configureConfigurations(project);

    PluginContainer plugins = project.getPlugins();

    setupEarTask(project, earPluginConvention);

    configureWithJavaPluginApplied(project, earPluginConvention, plugins);
    configureWithNoJavaPluginApplied(project, earPluginConvention);
}
 
Example 20
Source Project: pushfish-android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));

    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
 
Example 21
private Upload createUploadTask(String name, final Configuration configuration, final Project project) {
    Upload upload = project.getTasks().create(name, Upload.class);
    upload.setDescription(String.format("Uploads all artifacts belonging to %s", configuration));
    upload.setGroup(BasePlugin.UPLOAD_GROUP);
    upload.setConfiguration(configuration);
    upload.setUploadDescriptor(true);
    upload.getConventionMapping().map("descriptorDestination", new Callable<File>() {
        public File call() throws Exception {
            return new File(project.getBuildDir(), "ivy.xml");
        }
    });
    return upload;
}
 
Example 22
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(BasePlugin.class);
    project.getPlugins().apply(LanguageBasePlugin.class);

    modelRules.register("toolChains", ToolChainRegistryInternal.class, factory(DefaultToolChainRegistry.class));
    modelRules.register("platforms", PlatformContainer.class, factory(DefaultPlatformContainer.class));
    modelRules.register("buildTypes", BuildTypeContainer.class, factory(DefaultBuildTypeContainer.class));
    modelRules.register("flavors", FlavorContainer.class, factory(DefaultFlavorContainer.class));

    project.getModelRegistry().create("repositories", Arrays.asList("flavors", "platforms", "buildTypes"), new RepositoriesFactory(instantiator, fileResolver));

    modelRules.rule(new CreateDefaultPlatform());
    modelRules.rule(new CreateDefaultBuildTypes());
    modelRules.rule(new CreateDefaultFlavors());
    modelRules.rule(new AddDefaultToolChainsIfRequired());
    modelRules.rule(new CreateNativeBinaries(instantiator, project, resolver));
    modelRules.rule(new CloseBinariesForTasks());

    project.getExtensions().create(
            "executables",
            DefaultExecutableContainer.class,
            instantiator,
            project
    );
    project.getExtensions().create(
            "libraries",
            DefaultLibraryContainer.class,
            instantiator,
            project
    );

    // TODO:DAZ Lazy configuration actions: need a better way to accomplish these.
    configurationActions.add(Actions.composite(
            new ConfigureGeneratedSourceSets(),
            new ApplySourceSetConventions()
    ));
}
 
Example 23
Source Project: pushfish-android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setupEarTask(final Project project, EarPluginConvention convention) {
    Ear ear = project.getTasks().create(EAR_TASK_NAME, Ear.class);
    ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
    DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
    if (deploymentDescriptor != null) {
        if (deploymentDescriptor.getDisplayName() == null) {
            deploymentDescriptor.setDisplayName(project.getName());
        }
        if (deploymentDescriptor.getDescription() == null) {
            deploymentDescriptor.setDescription(project.getDescription());
        }
    }
    ear.setGroup(BasePlugin.BUILD_GROUP);
    project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new ArchivePublishArtifact(ear));

    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(Ear task) {
            task.getLib().from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    return project.getConfigurations().getByName(EARLIB_CONFIGURATION_NAME);
                }
            });
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    // add the module configuration's files
                    return project.getConfigurations().getByName(DEPLOY_CONFIGURATION_NAME);
                }
            });
        }
    });
}
 
Example 24
private Upload createUploadTask(String name, final Configuration configuration, final Project project) {
    Upload upload = project.getTasks().create(name, Upload.class);
    upload.setDescription(String.format("Uploads all artifacts belonging to %s", configuration));
    upload.setGroup(BasePlugin.UPLOAD_GROUP);
    upload.setConfiguration(configuration);
    upload.setUploadDescriptor(true);
    upload.getConventionMapping().map("descriptorDestination", new Callable<File>() {
        public File call() throws Exception {
            return new File(project.getBuildDir(), "ivy.xml");
        }
    });
    return upload;
}
 
Example 25
Source Project: quarkus   Source File: QuarkusPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldMakeAssembleDependOnQuarkusBuild() {
    Project project = ProjectBuilder.builder().build();
    project.getPluginManager().apply(QuarkusPlugin.ID);
    project.getPluginManager().apply("base");

    TaskContainer tasks = project.getTasks();

    assertThat(tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).getDependsOn())
            .contains(tasks.getByName(QuarkusPlugin.QUARKUS_BUILD_TASK_NAME));
}
 
Example 26
Source Project: javaide   Source File: BuildTypeData.java    License: GNU General Public License v3.0 5 votes vote down vote up
BuildTypeData(
        @NonNull CoreBuildType buildType,
        @NonNull Project project,
        @NonNull DefaultAndroidSourceSet sourceSet) {
    super(sourceSet, project);

    this.buildType = buildType;

    String sourceSetName = StringHelper.capitalize(buildType.getName());

    assembleTask = project.getTasks().create("assemble" + sourceSetName);
    assembleTask.setDescription("Assembles all " + sourceSetName + " builds.");
    assembleTask.setGroup(BasePlugin.BUILD_GROUP);
}
 
Example 27
Source Project: curiostack   Source File: CurioDatabasePlugin.java    License: MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
  DatabaseExtension.create(project);

  project.getPlugins().apply(BasePlugin.class);
  project.getPlugins().apply(DockerRemoteApiPlugin.class);
  project.getPlugins().apply(FlywayPlugin.class);

  project.afterEvaluate(CurioDatabasePlugin::addTasks);
}
 
Example 28
Source Project: curiostack   Source File: NodePlugin.java    License: MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
  project.getRootProject().getPlugins().apply(NodeSetupPlugin.class);
  project.getPlugins().apply(BasePlugin.class);

  project
      .getTasks()
      .withType(Delete.class)
      .named("clean")
      .configure(t -> t.delete("node_modules"));

  project
      .getTasks()
      .addRule(
          "Pattern: \"yarn_<command>\": Executes an Yarn command.",
          taskName -> {
            if (taskName.startsWith("yarn_")) {
              project
                  .getTasks()
                  .create(
                      taskName,
                      NodeTask.class,
                      t -> {
                        List<String> tokens = YARN_TASK_SPLITTER.splitToList(taskName);
                        t.args(tokens.subList(1, tokens.size()));
                      });
            }
          });
}
 
Example 29
Source Project: gradle-plugins   Source File: JavadocJarPlugin.java    License: MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {

        project.getLogger().warn("io.freefair.javadoc-jar is deprecated. Use java.withJavadocJar() instead");

        javadocJar = project.getTasks().register("javadocJar", Jar.class, javadocJar -> {
            javadocJar.from(project.getTasks().named(JavaPlugin.JAVADOC_TASK_NAME));
            javadocJar.getArchiveClassifier().set("javadoc");
            javadocJar.setDescription("Assembles a jar archive containing the javadocs.");
            javadocJar.setGroup(BasePlugin.BUILD_GROUP);
        });

        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, javadocJar);
    });

    project.getPlugins().withType(AggregateJavadocPlugin.class, aggregateJavadocPlugin -> {
        aggregateJavadocJar = project.getTasks().register("aggregateJavadocJar", Jar.class, aggregateJavadocJar -> {
            aggregateJavadocJar.from(aggregateJavadocPlugin.getAggregateJavadoc());
            aggregateJavadocJar.getArchiveClassifier().set("javadoc");
            aggregateJavadocJar.setGroup(BasePlugin.BUILD_GROUP);
        });

        project.getPlugins().apply(BasePlugin.class);
        project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, aggregateJavadocJar);

        project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
            aggregateJavadocJar.configure(aggregateJavadocJar -> {

                aggregateJavadocJar.getArchiveClassifier().convention("aggregateJavadoc");
                aggregateJavadocJar.getDestinationDirectory().set(new File(
                        project.getConvention().getPlugin(JavaPluginConvention.class).getDocsDir(),
                        "aggregateJavadoc"
                ));
            });
        });

    });
}
 
Example 30
Source Project: app-gradle-plugin   Source File: RunExtensionTest.java    License: Apache License 2.0 5 votes vote down vote up
private Set<String> getAssembleDependencies(Project project, String taskName) {
  Task task = project.getTasks().findByPath(taskName);
  return task.getDependsOn()
      .stream()
      .filter(t -> t instanceof Task)
      .map(t -> (Task) t)
      .filter(t -> t.getName().equals(BasePlugin.ASSEMBLE_TASK_NAME))
      .map(Task::getPath)
      .collect(Collectors.toSet());
}