-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
produce version report on outgoing configurations (#33)
- Loading branch information
Showing
14 changed files
with
245 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ build | |
*.iws | ||
out | ||
generated_* | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
gradle-versions/src/main/java/com/markelliot/gradle/versions/RootUpdateVersionsPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.markelliot.gradle.versions; | ||
|
||
import java.util.Map; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.Task; | ||
import org.gradle.api.artifacts.Configuration; | ||
import org.gradle.api.artifacts.Dependency; | ||
|
||
public final class RootUpdateVersionsPlugin implements Plugin<Project> { | ||
private static final String VERSIONS_PROPS = "versions.props"; | ||
private static final String ALL_REPORTS = "allReports"; | ||
|
||
@Override | ||
public void apply(Project project) { | ||
if (!project.equals(project.getRootProject())) { | ||
throw new IllegalStateException("Plugin must be applied onto root project"); | ||
} | ||
|
||
Configuration reportConfiguration = createReportConfiguration(project); | ||
project.getAllprojects() | ||
.forEach( | ||
subProject -> { | ||
subProject.getPluginManager().apply(UpdateVersionsPlugin.class); | ||
Dependency dependency = | ||
project.getDependencies() | ||
.project( | ||
Map.of( | ||
"path", | ||
subProject.getPath(), | ||
"configuration", | ||
UpdateVersionsPlugin.NEW_VERSIONS)); | ||
project.getDependencies() | ||
.add(reportConfiguration.getName(), dependency); | ||
}); | ||
|
||
project.getTasks() | ||
.register( | ||
"updateVersionsProps", | ||
UpdateVersionsPropsTask.class, | ||
task -> { | ||
task.setDescription( | ||
"Uses result of checkNewVersions task to update versions.props"); | ||
|
||
task.getVersionsProps().set(project.file(VERSIONS_PROPS)); | ||
task.getReports().from(reportConfiguration); | ||
}); | ||
|
||
project.getTasks() | ||
.register( | ||
"updatePlugins", | ||
UpdatePluginsTask.class, | ||
task -> { | ||
task.getReports().from(reportConfiguration); | ||
task.setDescription( | ||
"Uses result of checkNewVersions task to update buildscript plugin blocks"); | ||
}); | ||
project.getTasks() | ||
.create("updateGradleWrapper", UpdateGradleWrapperTask.class) | ||
.setDescription("Uses result of checkNewGradleVersion to update Gradle wrapper"); | ||
|
||
Task gradleTask = | ||
project.getTasks().create("checkNewGradleVersion", CheckNewGradleVersionTask.class); | ||
gradleTask.setDescription("Checks for and reports on existence of a new Gradle version"); | ||
project.getTasks().getByName("checkNewVersions").dependsOn(gradleTask); | ||
} | ||
|
||
private static Configuration createReportConfiguration(Project project) { | ||
return project.getConfigurations() | ||
.create( | ||
ALL_REPORTS, | ||
conf -> { | ||
conf.setCanBeResolved(true); | ||
conf.setCanBeConsumed(true); | ||
conf.setVisible(false); | ||
}); | ||
} | ||
} |
38 changes: 17 additions & 21 deletions
38
gradle-versions/src/main/java/com/markelliot/gradle/versions/UpdatePluginsTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.