Skip to content

Commit

Permalink
Add Plugin-Versions plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Mar 20, 2023
1 parent 86953b5 commit 27e9601
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ allprojects {
test.useJUnitPlatform()

dependencies {
implementation platform("org.junit:junit-bom:5.9.2")
testImplementation platform("org.junit:junit-bom:5.9.2")

testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
Expand Down
Empty file added buildSrc/build.gradle
Empty file.
28 changes: 28 additions & 0 deletions settings-plugin/build.gradle
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"))
}
}
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);
}
});

}
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ include "mkdocs-plugin"
include "quicktype-plugin"
include "plantuml-plugin"

include "settings-plugin"

include "gradle-plugin-platform"

0 comments on commit 27e9601

Please sign in to comment.