diff --git a/README.md b/README.md index 5369f77..c3fc1a6 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ buildscript { Then you can create a task that compiles `module-info.java` like this: ```kotlin -val compileModuleInfo = tasks.create("compileModuleInfo") { +val compileModuleInfo = tasks.create("compileModuleInfo") { sourceFile.set(file("src/main/module-info.java")) targetFile.set(buildDir.resolve("classes/java/module-info/module-info.class")) diff --git a/build.gradle.kts b/build.gradle.kts index 535f866..66fea0e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,61 +6,61 @@ plugins { `maven-publish` signing id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + + `java-gradle-plugin` + id("com.gradle.plugin-publish") version "0.18.0" } -allprojects { - apply { - plugin("java-library") - plugin("com.github.johnrengelman.shadow") - } +group = "org.glavo" +version = "2.0"// + "-SNAPSHOT" - group = "org.glavo" - version = "2.0-RC1" + "-SNAPSHOT" +repositories { + mavenCentral() +} - repositories { - mavenCentral() - } +tasks.compileJava { + sourceCompatibility = "1.8" + targetCompatibility = "1.8" +} - tasks.compileJava { - sourceCompatibility = "1.8" - targetCompatibility = "1.8" - } - - tasks.withType().configureEach { - (options as StandardJavadocDocletOptions).also { - it.encoding("UTF-8") - it.addStringOption("link", "https://docs.oracle.com/en/java/javase/17/docs/api/") - it.addBooleanOption("html5", true) - it.addStringOption("Xdoclint:none", "-quiet") - } +tasks.withType().configureEach { + (options as StandardJavadocDocletOptions).also { + it.encoding("UTF-8") + it.addStringOption("link", "https://docs.oracle.com/en/java/javase/17/docs/api/") + it.addBooleanOption("html5", true) + it.addStringOption("Xdoclint:none", "-quiet") } +} - java { - withSourcesJar() - withJavadocJar() - } +java { + withSourcesJar() + withJavadocJar() +} - tasks.jar { - archiveClassifier.set("core") - } +tasks.jar { + // archiveClassifier.set("core") +} - tasks.shadowJar { - archiveClassifier.set("") +tasks.shadowJar { + // archiveClassifier.set(null as String?) - relocate("org.objectweb.asm", "org.glavo.mic.asm") - relocate("com.github.javaparser", "org.glavo.mic.javaparser") + // relocate("org.objectweb.asm", "org.glavo.mic.asm") + // relocate("com.github.javaparser", "org.glavo.mic.javaparser") - minimize() - } + minimize() } dependencies { + compileOnly(gradleApi()) + implementation("com.github.javaparser:javaparser-core:3.24.2") implementation("org.ow2.asm:asm:9.3") } -loadMavenPublishProperties() +configurations.named(JavaPlugin.API_CONFIGURATION_NAME) { + dependencies.remove(project.dependencies.gradleApi()) +} description = "Compiler for module-info.java" @@ -72,18 +72,22 @@ tasks.jar { } } +loadMavenPublishProperties() + configure { publications { create("maven") { - project.shadow.component(this) groupId = project.group.toString() version = project.version.toString() artifactId = project.name - //artifact(tasks.shadowJar) - artifact(tasks["sourcesJar"]) - artifact(tasks["javadocJar"]) + + from(components["java"]) + + // artifact(tasks.shadowJar) + // artifact(tasks["sourcesJar"]) + // artifact(tasks["javadocJar"]) pom { name.set(project.name) @@ -134,8 +138,23 @@ nexusPublishing { } } -tasks.withType { - enabled = false + + +pluginBundle { + website = "https://github.com/Glavo/module-info-compiler" + vcsUrl = "https://github.com/Glavo/module-info-compiler.git" + tags = listOf("java", "modules", "jpms", "modularity") +} + +gradlePlugin { + plugins { + create("compileModuleInfoPlugin") { + id = "org.glavo.compile-module-info-plugin" + displayName = "Compile Module Info Plugin" + description = rootProject.description + implementationClass = "org.glavo.mic.CompileModuleInfoPlugin" + } + } } fun loadMavenPublishProperties() { diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts deleted file mode 100644 index ee49ea1..0000000 --- a/gradle-plugin/build.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -plugins { - `java-gradle-plugin` - id("com.gradle.plugin-publish") version "0.18.0" -} - -dependencies { - compileOnly(gradleApi()) - - implementation(rootProject) -} - -configurations.named(JavaPlugin.API_CONFIGURATION_NAME) { - dependencies.remove(project.dependencies.gradleApi()) -} - -pluginBundle { - website = "https://github.com/Glavo/module-info-compiler" - vcsUrl = "https://github.com/Glavo/module-info-compiler.git" - tags = listOf("java", "modules", "jpms", "modularity") -} - -gradlePlugin { - plugins { - create("compileModuleInfoPlugin") { - id = "org.glavo.compile-module-info" - displayName = "Compile Module Info Plugin" - description = rootProject.description - implementationClass = "org.glavo.mic.plugin.CompileModuleInfoPlugin" - } - } -} - diff --git a/settings.gradle.kts b/settings.gradle.kts index 5efcf81..e4738b5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,3 @@ rootProject.name = "module-info-compiler" -include("gradle-plugin") \ No newline at end of file +// include("gradle-plugin") diff --git a/gradle-plugin/src/main/java/org/glavo/mic/plugin/CompileModuleInfoPlugin.java b/src/main/java/org/glavo/mic/CompileModuleInfoPlugin.java similarity index 96% rename from gradle-plugin/src/main/java/org/glavo/mic/plugin/CompileModuleInfoPlugin.java rename to src/main/java/org/glavo/mic/CompileModuleInfoPlugin.java index 8bc7d35..e24987d 100644 --- a/gradle-plugin/src/main/java/org/glavo/mic/plugin/CompileModuleInfoPlugin.java +++ b/src/main/java/org/glavo/mic/CompileModuleInfoPlugin.java @@ -1,6 +1,6 @@ -package org.glavo.mic.plugin; +package org.glavo.mic; -import org.glavo.mic.plugin.tasks.CompileModuleInfo; +import org.glavo.mic.tasks.CompileModuleInfo; import org.gradle.api.*; import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension; diff --git a/src/main/java/org/glavo/mic/ModuleInfoCompiler.java b/src/main/java/org/glavo/mic/ModuleInfoCompiler.java index d434c15..b6b5b36 100644 --- a/src/main/java/org/glavo/mic/ModuleInfoCompiler.java +++ b/src/main/java/org/glavo/mic/ModuleInfoCompiler.java @@ -83,7 +83,7 @@ public void compile(Reader source, OutputStream target) throws IOException { ModuleVisitor moduleVisitor = classWriter.visitModule(md.getNameAsString(), md.isOpen() ? Opcodes.ACC_OPEN : 0, moduleVersion); if (mainClass != null) { - moduleVisitor.visitMainClass(mainClass); + moduleVisitor.visitMainClass(mainClass.replace('.', '/')); } if (!md.getNameAsString().equals("java.base")) { diff --git a/gradle-plugin/src/main/java/org/glavo/mic/plugin/tasks/CompileModuleInfo.java b/src/main/java/org/glavo/mic/tasks/CompileModuleInfo.java similarity index 98% rename from gradle-plugin/src/main/java/org/glavo/mic/plugin/tasks/CompileModuleInfo.java rename to src/main/java/org/glavo/mic/tasks/CompileModuleInfo.java index db0d254..822b34d 100644 --- a/gradle-plugin/src/main/java/org/glavo/mic/plugin/tasks/CompileModuleInfo.java +++ b/src/main/java/org/glavo/mic/tasks/CompileModuleInfo.java @@ -1,4 +1,4 @@ -package org.glavo.mic.plugin.tasks; +package org.glavo.mic.tasks; import org.glavo.mic.ModuleInfoCompiler; import org.gradle.api.DefaultTask;