|
| 1 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 2 | +import org.gradle.jvm.tasks.Jar |
| 3 | + |
| 4 | +plugins { |
| 5 | + `java-library` |
| 6 | + `maven-publish` |
| 7 | +} |
| 8 | + |
| 9 | +repositories { |
| 10 | + mavenCentral() |
| 11 | +} |
| 12 | + |
| 13 | +val javacExports = listOf( |
| 14 | + "jdk.compiler/com.sun.tools.javac.api", |
| 15 | + "jdk.compiler/com.sun.tools.javac.code", |
| 16 | + "jdk.compiler/com.sun.tools.javac.tree", |
| 17 | + "jdk.compiler/com.sun.tools.javac.util", |
| 18 | +) |
| 19 | + |
| 20 | +dependencies { |
| 21 | + testImplementation(libs.junit.jupiter) |
| 22 | + testRuntimeOnly("org.junit.platform:junit-platform-launcher") |
| 23 | +} |
| 24 | + |
| 25 | +java { |
| 26 | + toolchain { |
| 27 | + languageVersion = JavaLanguageVersion.of(17) |
| 28 | + } |
| 29 | + withJavadocJar() |
| 30 | + withSourcesJar() |
| 31 | +} |
| 32 | + |
| 33 | +tasks.withType<JavaCompile>().configureEach { |
| 34 | + options.compilerArgs.addAll( |
| 35 | + javacExports.flatMap { export -> listOf("--add-exports", "$export=ALL-UNNAMED") }, |
| 36 | + ) |
| 37 | +} |
| 38 | + |
| 39 | +tasks.withType<Test>().configureEach { |
| 40 | + useJUnitPlatform() |
| 41 | + jvmArgs(javacExports.map { export -> "--add-exports=$export=ALL-UNNAMED" }) |
| 42 | + testLogging { |
| 43 | + exceptionFormat = TestExceptionFormat.FULL |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +tasks.named<Jar>("jar") { |
| 48 | + manifest { |
| 49 | + attributes["Automatic-Module-Name"] = "net.ikvm.javarefplugin" |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +publishing { |
| 54 | + publications { |
| 55 | + create<MavenPublication>("mavenJava") { |
| 56 | + from(components["java"]) |
| 57 | + artifactId = rootProject.name |
| 58 | + pom { |
| 59 | + name = "java-ref-plugin" |
| 60 | + description = project.description |
| 61 | + url = "https://github.com/ikvmnet/java-ref-plugin" |
| 62 | + licenses { |
| 63 | + license { |
| 64 | + name = "MIT License" |
| 65 | + url = "https://opensource.org/licenses/MIT" |
| 66 | + } |
| 67 | + } |
| 68 | + developers { |
| 69 | + developer { |
| 70 | + id = "ikvmnet" |
| 71 | + name = "IKVM" |
| 72 | + } |
| 73 | + } |
| 74 | + scm { |
| 75 | + connection = "scm:git:https://github.com/ikvmnet/java-ref-plugin.git" |
| 76 | + developerConnection = "scm:git:ssh://git@github.com/ikvmnet/java-ref-plugin.git" |
| 77 | + url = "https://github.com/ikvmnet/java-ref-plugin" |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + repositories { |
| 83 | + maven { |
| 84 | + name = "GitHubPackages" |
| 85 | + val repositoryPath = providers.environmentVariable("GITHUB_REPOSITORY") |
| 86 | + .orElse("ikvmnet/java-ref-plugin") |
| 87 | + url = uri(repositoryPath.map { "https://maven.pkg.github.com/$it" }) |
| 88 | + credentials { |
| 89 | + username = providers.gradleProperty("githubUsername") |
| 90 | + .orElse(providers.environmentVariable("GITHUB_ACTOR")) |
| 91 | + .orNull |
| 92 | + password = providers.gradleProperty("githubToken") |
| 93 | + .orElse(providers.environmentVariable("GITHUB_TOKEN")) |
| 94 | + .orNull |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | +} |
0 commit comments