Java Code Examples for org.gradle.api.project#allprojects()
The following examples show how to use
org.gradle.api.project#allprojects() .
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: VersionPlugin.java From pygradle with Apache License 2.0 | 6 votes |
@Override public void apply(Project target) { if (target.getRootProject() != target) { throw new GradleException("Cannot apply dependency plugin to a non-root project"); } File versionProperties = target.file("version.properties"); Version version = VersionFile.getVersion(versionProperties); if (!target.hasProperty("release") || !Boolean.parseBoolean((String) target.property("release"))) { version = version.asSnapshot(); } logger.lifecycle("Building using version {}", version); target.allprojects(new VersionAction(version)); }
Example 2
Source File: PomContributorsPlugin.java From shipkit with MIT License | 6 votes |
@Override public void apply(final Project project) { project.getPlugins().apply(GitHubContributorsPlugin.class); final Task fetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS); project.allprojects(subproject -> subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> { //Because maven-publish plugin uses new configuration model, we cannot get the task directly //So we use 'matching' technique. subproject.getTasks().matching(withName(POM_TASK)).all(t -> t.mustRunAfter(fetcher)); //Pom task needs data from fetcher hence 'mustRunAfter' above. //We don't use 'dependsOn' because we want the fetcher to be included only when we are publishing to Bintray Task upload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK); upload.dependsOn(fetcher); })); }
Example 3
Source File: VersioningPlugin.java From shipkit with MIT License | 6 votes |
public void apply(final Project project) { LocalSnapshotPlugin snapshotPlugin = project.getPlugins().apply(LocalSnapshotPlugin.class); final File versionFile = project.file(VERSION_FILE_NAME); final VersionInfo versionInfo = new VersionInfoFactory().createVersionInfo(versionFile, project.getVersion(), snapshotPlugin.isSnapshot()); project.getExtensions().add(VersionInfo.class.getName(), versionInfo); final String version = versionInfo.getVersion(); project.allprojects(project1 -> project1.setVersion(version)); TaskMaker.task(project, BUMP_VERSION_FILE_TASK, BumpVersionFileTask.class, t -> { t.setDescription("Increments version number in " + versionFile.getName()); t.setVersionFile(versionFile); String versionChangeMessage = formatVersionInformationInCommitMessage(version, versionInfo.getPreviousVersion()); GitPlugin.registerChangesForCommitIfApplied(singletonList(versionFile), versionChangeMessage, t); }); }
Example 4
Source File: GitVersionPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; this.logger = project.getLogger(); project.setVersion(resolveVersion()); project.allprojects(p -> p.setVersion(project.getVersion())); }
Example 5
Source File: ShipkitJavaPlugin.java From shipkit with MIT License | 5 votes |
public void apply(final Project project) { ProjectUtil.requireRootProject(project, this.getClass()); project.getPlugins().apply(ShipkitBasePlugin.class); project.getPlugins().apply(PomContributorsPlugin.class); project.allprojects(subproject -> subproject.getPlugins().withId("java", plugin -> { subproject.getPlugins().apply(JavaBintrayPlugin.class); })); }
Example 6
Source File: GradlePortalReleasePlugin.java From shipkit with MIT License | 5 votes |
@Override public void apply(final Project project) { ReleasePlugin releasePlugin = project.getPlugins().apply(ReleasePlugin.class); final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration(); final Task performRelease = project.getTasks().getByName(ReleasePlugin.PERFORM_RELEASE_TASK); final Task gitPush = project.getTasks().getByName(GitPlugin.GIT_PUSH_TASK); project.allprojects(subproject -> subproject.getPlugins().withId("com.gradle.plugin-publish", plugin -> { subproject.getPlugins().apply(PluginDiscoveryPlugin.class); subproject.getPlugins().apply(PluginValidationPlugin.class); subproject.getPlugins().apply(GradlePortalPublishPlugin.class); subproject.getPlugins().apply(ComparePublicationsPlugin.class); Task publishPlugins = subproject.getTasks().getByName(GradlePortalPublishPlugin.PUBLISH_PLUGINS_TASK); performRelease.dependsOn(publishPlugins); //perform release will actually publish the plugins publishPlugins.mustRunAfter(gitPush); //git push is easier to revert than perform release //We first build plugins to be published, then do git push, we're using 'buildArchives' for that //We know that "buildArchives" task exists because 'com.gradle.plugin-publish' applies Java plugin Task archivesTask = subproject.getTasks().getByName("buildArchives"); publishPlugins.dependsOn(archivesTask); gitPush.mustRunAfter(archivesTask); UpdateReleaseNotesTask updateNotes = (UpdateReleaseNotesTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_TASK); updateNotes.setPublicationRepository(conf.getReleaseNotes().getPublicationRepository()); UpdateReleaseNotesOnGitHubTask updateNotesOnGitHub = (UpdateReleaseNotesOnGitHubTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_ON_GITHUB_TASK); updateNotesOnGitHub.setPublicationRepository(conf.getReleaseNotes().getPublicationRepository()); //when contributors are testing, we need to avoid publish task because it requires secret keys releasePlugin.excludeFromContributorTest(GradlePortalPublishPlugin.PUBLISH_PLUGINS_TASK); })); }
Example 7
Source File: GitVersionPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; this.logger = project.getLogger(); project.setVersion(resolveVersion()); project.allprojects(p -> p.setVersion(project.getVersion())); }
Example 8
Source File: AggregateJavadocPlugin.java From gradle-plugins with MIT License | 4 votes |
@Override public void apply(Project project) { aggregateJavadoc = project.getTasks().register("aggregateJavadoc", Javadoc.class, aggregateJavadoc -> { aggregateJavadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); aggregateJavadoc.getConventionMapping().map("destinationDir", new Callable<Object>() { @Override public Object call() { File docsDir = Optional.ofNullable(project.getConvention().findPlugin(JavaPluginConvention.class)) .map(JavaPluginConvention::getDocsDir) .orElse(new File(project.getBuildDir(), "docs")); return new File(docsDir, "aggregateJavadoc"); } }); }); project.allprojects(p -> p.getPlugins().withType(JavaPlugin.class, jp -> aggregateJavadoc.configure(aj -> { TaskProvider<Javadoc> javadoc = p.getTasks().named(JavaPlugin.JAVADOC_TASK_NAME, Javadoc.class); aj.source(javadoc.map(Javadoc::getSource)); if (aj.getClasspath() instanceof ConfigurableFileCollection) { ((ConfigurableFileCollection) aj.getClasspath()).from(javadoc.map(Javadoc::getClasspath)); } else { ConfigurableFileCollection classpath = project.files(); classpath.from(aj.getClasspath()); classpath.from(javadoc.map(Javadoc::getClasspath)); aj.setClasspath(classpath); } StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.get().getOptions(); StandardJavadocDocletOptions aggregateOptions = (StandardJavadocDocletOptions) aj.getOptions(); options.getLinks().forEach(link -> { if (!aggregateOptions.getLinks().contains(link)) { aggregateOptions.getLinks().add(link); } }); options.getLinksOffline().forEach(link -> { if (!aggregateOptions.getLinksOffline().contains(link)) { aggregateOptions.getLinksOffline().add(link); } }); options.getJFlags().forEach(jFlag -> { if (!aggregateOptions.getJFlags().contains(jFlag)) { aggregateOptions.getJFlags().add(jFlag); } }); }) ) ); }
Example 9
Source File: BintrayReleasePlugin.java From shipkit with MIT License | 4 votes |
public void apply(final Project project) { ReleasePlugin releasePlugin = project.getPlugins().apply(ReleasePlugin.class); final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration(); final Task gitPush = project.getTasks().getByName(GitPlugin.GIT_PUSH_TASK); final Task performRelease = project.getTasks().getByName(ReleasePlugin.PERFORM_RELEASE_TASK); project.allprojects(subproject -> { subproject.getPlugins().withType(ShipkitBintrayPlugin.class, plugin -> { Task bintrayUpload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK); performRelease.dependsOn(bintrayUpload); //bintray upload after git push so that when git push fails we don't publish jars to bintray //git push is easier to undo than deleting published jars (not possible with Central) bintrayUpload.mustRunAfter(gitPush); final BintrayExtension bintray = subproject.getExtensions().getByType(BintrayExtension.class); deferredConfiguration(subproject, () -> { UpdateReleaseNotesTask updateNotes = (UpdateReleaseNotesTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_TASK); UpdateReleaseNotesOnGitHubTask updateNotesOnGitHub = (UpdateReleaseNotesOnGitHubTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_ON_GITHUB_TASK); UpdateReleaseNotesOnGitHubCleanupTask updateNotesOnGitHubCleanup = (UpdateReleaseNotesOnGitHubCleanupTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_ON_GITHUB_CLEANUP_TASK); String userSpecifiedRepo = conf.getLenient().getReleaseNotes().getPublicationRepository(); if (userSpecifiedRepo != null) { updateNotes.setPublicationRepository(userSpecifiedRepo); updateNotesOnGitHub.setPublicationRepository(userSpecifiedRepo); updateNotesOnGitHubCleanup.setPublicationRepository(userSpecifiedRepo); } else { String repoLink = BintrayUtil.getRepoLink(bintray); updateNotes.setPublicationRepository(repoLink); updateNotesOnGitHub.setPublicationRepository(repoLink); updateNotesOnGitHubCleanup.setPublicationRepository(repoLink); } updateNotesOnGitHub.setGitHubWriteToken(conf.getLenient().getGitHub().getWriteAuthToken()); }); }); subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> { //Making git push run as late as possible because it is an operation that is hard to reverse. //Git push will be executed after all tasks needed by bintrayUpload // but before bintrayUpload. //Using task path as String because the task comes from maven-publish new configuration model // and we cannot refer to it in a normal way, by task instance. String mavenLocalTask = subproject.getPath() + ":" + MAVEN_LOCAL_TASK; gitPush.mustRunAfter(mavenLocalTask); }); subproject.getPlugins().withType(ShipkitBintrayPlugin.class, plugin -> { //when contributors are testing, we need to avoid bintray task because it requires secret keys releasePlugin.excludeFromContributorTest(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK); }); }); }
Example 10
Source File: AggregateJavadocPlugin.java From gradle-plugins with MIT License | 4 votes |
@Override public void apply(Project project) { aggregateJavadoc = project.getTasks().register("aggregateJavadoc", Javadoc.class, aggregateJavadoc -> { aggregateJavadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); aggregateJavadoc.getConventionMapping().map("destinationDir", new Callable<Object>() { @Override public Object call() { File docsDir = Optional.ofNullable(project.getConvention().findPlugin(JavaPluginConvention.class)) .map(JavaPluginConvention::getDocsDir) .orElse(new File(project.getBuildDir(), "docs")); return new File(docsDir, "aggregateJavadoc"); } }); }); project.allprojects(p -> p.getPlugins().withType(JavaPlugin.class, jp -> aggregateJavadoc.configure(aj -> { TaskProvider<Javadoc> javadoc = p.getTasks().named(JavaPlugin.JAVADOC_TASK_NAME, Javadoc.class); aj.source(javadoc.map(Javadoc::getSource)); if (aj.getClasspath() instanceof ConfigurableFileCollection) { ((ConfigurableFileCollection) aj.getClasspath()).from(javadoc.map(Javadoc::getClasspath)); } else { ConfigurableFileCollection classpath = project.files(); classpath.from(aj.getClasspath()); classpath.from(javadoc.map(Javadoc::getClasspath)); aj.setClasspath(classpath); } StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.get().getOptions(); StandardJavadocDocletOptions aggregateOptions = (StandardJavadocDocletOptions) aj.getOptions(); options.getLinks().forEach(link -> { if (!aggregateOptions.getLinks().contains(link)) { aggregateOptions.getLinks().add(link); } }); options.getLinksOffline().forEach(link -> { if (!aggregateOptions.getLinksOffline().contains(link)) { aggregateOptions.getLinksOffline().add(link); } }); options.getJFlags().forEach(jFlag -> { if (!aggregateOptions.getJFlags().contains(jFlag)) { aggregateOptions.getJFlags().add(jFlag); } }); }) ) ); }