Skip to content

Commit 47d96d7

Browse files
committed
Implement support for ECJ
Rejig RAM directory naming, add ability to dump tree view of workspaces Port across ECJ support This is still provisional and an active work in progress, please track eclipse-jdt/eclipse.jdt.core#958 for this work. Enable tests for eclipse Run against CI build of ECJ temporarily Address ShellCheck warnings Fix ECJ injection script Add ability to adjust log level in POM Apply 2025 license headers to new ECJ classes Use eclipse snapshot repositories
1 parent c52dfcf commit 47d96d7

File tree

36 files changed

+1565
-19
lines changed

36 files changed

+1565
-19
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ jobs:
7272
env:
7373
cache-name: maven-cache
7474
with:
75-
path:
76-
~/.m2
75+
path: ~/.m2
7776
key: build-${{ env.cache-name }}
7877

7978
- name: Compile and run tests

java-compiler-testing/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
<artifactId>assertj-core</artifactId>
5454
</dependency>
5555

56+
<dependency>
57+
<groupId>org.eclipse.jdt</groupId>
58+
<artifactId>ecj</artifactId>
59+
</dependency>
60+
5661
<dependency>
5762
<groupId>org.jspecify</groupId>
5863
<artifactId>jspecify</artifactId>

java-compiler-testing/src/it/avaje-http/src/test/java/io/github/ascopes/jct/acceptancetests/avajehttp/AvajeHttpTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation;
1919

2020
import io.github.ascopes.jct.compilers.JctCompiler;
21+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2122
import io.github.ascopes.jct.junit.JavacCompilerTest;
2223
import io.github.ascopes.jct.workspaces.Workspaces;
2324
import org.junit.jupiter.api.DisplayName;
@@ -26,6 +27,7 @@
2627
class AvajeHttpTest {
2728

2829
@DisplayName("HTTP client code gets generated as expected")
30+
@EcjCompilerTest(minVersion = 11)
2931
@JavacCompilerTest(minVersion = 11)
3032
void httpClientCodeGetsGeneratedAsExpected(JctCompiler compiler) {
3133
// Given
@@ -40,7 +42,7 @@ void httpClientCodeGetsGeneratedAsExpected(JctCompiler compiler) {
4042

4143
// Then
4244
assertThatCompilation(compilation)
43-
.isSuccessfulWithoutWarnings()
45+
.isSuccessful()
4446
.classOutputPackages()
4547
.allFilesExist(
4648
"org/example/httpclient/GeneratedHttpComponent.class",

java-compiler-testing/src/it/avaje-inject/src/test/java/io/github/ascopes/jct/acceptancetests/avajeinject/AvajeInjectTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation;
1919

2020
import io.github.ascopes.jct.compilers.JctCompiler;
21+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2122
import io.github.ascopes.jct.junit.JavacCompilerTest;
2223
import io.github.ascopes.jct.workspaces.PathStrategy;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
@@ -27,6 +28,7 @@
2728
class AvajeInjectTest {
2829

2930
@DisplayName("Dependency injection code gets generated as expected")
31+
@EcjCompilerTest(minVersion = 11)
3032
@JavacCompilerTest(minVersion = 11)
3133
void dependencyInjectionCodeGetsGeneratedAsExpected(JctCompiler compiler) {
3234
// Given
@@ -41,7 +43,7 @@ void dependencyInjectionCodeGetsGeneratedAsExpected(JctCompiler compiler) {
4143

4244
// Then
4345
assertThatCompilation(compilation)
44-
.isSuccessfulWithoutWarnings()
46+
.isSuccessful()
4547
.classOutputPackages()
4648
.allFilesExist(
4749
"org/example/CoffeeMaker.class",

java-compiler-testing/src/it/avaje-jsonb/src/test/java/io/github/ascopes/jct/acceptancetests/avajejsonb/AvajeJsonbTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.avaje.jsonb.Jsonb;
2222
import io.avaje.jsonb.generator.Processor;
2323
import io.github.ascopes.jct.compilers.JctCompiler;
24+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2425
import io.github.ascopes.jct.junit.JavacCompilerTest;
2526
import io.github.ascopes.jct.workspaces.Workspaces;
2627
import java.time.Instant;
@@ -30,6 +31,7 @@
3031
@DisplayName("Avaje Jsonb acceptance tests")
3132
class AvajeJsonbTest {
3233
@DisplayName("JSON handling logic is generated as expected")
34+
@EcjCompilerTest(minVersion = 11)
3335
@JavacCompilerTest(minVersion = 11)
3436
void jsonHandlingLogicIsGeneratedAsExpected(JctCompiler compiler) throws Throwable {
3537
// Given
@@ -46,7 +48,7 @@ void jsonHandlingLogicIsGeneratedAsExpected(JctCompiler compiler) throws Throwab
4648

4749
// Then
4850
assertThatCompilation(compilation)
49-
.isSuccessfulWithoutWarnings();
51+
.isSuccessful();
5052

5153
var userClass = compilation
5254
.getClassOutputs()

java-compiler-testing/src/it/dagger/src/test/java/io/github/ascopes/jct/acceptancetests/dagger/DaggerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation;
1919

2020
import io.github.ascopes.jct.compilers.JctCompiler;
21+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2122
import io.github.ascopes.jct.junit.JavacCompilerTest;
2223
import io.github.ascopes.jct.workspaces.Workspaces;
2324
import org.junit.jupiter.api.DisplayName;
2425

2526
@DisplayName("Dagger acceptance tests")
2627
class DaggerTest {
2728
@DisplayName("Dagger DI runs as expected in the annotation processing phase")
29+
@EcjCompilerTest
2830
@JavacCompilerTest
2931
void daggerDiRunsAsExpectedInTheAnnotationProcessingPhase(JctCompiler compiler) {
3032
try (var workspace = Workspaces.newWorkspace()) {
@@ -38,7 +40,7 @@ void daggerDiRunsAsExpectedInTheAnnotationProcessingPhase(JctCompiler compiler)
3840
var compilation = compiler.compile(workspace);
3941

4042
// Then
41-
assertThatCompilation(compilation).isSuccessfulWithoutWarnings();
43+
assertThatCompilation(compilation).isSuccessful();
4244

4345
assertThatCompilation(compilation)
4446
.sourceOutputPackages()

java-compiler-testing/src/it/dogfood/src/test/java/io/github/ascopes/jct/acceptancetests/dogfood/JctDogfoodTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static io.github.ascopes.jct.assertions.JctAssertions.assertThat;
1919

2020
import io.github.ascopes.jct.compilers.JctCompiler;
21+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2122
import io.github.ascopes.jct.junit.JavacCompilerTest;
2223
import io.github.ascopes.jct.workspaces.Workspaces;
2324
import java.io.IOException;
@@ -52,6 +53,7 @@ class JctDogfoodTest {
5253
.resolve("classes");
5354

5455
@DisplayName("JCT can compile itself as a legacy module source")
56+
@EcjCompilerTest(minVersion = 17, configurers = JctCompilationConfigurer.class)
5557
@JavacCompilerTest(minVersion = 17, configurers = JctCompilationConfigurer.class)
5658
void jctCanCompileItselfAsLegacyModule(JctCompiler compiler) throws IOException {
5759
// Given

java-compiler-testing/src/it/google-auto-factory/src/test/java/io/github/ascopes/jct/acceptancetests/autofactory/AutoFactoryTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.assertj.core.api.SoftAssertions.assertSoftly;
2020

2121
import io.github.ascopes.jct.compilers.JctCompiler;
22+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2223
import io.github.ascopes.jct.junit.JavacCompilerTest;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
2425
import java.time.Instant;
@@ -28,6 +29,7 @@
2829
class AutoFactoryTest {
2930

3031
@DisplayName("The AutoFactory class is created as expected")
32+
@EcjCompilerTest
3133
@JavacCompilerTest
3234
void autoFactoryClassIsCreatedAsExpected(JctCompiler compiler) throws Throwable {
3335
try (var workspace = Workspaces.newWorkspace()) {
@@ -42,7 +44,7 @@ void autoFactoryClassIsCreatedAsExpected(JctCompiler compiler) throws Throwable
4244

4345
// Then
4446
assertThatCompilation(compilation)
45-
.isSuccessfulWithoutWarnings()
47+
.isSuccessful()
4648
.classOutputPackages()
4749
.fileExists("org", "example", "UserFactory.class")
4850
.isNotEmptyFile();

java-compiler-testing/src/it/google-auto-service/src/test/java/io/github/ascopes/jct/acceptancetests/autoservice/AutoServiceTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation;
1919

2020
import io.github.ascopes.jct.compilers.JctCompiler;
21+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2122
import io.github.ascopes.jct.junit.JavacCompilerTest;
2223
import io.github.ascopes.jct.workspaces.Workspaces;
2324
import org.junit.jupiter.api.DisplayName;
@@ -26,6 +27,7 @@
2627
class AutoServiceTest {
2728

2829
@DisplayName("The AutoService descriptor is created as expected")
30+
@EcjCompilerTest
2931
@JavacCompilerTest
3032
void autoServiceDescriptorIsCreatedAsExpected(JctCompiler compiler) {
3133
try (var workspace = Workspaces.newWorkspace()) {
@@ -40,7 +42,7 @@ void autoServiceDescriptorIsCreatedAsExpected(JctCompiler compiler) {
4042

4143
// Then
4244
assertThatCompilation(compilation)
43-
.isSuccessfulWithoutWarnings()
45+
.isSuccessful()
4446
.classOutputPackages()
4547
.fileExists("META-INF", "services", "org.example.SomeInterface")
4648
.hasContent("org.example.SomeImpl");

java-compiler-testing/src/it/google-auto-value/src/test/java/io/github/ascopes/jct/acceptancetests/autovalue/AutoValueTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.assertj.core.api.SoftAssertions.assertSoftly;
2020

2121
import io.github.ascopes.jct.compilers.JctCompiler;
22+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2223
import io.github.ascopes.jct.junit.JavacCompilerTest;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
2425
import java.time.Instant;
@@ -29,6 +30,7 @@
2930
class AutoValueTest {
3031

3132
@DisplayName("The AutoValue implementation class is created as expected")
33+
@EcjCompilerTest
3234
@JavacCompilerTest
3335
void autoValueImplementationClassIsCreatedAsExpected(JctCompiler compiler) throws Throwable {
3436
try (var workspace = Workspaces.newWorkspace()) {
@@ -43,7 +45,7 @@ void autoValueImplementationClassIsCreatedAsExpected(JctCompiler compiler) throw
4345

4446
// Then
4547
assertThatCompilation(compilation)
46-
.isSuccessfulWithoutWarnings()
48+
.isSuccessful()
4749
.classOutputPackages()
4850
.allFilesExist(
4951
"org/example/AutoValue_User.class",

java-compiler-testing/src/it/immutables/src/test/java/io/github/ascopes/jct/acceptancetests/immutables/ImmutablesTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.assertj.core.api.SoftAssertions.assertSoftly;
2020

2121
import io.github.ascopes.jct.compilers.JctCompiler;
22+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2223
import io.github.ascopes.jct.junit.JavacCompilerTest;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
2425
import java.util.stream.Stream;
@@ -36,6 +37,7 @@
3637
class ImmutablesTest {
3738

3839
@DisplayName("Immutables @Value produces the expected class")
40+
@EcjCompilerTest
3941
@JavacCompilerTest
4042
void immutablesValueProducesTheExpectedClass(JctCompiler compiler) throws Throwable {
4143
try (var workspace = Workspaces.newWorkspace()) {
@@ -68,6 +70,7 @@ void immutablesValueProducesTheExpectedClass(JctCompiler compiler) throws Throwa
6870
}
6971

7072
@DisplayName("Immutables @Value produces the expected class for modules")
73+
@EcjCompilerTest(minVersion = 9)
7174
@JavacCompilerTest(minVersion = 9)
7275
void immutablesValueProducesTheExpectedClassForModules(JctCompiler compiler) throws Throwable {
7376
try (var workspace = Workspaces.newWorkspace()) {

java-compiler-testing/src/it/mapstruct/src/test/java/io/github/ascopes/jct/acceptancetests/mapstruct/MapStructTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.assertj.core.api.SoftAssertions.assertSoftly;
2020

2121
import io.github.ascopes.jct.compilers.JctCompiler;
22+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2223
import io.github.ascopes.jct.junit.JavacCompilerTest;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
2425
import java.util.stream.Stream;
@@ -28,6 +29,7 @@
2829
class MapStructTest {
2930

3031
@DisplayName("MapStruct generates expected mapping code")
32+
@EcjCompilerTest
3133
@JavacCompilerTest
3234
void mapStructGeneratesExpectedMappingCode(JctCompiler compiler) throws Throwable {
3335
try (final var workspace = Workspaces.newWorkspace()) {
@@ -40,7 +42,7 @@ void mapStructGeneratesExpectedMappingCode(JctCompiler compiler) throws Throwabl
4042
final var compilation = compiler.compile(workspace);
4143

4244
// Then
43-
assertThatCompilation(compilation).isSuccessfulWithoutWarnings();
45+
assertThatCompilation(compilation).isSuccessful();
4446

4547
final var classLoader = compilation.getFileManager()
4648
.getClassLoader(StandardLocation.CLASS_OUTPUT);
@@ -68,6 +70,7 @@ void mapStructGeneratesExpectedMappingCode(JctCompiler compiler) throws Throwabl
6870
}
6971

7072
@DisplayName("MapStruct generates expected mapping code for modules")
73+
@EcjCompilerTest(minVersion = 9)
7174
@JavacCompilerTest(minVersion = 9)
7275
void mapStructGeneratesExpectedMappingCodeForModules(JctCompiler compiler) throws Throwable {
7376
try (final var workspace = Workspaces.newWorkspace()) {
@@ -80,7 +83,7 @@ void mapStructGeneratesExpectedMappingCodeForModules(JctCompiler compiler) throw
8083
final var compilation = compiler.compile(workspace);
8184

8285
// Then
83-
assertThatCompilation(compilation).isSuccessfulWithoutWarnings();
86+
assertThatCompilation(compilation).isSuccessful();
8487

8588
final var classLoader = compilation.getFileManager()
8689
.getClassLoader(StandardLocation.CLASS_OUTPUT);

java-compiler-testing/src/it/micronaut/src/test/java/io/github/ascopes/jct/acceptancetests/micronaut/MicronautIntegrationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static io.github.ascopes.jct.assertions.JctAssertions.assertThatCompilation;
1919

2020
import io.github.ascopes.jct.compilers.JctCompiler;
21+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2122
import io.github.ascopes.jct.junit.JavacCompilerTest;
2223
import io.github.ascopes.jct.workspaces.Workspaces;
2324
import org.junit.jupiter.api.DisplayName;
@@ -26,6 +27,7 @@
2627
class MicronautIntegrationTest {
2728

2829
@DisplayName("Micronaut generates the expected code")
30+
@EcjCompilerTest(configurers = MicronautConfigurer.class)
2931
@JavacCompilerTest(configurers = MicronautConfigurer.class)
3032
void micronautGeneratesTheExpectedCode(JctCompiler compiler) {
3133
try (var workspace = Workspaces.newWorkspace()) {

java-compiler-testing/src/it/serviceloader-jpms/src/test/java/io/github/ascopes/jct/acceptancetests/serviceloaderjpms/testing/ServiceProcessorJpmsTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.github.ascopes.jct.acceptancetests.serviceloaderjpms.ServiceProcessor;
2121
import io.github.ascopes.jct.compilers.JctCompiler;
22+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2223
import io.github.ascopes.jct.junit.JavacCompilerTest;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
2425
import org.junit.jupiter.api.DisplayName;
@@ -27,6 +28,7 @@
2728
class ServiceProcessorJpmsTest {
2829

2930
@DisplayName("Expected files get created when the processor is run")
31+
@EcjCompilerTest(minVersion = 9)
3032
@JavacCompilerTest(minVersion = 9)
3133
void expectedFilesGetCreated(JctCompiler compiler) {
3234
try (var workspace = Workspaces.newWorkspace()) {
@@ -41,7 +43,7 @@ void expectedFilesGetCreated(JctCompiler compiler) {
4143
.compile(workspace);
4244

4345
assertThatCompilation(compilation)
44-
.isSuccessfulWithoutWarnings()
46+
.isSuccessful()
4547
.classOutputPackages()
4648
.fileExists("META-INF", "services", "org.example.InsultProvider")
4749
.hasContent("org.example.MeanInsultProviderImpl");
@@ -62,7 +64,7 @@ void expectedFilesGetCreatedInMultiModuleRoots(JctCompiler compiler) {
6264
.compile(workspace);
6365

6466
assertThatCompilation(compilation)
65-
.isSuccessfulWithoutWarnings()
67+
.isSuccessful()
6668
.classOutputModules().moduleExists("org.example")
6769
.fileExists("META-INF", "services", "org.example.InsultProvider")
6870
.hasContent("org.example.MeanInsultProviderImpl");

java-compiler-testing/src/it/serviceloader/src/test/java/io/github/ascopes/jct/acceptancetests/serviceloader/testing/ServiceProcessorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.github.ascopes.jct.acceptancetests.serviceloader.ServiceProcessor;
2121
import io.github.ascopes.jct.compilers.JctCompiler;
22+
import io.github.ascopes.jct.junit.EcjCompilerTest;
2223
import io.github.ascopes.jct.junit.JavacCompilerTest;
2324
import io.github.ascopes.jct.workspaces.Workspaces;
2425
import org.junit.jupiter.api.DisplayName;
@@ -27,6 +28,7 @@
2728
class ServiceProcessorTest {
2829

2930
@DisplayName("Expected files get created when the processor is run")
31+
@EcjCompilerTest
3032
@JavacCompilerTest
3133
void expectedFilesGetCreated(JctCompiler compiler) {
3234
try (var workspace = Workspaces.newWorkspace()) {
@@ -41,7 +43,7 @@ void expectedFilesGetCreated(JctCompiler compiler) {
4143
.compile(workspace);
4244

4345
assertThatCompilation(compilation)
44-
.isSuccessfulWithoutWarnings()
46+
.isSuccessful()
4547
.classOutputPackages()
4648
.fileExists("META-INF", "services", "org.example.InsultProvider")
4749
.hasContent("org.example.MeanInsultProviderImpl");

0 commit comments

Comments
 (0)