Skip to content

Commit 3ebc966

Browse files
authored
Merge pull request #1 from ikvmnet/copilot/create-java-compiler-plugin
Target the published javac plugin at Java 8
2 parents 09f6acb + e2fc5b6 commit 3ebc966

16 files changed

Lines changed: 964 additions & 0 deletions

File tree

‎.gitattributes‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
10+
# Binary files should be left untouched
11+
*.jar binary
12+

‎.github/workflows/ci.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Java
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 17
23+
24+
- name: Set up Gradle
25+
uses: gradle/actions/setup-gradle@v4
26+
27+
- name: Build and test
28+
run: ./gradlew build

‎.github/workflows/publish.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Check out repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: temurin
23+
java-version: 17
24+
25+
- name: Set up Gradle
26+
uses: gradle/actions/setup-gradle@v4
27+
28+
- name: Publish to GitHub Packages
29+
env:
30+
GITHUB_ACTOR: ${{ github.actor }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GITHUB_REPOSITORY: ${{ github.repository }}
33+
run: ./gradlew publish

‎.gitignore‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
6+
7+
# Ignore Kotlin plugin data
8+
.kotlin

‎build.gradle.kts‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
val java8Compiler = javaToolchains.compilerFor {
21+
languageVersion = JavaLanguageVersion.of(8)
22+
}
23+
24+
dependencies {
25+
compileOnly(files(java8Compiler.map { it.metadata.installationPath.file("lib/tools.jar") }))
26+
testImplementation(libs.junit.jupiter)
27+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
28+
}
29+
30+
java {
31+
toolchain {
32+
languageVersion = JavaLanguageVersion.of(17)
33+
}
34+
withSourcesJar()
35+
}
36+
37+
tasks.named<JavaCompile>("compileJava") {
38+
javaCompiler = java8Compiler
39+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
40+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
41+
}
42+
43+
tasks.named<JavaCompile>("compileTestJava") {
44+
sourceCompatibility = JavaVersion.VERSION_17.toString()
45+
targetCompatibility = JavaVersion.VERSION_17.toString()
46+
}
47+
48+
tasks.withType<Test>().configureEach {
49+
useJUnitPlatform()
50+
jvmArgs(javacExports.map { export -> "--add-exports=$export=ALL-UNNAMED" })
51+
testLogging {
52+
exceptionFormat = TestExceptionFormat.FULL
53+
}
54+
}
55+
56+
tasks.named<Jar>("jar") {
57+
manifest {
58+
attributes["Automatic-Module-Name"] = "net.ikvm.javarefplugin"
59+
}
60+
}
61+
62+
publishing {
63+
publications {
64+
create<MavenPublication>("mavenJava") {
65+
from(components["java"])
66+
artifactId = rootProject.name
67+
pom {
68+
name = "java-ref-plugin"
69+
description = project.description.toString()
70+
url = "https://github.com/ikvmnet/java-ref-plugin"
71+
licenses {
72+
license {
73+
name = "MIT License"
74+
url = "https://opensource.org/licenses/MIT"
75+
}
76+
}
77+
developers {
78+
developer {
79+
id = "ikvmnet"
80+
name = "IKVM"
81+
}
82+
}
83+
scm {
84+
connection = "scm:git:https://github.com/ikvmnet/java-ref-plugin.git"
85+
developerConnection = "scm:git:ssh://git@github.com/ikvmnet/java-ref-plugin.git"
86+
url = "https://github.com/ikvmnet/java-ref-plugin"
87+
}
88+
}
89+
}
90+
}
91+
repositories {
92+
maven {
93+
name = "GitHubPackages"
94+
val repositoryPath = providers.environmentVariable("GITHUB_REPOSITORY")
95+
.orElse("ikvmnet/java-ref-plugin")
96+
url = uri("https://maven.pkg.github.com/${repositoryPath.get()}")
97+
credentials {
98+
username = providers.gradleProperty("githubUsername")
99+
.orElse(providers.environmentVariable("GITHUB_ACTOR"))
100+
.orNull
101+
password = providers.gradleProperty("githubToken")
102+
.orElse(providers.environmentVariable("GITHUB_TOKEN"))
103+
.orNull
104+
}
105+
}
106+
}
107+
}

‎gradle.properties‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.configuration-cache=true
2+
group=net.ikvm
3+
version=0.1.0-SNAPSHOT
4+
description=Javac plugin that rewrites concrete method bodies into NoSuchMethodError throws for reference-only API artifacts.

‎gradle/libs.versions.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[versions]
2+
junit-jupiter = "6.0.1"
3+
4+
[libraries]
5+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }

‎gradle/wrapper/gradle-wrapper.jar‎

47.3 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
4+
networkTimeout=10000
5+
retries=0
6+
retryBackOffMs=500
7+
validateDistributionUrl=true
8+
zipStoreBase=GRADLE_USER_HOME
9+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)