various fixes
This commit is contained in:
12
build.gradle
12
build.gradle
@@ -6,7 +6,6 @@ subprojects {
|
||||
url = woggioniMavenRepositoryUrl
|
||||
}
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
group = "net.woggioni.gradle"
|
||||
|
||||
@@ -22,12 +21,10 @@ subprojects {
|
||||
tasks.named("test", Test) {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
childProjects.forEach { name, project ->
|
||||
project.with {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
@@ -40,10 +37,11 @@ subprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "7.1.1"
|
||||
gradleVersion = getProperty("version.gradle")
|
||||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
|
@@ -1,24 +1,13 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "net.woggioni.gradle:dependency-export:0.1"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "net.woggioni.gradle.dependency-export" version "0.1"
|
||||
id "net.woggioni.gradle.dependency-export"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
exportDependencies {
|
||||
configurationName = 'runtimeCl'
|
||||
configurationName = 'runtimeClasspath'
|
||||
}
|
||||
|
||||
renderDependencies {
|
||||
|
@@ -1,6 +1,10 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url = 'https://woggioni.net/mvn/'
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id "net.woggioni.gradle.dependency-export" version "0.1"
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,9 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("net.woggioni.gradle:dependency-export:0.1")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("net.woggioni.gradle.dependency-export") version "0.1"
|
||||
id("net.woggioni.gradle.dependency-export")
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -23,7 +11,7 @@ dependencies {
|
||||
}
|
||||
|
||||
configure<ExportDependenciesPluginExtension> {
|
||||
configurationName = "runtime"
|
||||
configurationName = "runtimeClassapath"
|
||||
}
|
||||
|
||||
configure<RenderDependenciesPluginExtension> {
|
||||
|
@@ -1,6 +1,11 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
url = 'https://woggioni.net/mvn/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
plugins {
|
||||
id "net.woggioni.gradle.dependency-export" version "0.1"
|
||||
}
|
||||
}
|
||||
|
@@ -8,8 +8,8 @@ exportDependencies {
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -1,9 +1,6 @@
|
||||
woggioniMavenRepositoryUrl=https://mvn.woggioni.net/
|
||||
|
||||
|
||||
version.kotlin=1.3.72
|
||||
version.gradlePublish=0.10.1
|
||||
version.gradle=7.2
|
||||
version.lombok=1.18.16
|
||||
version.slf4j=1.7.30
|
||||
version.junitJupiter=5.7.2
|
||||
version.junitPlatform=1.7.0
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@@ -5,6 +5,11 @@ plugins {
|
||||
|
||||
version = "0.1"
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("JlinkPlugin") {
|
||||
|
@@ -1,5 +1,11 @@
|
||||
package net.woggioni.gradle.jlink;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
@@ -9,22 +15,23 @@ import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.DirectoryProperty;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.model.ObjectFactory;
|
||||
import org.gradle.api.plugins.*;
|
||||
import org.gradle.api.plugins.BasePluginExtension;
|
||||
import org.gradle.api.plugins.ExtensionContainer;
|
||||
import org.gradle.api.plugins.JavaApplication;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.*;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.Optional;
|
||||
import org.gradle.api.tasks.OutputDirectory;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.jvm.toolchain.JavaInstallationMetadata;
|
||||
import org.gradle.jvm.toolchain.JavaLauncher;
|
||||
import org.gradle.jvm.toolchain.JavaToolchainService;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class JlinkTask extends DefaultTask {
|
||||
|
||||
|
@@ -7,8 +7,13 @@ version = "0.1"
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("JPMSCheckPlugin") {
|
||||
id = "net.woggioni.plugins.jpms-check"
|
||||
id = "net.woggioni.gradle.jpms-check"
|
||||
implementationClass = "net.woggioni.gradle.jpms.check.JPMSCheckPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
@@ -4,6 +4,11 @@ plugins {
|
||||
|
||||
version = "0.1"
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("LombokPlugin") {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.woggioni.gradle.lombok;
|
||||
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
@@ -13,10 +14,12 @@ import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.SourceSetContainer;
|
||||
import org.gradle.api.tasks.TaskContainer;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.api.tasks.javadoc.Javadoc;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import org.gradle.jvm.toolchain.JavaToolchainSpec;
|
||||
|
||||
public class LombokPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
@@ -76,6 +79,21 @@ public class LombokPlugin implements Plugin<Project> {
|
||||
javadoc.getInputs().files(delombokTaskProvider);
|
||||
}
|
||||
}
|
||||
JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
|
||||
JavaToolchainSpec toolchain = javaPluginExtension.getToolchain();
|
||||
if(toolchain.getLanguageVersion().isPresent()) {
|
||||
project.afterEvaluate((Project pro) -> {
|
||||
if(toolchain.getLanguageVersion().get().asInt() >= 16) {
|
||||
pro.getTasks().withType(JavaCompile.class, t -> {
|
||||
t.getOptions().getForkOptions().getJvmArgs().add("--illegal-access=permit");
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if(JavaVersion.current().compareTo(JavaVersion.VERSION_16) >= 0) {
|
||||
project.getTasks().withType(JavaCompile.class, t -> {
|
||||
t.getOptions().getForkOptions().getJvmArgs().add("--illegal-access=permit");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -8,12 +8,12 @@ version = "0.1"
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("MultiVersionJarPlugin") {
|
||||
id = "net.woggioni.plugins.multi-version-jar"
|
||||
implementationClass = "net.woggioni.plugins.multi.release.jar.MultiVersionJarPlugin"
|
||||
id = "net.woggioni.gradle.multi-version-jar"
|
||||
implementationClass = "net.woggioni.gradle.multi.release.jar.MultiVersionJarPlugin"
|
||||
}
|
||||
create("MultiReleaseJarPlugin") {
|
||||
id = "net.woggioni.plugins.multi-release-jar"
|
||||
implementationClass = "net.woggioni.plugins.multi.release.jar.MultiReleaseJarPlugin"
|
||||
id = "net.woggioni.gradle.multi-release-jar"
|
||||
implementationClass = "net.woggioni.gradle.multi.release.jar.MultiReleaseJarPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.woggioni.plugins.multi.release.jar
|
||||
package net.woggioni.gradle.multi.release.jar
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
@@ -7,6 +8,7 @@ import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.attributes.java.TargetJvmVersion
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.internal.plugins.DslObject
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
@@ -23,12 +25,13 @@ class MultiReleaseJarPlugin implements Plugin<Project> {
|
||||
it.languageVersion.get()
|
||||
} ?: JavaVersion.current()
|
||||
if(binaryVersion > JavaVersion.VERSION_1_8) {
|
||||
Configuration compileClasspathConfiguration = project.configurations.compileClasspath
|
||||
SourceSet mainSourceSet = (project.sourceSets.main as SourceSet)
|
||||
JavaCompile compileJavaTask = project.tasks.named("compileJava", JavaCompile).get()
|
||||
JavaCompile compileJavaTask = project.tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile).get()
|
||||
compileJavaTask.configure {
|
||||
options.release.set(JavaVersion.VERSION_1_8.majorVersion.toInteger())
|
||||
}
|
||||
Jar jarTask = project.tasks.named("jar", Jar).get()
|
||||
Jar jarTask = project.tasks.named(JavaPlugin.JAR_TASK_NAME, Jar).get()
|
||||
jarTask.configure {
|
||||
manifest.attributes('Multi-Release': 'true')
|
||||
}
|
||||
@@ -42,30 +45,42 @@ class MultiReleaseJarPlugin implements Plugin<Project> {
|
||||
SourceDirectorySet sourceDirectorySet =
|
||||
project.objects.sourceDirectorySet("java${javaVersion.majorVersion}", javaVersion.toString())
|
||||
sourceDirectorySet.with {
|
||||
srcDir(new File(project.projectDir, "src/main/${sourceDirectorySet.name}"))
|
||||
srcDir(new File(project.projectDir, "src/${mainSourceSet.name}/${sourceDirectorySet.name}"))
|
||||
destinationDirectory.set(new File(project.buildDir, "classes/${sourceDirectorySet.name}"))
|
||||
sourcePaths << sourceDirectories
|
||||
}
|
||||
TaskProvider<JavaCompile> compileTask = project.tasks.register(JavaPlugin.COMPILE_JAVA_TASK_NAME + javaVersion.majorVersion, JavaCompile, {
|
||||
options.release.set(javaVersion.majorVersion.toInteger())
|
||||
classpath = compileOutputs.stream().reduce { fc1, fc2 -> fc1 + fc2 }.get()
|
||||
it.doFirst {
|
||||
options.compilerArgs << "--module-path" << mainSourceSet.compileClasspath.asPath
|
||||
new DslObject(mainSourceSet).getConvention().getPlugins().put(sourceDirectorySet.name, sourceDirectorySet)
|
||||
mainSourceSet.getExtensions().add(SourceDirectorySet.class, sourceDirectorySet.name, sourceDirectorySet)
|
||||
TaskProvider<JavaCompile> compileTask = project.tasks.register(JavaPlugin.COMPILE_JAVA_TASK_NAME + javaVersion.majorVersion, JavaCompile, { javaCompileTask ->
|
||||
javaCompileTask.options.release.set(javaVersion.majorVersion.toInteger())
|
||||
javaCompileTask.classpath = compileClasspathConfiguration + compileOutputs.stream().reduce { fc1, fc2 -> fc1 + fc2 }.get()
|
||||
javaCompileTask.doFirst {
|
||||
if(project.hasProperty("jpms.module.name")) {
|
||||
javaCompileTask.options.compilerArgs << "--patch-module" <<
|
||||
"${project.property("jpms.module.name")}=${mainSourceSet.output.asPath}"
|
||||
} else {
|
||||
throw new GradleException("Missing property 'jpms.module.name'")
|
||||
}
|
||||
source = sourceDirectorySet
|
||||
destinationDirectory.set(sourceDirectorySet.destinationDirectory)
|
||||
options.annotationProcessorPath = mainSourceSet.annotationProcessorPath
|
||||
modularity.inferModulePath = false
|
||||
options.sourcepath = sourcePaths.stream().reduce { fc1, fc2 -> fc1 + fc2 }.get()
|
||||
}
|
||||
javaCompileTask.source = sourceDirectorySet
|
||||
javaCompileTask.destinationDirectory.set(sourceDirectorySet.destinationDirectory)
|
||||
javaCompileTask.options.annotationProcessorPath = mainSourceSet.annotationProcessorPath
|
||||
javaCompileTask.modularity.inferModulePath = javaPluginExtension.modularity.inferModulePath
|
||||
javaCompileTask.options.sourcepath = sourcePaths.stream().reduce { fc1, fc2 -> fc1 + fc2 }.get()
|
||||
})
|
||||
compileOutputs << compileJavaTask.outputs.files
|
||||
compileOutputs << compileTask.get().outputs.files
|
||||
sourceDirectorySet.compiledBy(compileTask, { it.getDestinationDirectory()})
|
||||
jarTask.configure {
|
||||
from(compileTask.get().outputs.files) {
|
||||
from(compileTask.get().destinationDirectory) {
|
||||
into("META-INF/versions/${javaVersion.majorVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SourceSet testSourceSet = (project.sourceSets.test as SourceSet)
|
||||
testSourceSet.compileClasspath += compileOutputs.stream().reduce { fc1, fc2 -> fc1 + fc2 }.get()
|
||||
testSourceSet.runtimeClasspath += compileOutputs.stream().reduce { fc1, fc2 -> fc1 + fc2 }.get()
|
||||
|
||||
["apiElements", "runtimeElements"].forEach { String name ->
|
||||
Configuration conf = project.configurations.getByName(name)
|
||||
conf.attributes {
|
@@ -1,4 +1,4 @@
|
||||
package net.woggioni.plugins.multi.release.jar
|
||||
package net.woggioni.gradle.multi.release.jar
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Plugin
|
@@ -2,11 +2,6 @@ pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version this['version.kotlin']
|
||||
id 'com.gradle.plugin-publish' version this['version.gradlePublish']
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-gradle-plugins"
|
||||
@@ -17,6 +12,3 @@ include("multi-release-jar")
|
||||
include("wildfly")
|
||||
include("lombok")
|
||||
include("jlink")
|
||||
include("executable-jar")
|
||||
include("executable-jar:executable-jar-common")
|
||||
include("executable-jar:executable-jar-launcher")
|
||||
|
@@ -5,6 +5,11 @@ plugins {
|
||||
|
||||
version = "0.1"
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("WildflyPlugin") {
|
||||
|
Reference in New Issue
Block a user