-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86953b5
commit 27e9601
Showing
5 changed files
with
63 additions
and
1 deletion.
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
Empty file.
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,28 @@ | ||
import io.freefair.gradle.plugins.build.ListPluginIds | ||
|
||
plugins { | ||
id "java-gradle-plugin" | ||
id "maven-publish" | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
pluginManagement { | ||
id = "io.freefair.settings.plugin-versions" | ||
implementationClass = "io.freefair.gradle.plugins.settings.PluginVersionsPlugin" | ||
displayName = "FreeFair Plugin Version Management Plugin" | ||
description = "Apply this to your settings.gradle to get default versions for all FreeFair Gradle Plugins" | ||
tags.set(["plugin-management", "freefair"]) | ||
} | ||
} | ||
} | ||
|
||
tasks.register("listPluginIds", ListPluginIds) { | ||
outputFile = file("build/plugin-ids") | ||
} | ||
|
||
tasks.named("processResources", ProcessResources).configure { | ||
into("META-INF/freefair") { | ||
from(tasks.named("listPluginIds")) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
settings-plugin/src/main/java/io/freefair/gradle/plugins/settings/PluginVersionsPlugin.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,32 @@ | ||
package io.freefair.gradle.plugins.settings; | ||
|
||
import lombok.SneakyThrows; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.codehaus.groovy.runtime.ResourceGroovyMethods; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.initialization.Settings; | ||
|
||
import java.net.URL; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
public class PluginVersionsPlugin implements Plugin<Settings> { | ||
@SneakyThrows | ||
@Override | ||
public void apply(Settings settings) { | ||
|
||
String version = this.getClass().getPackage().getImplementationVersion(); | ||
|
||
URL resource = this.getClass().getClassLoader().getResource("META-INF/freefair/plugin-ids"); | ||
|
||
List<String> ids = ResourceGroovyMethods.readLines(resource); | ||
|
||
settings.getPluginManagement().plugins(pds -> { | ||
for (String id : ids) { | ||
log.info("id '{}' version '{}'", id, version); | ||
pds.id(id).version(version); | ||
} | ||
}); | ||
|
||
} | ||
} |
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