Java Code Examples for org.gradle.api.Project#afterEvaluate()
The following examples show how to use
org.gradle.api.Project#afterEvaluate() .
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: WarAttachClassesPlugin.java From gradle-plugins with MIT License | 6 votes |
@Override public void apply(Project project) { project.getPlugins().apply(WarPlugin.class); WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention(); project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class, war -> war.getConvention().getPlugins().put("attachClasses", attachClassesConvention) ); project.afterEvaluate(p -> { if (attachClassesConvention.isAttachClasses()) { TaskProvider<Jar> jar = project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class, j -> j.getArchiveClassifier().convention(attachClassesConvention.getClassesClassifier()) ); project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar); } }); }
Example 2
Source File: AbstractThorntailPlugin.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void apply(Project project) { this.project = project; // Skip if the plugin has already been applied. if (project.getExtensions().findByType(ThorntailExtension.class) == null) { ThorntailExtension extension = new ThorntailExtension(project); project.getExtensions().add(THORNTAIL_EXTENSION, extension); // Register a model builder as well. registry.register(new ThorntailToolingModelBuilder()); //noinspection Convert2Lambda project.afterEvaluate(new Action<Project>() { @Override public void execute(Project p) { addDependency("runtimeOnly", "io.thorntail:bootstrap:" + determinePluginVersion()); } }); } }
Example 3
Source File: GithubPackageRegistryMavenPublishPlugin.java From gradle-plugins with MIT License | 6 votes |
@Override public void apply(Project project) { project.getPlugins().apply(MavenPublishPlugin.class); project.getPlugins().apply(GithubPomPlugin.class); GithubExtension githubExtension = project.getRootProject().getExtensions().getByType(GithubExtension.class); project.afterEvaluate(p -> p.getExtensions().getByType(PublishingExtension.class) .getRepositories() .maven(githubRepo -> { githubRepo.setName("GithubPackageRegistry"); githubRepo.setUrl("https://maven.pkg.github.com/" + githubExtension.getSlug().get()); if (githubExtension.getUsername().isPresent() && githubExtension.getToken().isPresent()) { githubRepo.credentials(passwordCredentials -> { passwordCredentials.setUsername(githubExtension.getUsername().get()); passwordCredentials.setPassword(githubExtension.getToken().get()); }); } })); }
Example 4
Source File: GeneratePlugin.java From jpa2ddl with Apache License 2.0 | 6 votes |
@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 File: WarAttachClassesPlugin.java From gradle-plugins with MIT License | 6 votes |
@Override public void apply(Project project) { project.getPlugins().apply(WarPlugin.class); WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention(); project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class, war -> war.getConvention().getPlugins().put("attachClasses", attachClassesConvention) ); project.afterEvaluate(p -> { if (attachClassesConvention.isAttachClasses()) { TaskProvider<Jar> jar = project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class, j -> j.getArchiveClassifier().convention(attachClassesConvention.getClassesClassifier()) ); project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar); } }); }
Example 6
Source File: CliExecPlugin.java From gradle-plugins with Apache License 2.0 | 5 votes |
public void apply(Project project) { project.getPlugins().apply("de.undercouch.download"); CliExecExtension extension = project.getExtensions().create("cliExec", CliExecExtension.class); extension.project = project; project.afterEvaluate(project1 -> extension.init()); }
Example 7
Source File: MavenPublishBasePlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(getPluginClass()); project.getPlugins().apply(MavenPublishPlugin.class); publication = project.getExtensions().getByType(PublishingExtension.class) .getPublications() .create(getPublicationName(), MavenPublication.class); project.afterEvaluate(p -> { publication.from(getSoftwareComponent()); project.getPlugins().withType(SourcesJarPlugin.class, sourcesJarPlugin -> { Jar sourcesJar = sourcesJarPlugin.getSourcesJar().get(); publication.artifact(sourcesJar); }); project.getPlugins().withType(JavadocJarPlugin.class, javadocJarPlugin -> { Jar javadocJar = javadocJarPlugin.getJavadocJar().get(); publication.artifact(javadocJar); }); project.getPlugins().withType(SigningPlugin.class, signingPlugin -> project.getExtensions() .getByType(SigningExtension.class) .sign(publication) ); }); }
Example 8
Source File: AssembleNeededPlugin.java From gradle-plugins with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { project.getPlugins().apply("base"); Task assembleNeeded = project.getTasks().create("assembleNeeded"); assembleNeeded.dependsOn("assemble"); project.afterEvaluate(project1 -> { DomainObjectSet<ProjectDependency> projectDependencies = project1.getConfigurations().getByName("runtime").getAllDependencies().withType(ProjectDependency.class); for (ProjectDependency neededProjectDependency : projectDependencies) { assembleNeeded.dependsOn(neededProjectDependency.getDependencyProject().getPath() + ":assembleNeeded"); } }); }
Example 9
Source File: MeecrowavePlugin.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
@Override public void apply(final Project project) { project.getExtensions().create(NAME, MeecrowaveExtension.class); project.afterEvaluate(actionProject -> { final MeecrowaveExtension extension = MeecrowaveExtension.class.cast(actionProject.getExtensions().findByName(NAME)); if (extension != null && extension.isSkipMavenCentral()) { return; } actionProject.getRepositories().mavenCentral(); }); final Configuration configuration = project.getConfigurations().maybeCreate(NAME); configuration.getIncoming().beforeResolve(resolvableDependencies -> { String version; try { final String resource = "META-INF/maven/org.apache.meecrowave/meecrowave-gradle-plugin/pom.properties"; try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) { final Properties p = new Properties(); p.load(is); version = p.getProperty("version"); } } catch (final IOException e) { throw new IllegalStateException(e); } final DependencyHandler dependencyHandler = project.getDependencies(); final DependencySet dependencies = configuration.getDependencies(); dependencies.add(dependencyHandler.create("org.apache.meecrowave:meecrowave-core:" + version)); }); project.task(new HashMap<String, Object>() {{ put("type", MeecrowaveTask.class); put("group", "Embedded Application Server"); put("description", "Starts a meecrowave!"); }}, NAME); }
Example 10
Source File: PlayTwirlPlugin.java From playframework with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { PlayExtension playExtension = (PlayExtension) project.getExtensions().getByName(PlayApplicationPlugin.PLAY_EXTENSION_NAME); Configuration twirlCompilerConfiguration = createTwirlCompilerConfiguration(project); declareDefaultDependencies(project, twirlCompilerConfiguration, playExtension); TwirlSourceSet twirlSourceSet = PlayPluginHelper.createCustomSourceSet(project, DefaultTwirlSourceSet.class, "twirl"); TaskProvider<TwirlCompile> twirlCompile = createDefaultTwirlCompileTask(project, twirlSourceSet, twirlCompilerConfiguration, playExtension); project.afterEvaluate(project1 -> { if (hasTwirlSourceSetsWithJavaImports(twirlCompile)) { project.getDependencies().add(PlayApplicationPlugin.PLATFORM_CONFIGURATION, playExtension.getPlatform().getDependencyNotation("play-java").get()); } }); }
Example 11
Source File: TerraformPlugin.java From gradle-plugins with Apache License 2.0 | 5 votes |
public void apply(Project project) { project.getPlugins().apply(CliExecPlugin.class); File configDir = new File(project.getProjectDir(), "src/main/terraform"); TerraformExtension extension = project.getExtensions().create("terraform", TerraformExtension.class); extension.setProject(project); extension.setSourceDir(configDir); extension.getCli().setImageName("hashicorp/terraform"); extension.getCli().setImageTag("0.11.7"); // terraform needs to have its files in the local working directory extension.getCli().setWorkingDir("/workdir/src/main/terraform"); TerraformInitTask initTask = project.getTasks().create("terraformInit", TerraformInitTask.class); TerraformValidateTask validateTask = project.getTasks().create("terraformValidate", TerraformValidateTask.class); TerraformRefreshTask refreshTask = project.getTasks().create("terraformRefresh", TerraformRefreshTask.class); TerraformPlanTask planTask = project.getTasks().create("terraformPlan", TerraformPlanTask.class); TerraformApplyTask applyTask = project.getTasks().create("terraformApply", TerraformApplyTask.class); TerraformDestroyTask destroyTask = project.getTasks().create("terraformDestroy", TerraformDestroyTask.class); refreshTask.dependsOn(initTask); validateTask.dependsOn(initTask); planTask.dependsOn(validateTask); applyTask.dependsOn(planTask); destroyTask.dependsOn(planTask); CliExecExtension cliExec = project.getExtensions().getByType(CliExecExtension.class); cliExec.register("terraform", extension.getCli()); project.afterEvaluate(project1 -> { Cli cli = extension.getCli(); File terraformTempDir2 = new File(project.getBuildDir(), ".terraformCache"); cli.getVolumeMappings().put("/.terraform", terraformTempDir2); if (extension.getDebug()) { cli.getEnvironment().put("TF_LOG", "DEBUG"); } }); }
Example 12
Source File: JdkDownloadPlugin.java From crate with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { NamedDomainObjectContainer<Jdk> jdksContainer = project.container( Jdk.class, name -> new Jdk(name, project.getConfigurations().create("jdk_" + name), project.getObjects()) ); project.getExtensions().add(EXTENSION_NAME, jdksContainer); project.afterEvaluate(p -> jdksContainer.all(jdk -> { jdk.finalizeValues(); // depend on the jdk directory "artifact" from the root project var dependencies = project.getDependencies(); Map<String, Object> depConfig = Map.of( "path", ":", "configuration", configName( "extract", jdk.vendor(), jdk.version(), jdk.platform())); dependencies.add( jdk.configuration().getName(), dependencies.project(depConfig)); setupRootJdkDownload(project.getRootProject(), jdk); }) ); }
Example 13
Source File: ProtobufPlugin.java From curiostack with MIT License | 5 votes |
private static void configureSourceSetOutput( SourceSet sourceSet, TaskProvider<GenerateProtoTask> generateProto, ProtobufExtension extension, Project project) { project.afterEvaluate( unused -> extension .getSources() .getByName( sourceSet.getName(), source -> { sourceSet.getExtensions().add("proto", source); source.getSrcDirs().forEach(sourceSet.getResources()::srcDir); })); extension .getLanguages() .configureEach( language -> { String compileTaskName = sourceSet.getCompileTaskName(language.getName()); var compileTask = project.getTasks().findByName(compileTaskName); if (compileTask != null) { compileTask.dependsOn(generateProto); } sourceSet .getJava() .srcDir( extension .getOutputBaseDir() .map( outputBaseDir -> SourceSetUtils.getLanguageOutputDir( language, outputBaseDir, sourceSet.getName()))); }); }
Example 14
Source File: PackagePlugin.java From wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { project.getExtensions().create("swarm", SwarmExtension.class); project.afterEvaluate(__ -> { final TaskContainer tasks = project.getTasks(); final PackageTask packageTask = tasks.create("wildfly-swarm-package", PackageTask.class); tasks.withType(Jar.class, task -> packageTask.jarTask(task).dependsOn(task)); tasks.getByName("build").dependsOn(packageTask); }); }
Example 15
Source File: PackagePlugin.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { super.apply(project); PluginManager pluginManager = project.getPluginManager(); if (!pluginManager.hasPlugin(ThorntailArquillianPlugin.PLUGIN_ID)) { pluginManager.apply(ThorntailArquillianPlugin.class); } project.afterEvaluate(__ -> { final TaskContainer tasks = project.getTasks(); final PackageTask packageTask = tasks.create(THORNTAIL_PACKAGE_TASK_NAME, PackageTask.class); final Jar archiveTask = ThorntailUtils.getArchiveTask(project); packageTask.jarTask(archiveTask).dependsOn(archiveTask); tasks.getByName(JavaBasePlugin.BUILD_TASK_NAME).dependsOn(packageTask); Task classesTask = tasks.getByName(JavaPlugin.CLASSES_TASK_NAME); StartTask runTask = tasks.create(THORNTAIL_RUN_TASK_NAME, StartTask.class, StartTask::waitForProcess); runTask.dependsOn(classesTask); StartTask startTask = tasks.create(THORNTAIL_START_TASK_NAME, StartTask.class); startTask.dependsOn(classesTask); tasks.create(THORNTAIL_STOP_TASK_NAME, StopTask.class); }); }
Example 16
Source File: AbstractMetricsPlugin.java From gradle-metrics-plugin with Apache License 2.0 | 4 votes |
protected void configureProject(Project project) { checkNotNull(project); checkState(project == project.getRootProject(), "The metrics plugin may only be applied to the root project"); final MetricsPluginExtension extension = createMetricsExtension(project); if (project.hasProperty(METRICS_ENABLED_PROPERTY) && "false".equals(project.property(METRICS_ENABLED_PROPERTY))) { dispatcher = new NoopMetricsDispatcher(extension); project.getLogger().warn("Metrics have been disabled for this build."); return; } project.afterEvaluate(gradleProject -> { if (dispatcher instanceof UninitializedMetricsDispatcher) { switch (extension.getDispatcherType()) { case ES_HTTP: { dispatcher = new HttpESMetricsDispatcher(extension); break; } case SPLUNK: { dispatcher = new SplunkMetricsDispatcher(extension); break; } case REST: { dispatcher = new RestMetricsDispatcher(extension); break; } case NOOP: { dispatcher = new NoopMetricsDispatcher(extension); break; } case CUSTOM: { if(dispatcher instanceof UninitializedMetricsDispatcher) { throw new GradleException("setDispatcher should be called to set dispatcher when CUSTOM is selected as type"); } break; } } } configureProjectCollectors(gradleProject); }); }
Example 17
Source File: HelmPlugin.java From gradle-plugins with Apache License 2.0 | 4 votes |
public void apply(Project project) { project.getPlugins().apply(CliExecPlugin.class); HelmExtension extension = project.getExtensions().create("helm", HelmExtension.class); extension.setProject(project); // extension.setKubeConfig(KubernetesUtils.getDefaultKubeConfig(project)); HelmBootstrap helmBootstrap = project.getTasks().create("helmBootstrap", HelmBootstrap.class); DefaultTask helmPackages = project.getTasks().create("helmPackage", DefaultTask.class); HelmPublish helmPublish = project.getTasks().create("helmPublish", HelmPublish.class); Task helmUpdateRepository = project.getTasks().create("helmUpdateRepository", HelmUpdateRepository.class); DefaultTask helmPackagePrepare = project.getTasks().create("helmPackagePrepare", DefaultTask.class); helmPackagePrepare.dependsOn(helmBootstrap); helmUpdateRepository.dependsOn(helmBootstrap); helmPublish.dependsOn(helmUpdateRepository); helmPublish.dependsOn(helmPackages); CliExecExtension cliExec = project.getExtensions().getByType(CliExecExtension.class); cliExec.register("helm", extension.getCli()); Set<String> packageNames = extension.getPackageNames(); for (String packageName : packageNames) { HelmPackage helmPackage = project.getTasks().create("helmPackage" + toCamelCase(packageName), HelmPackage.class); helmPackage.setPackageName(packageName); helmPackage.dependsOn(helmPackagePrepare); helmPackages.dependsOn(helmPackage); } project.afterEvaluate(project1 -> { Cli cli = extension.getCli(); if (cli.isDockerized()) { helmBootstrap.setEnabled(false); } else if (cli.getDownload()) { helmBootstrap.src(cli.getDownloadUrl()); File downloadDir = cli.getDownloadDir(); downloadDir.mkdirs(); helmBootstrap.dest(downloadDir); } else { helmBootstrap.setEnabled(false); } }); }
Example 18
Source File: StaticSitePlugin.java From curiostack with MIT License | 4 votes |
@Override public void apply(Project project) { project.getPlugins().apply(NodePlugin.class); var config = StaticSiteExtension.create(project); var mergeSite = project .getTasks() .register( "mergeSite", Copy.class, t -> { t.from("src"); t.into("build/site"); for (SiteProject site : config.getSites().get()) { site.getProject() .getPlugins() .withType( LifecycleBasePlugin.class, unused -> t.dependsOn( site.getProject() .getTasks() .named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME))); t.from(site.getBuildDir(), copy -> copy.into(site.getOutputSubDir())); } }); var assemble = project.getTasks().named("assemble"); assemble.configure(t -> t.dependsOn(mergeSite)); var yarn = project.getRootProject().getTasks().named("yarn"); var deployAlpha = project .getTasks() .register( "deployAlpha", GcloudTask.class, t -> { t.dependsOn(assemble); // TODO(choko): Remove this major hack - the command line has two --project flags // and we're just lucky the later is used. t.args( config .getAppEngineProject() .map( appEngineProject -> ImmutableList.of( "app", "deploy", "--project=" + appEngineProject))); }); var deployProd = project .getTasks() .register( "deployProd", NodeTask.class, t -> { t.dependsOn(yarn, assemble); t.args( config .getFirebaseProject() .map( firebaseProject -> ImmutableList.of( "run", "firebase", "--project", firebaseProject, "deploy"))); }); project .getTasks() .register( "preview", NodeTask.class, t -> { t.dependsOn(yarn, assemble); t.args("run", "superstatic", "--port=8080"); }); CurioGenericCiPlugin.addToReleaseBuild(project, deployProd); project.afterEvaluate( unused -> { if (config.getAutoDeployAlpha().get()) { CurioGenericCiPlugin.addToMasterBuild(project, deployAlpha); } }); }
Example 19
Source File: ModularJavaExec.java From gradle-modules-plugin with MIT License | 4 votes |
public static void configure(Project project) { project.afterEvaluate(ModularJavaExec::configureAfterEvaluate); }
Example 20
Source File: AtlasPlugin.java From atlas with Apache License 2.0 | 2 votes |
@Override public void apply(Project project) { super.apply(project); atlasConfigurationHelper.createLibCompenents(); project.afterEvaluate(project1 -> { if (PluginTypeUtils.isAppProject(project) && atlasExtension.isAtlasEnabled()) { Map<String, String> multiDex = new HashMap<>(); multiDex.put("group", "com.android.support"); multiDex.put("module", "multidex"); project1.getConfigurations().all(configuration -> configuration.exclude(multiDex)); } Plugin plugin = project.getPlugins().findPlugin("kotlin-android"); if (plugin != null) { project.getDependencies().add("compile", "org.jetbrains.kotlin:kotlin-stdlib:1.2.41"); } atlasConfigurationHelper.registAtlasStreams(); atlasConfigurationHelper.configDependencies(atlasExtension.getTBuildConfig().getAwbConfigFile()); //3. update extension atlasConfigurationHelper.updateExtensionAfterEvaluate(); //4. Set up the android builder try { atlasConfigurationHelper.createBuilderAfterEvaluate(); } catch (Exception e) { throw new GradleException("update builder failed", e); } //5. Configuration tasks atlasConfigurationHelper.configTasksAfterEvaluate(); project1.getTasks().create("atlasList", AtlasListTask.class); }); }