Skip to content

Commit

Permalink
2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed May 1, 2022
1 parent e3a85b5 commit 089129b
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 80 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ buildscript {
Then you can create a task that compiles `module-info.java` like this:

```kotlin
val compileModuleInfo = tasks.create<org.glavo.mic.plugin.tasks.CompileModuleInfo>("compileModuleInfo") {
val compileModuleInfo = tasks.create<org.glavo.mic.org.glavo.mic.tasks.CompileModuleInfo>("compileModuleInfo") {
sourceFile.set(file("src/main/module-info.java"))
targetFile.set(buildDir.resolve("classes/java/module-info/module-info.class"))

Expand Down
103 changes: 61 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Javadoc>().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<Javadoc>().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"

Expand All @@ -72,18 +72,22 @@ tasks.jar {
}
}

loadMavenPublishProperties()

configure<PublishingExtension> {
publications {
create<MavenPublication>("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)
Expand Down Expand Up @@ -134,8 +138,23 @@ nexusPublishing {
}
}

tasks.withType<GenerateModuleMetadata> {
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() {
Expand Down
32 changes: 0 additions & 32 deletions gradle-plugin/build.gradle.kts

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = "module-info-compiler"

include("gradle-plugin")
// include("gradle-plugin")
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/glavo/mic/ModuleInfoCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 089129b

Please sign in to comment.