Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1553804
Start reimplementing paths to use containers to wrap concerns of file…
ascopes May 15, 2022
32ca6c4
Re-organise container-groups into package/module/output-oriented
ascopes May 16, 2022
d667909
Added initial output container group implementation
ascopes May 18, 2022
3fca19c
Starting integration for new path management system
ascopes May 19, 2022
8890461
Re-order packages to be cleaner, remove v1 path API
ascopes May 21, 2022
4aaf5be
Fix most integrations with the compiler
ascopes May 21, 2022
f0c1ba0
Solved concurrent-JAR issue! Got tests working again, fixed a bunch o…
ascopes May 22, 2022
467d4c3
Remove PlatformLinkStrategy code that is no longer needed
ascopes May 23, 2022
80fbd88
Remove DEFAULT_FILE_CHARSET that is no longer used
ascopes May 23, 2022
4280da4
Add back in .addSourcePath et al
ascopes May 23, 2022
0d868aa
Fix JAR binaryName and path lookup logic
ascopes May 23, 2022
004f479
Remove irrelevant TODO around zipfs usage
ascopes May 23, 2022
74b77b0
Begin adding assertions back in
ascopes May 28, 2022
514047d
Add Junit annotation support and tidy up
ascopes May 28, 2022
50ca240
Add missing docstring
ascopes May 28, 2022
6f9dde6
Allow using @EcjCompilers and @JavacCompilers as a meta-annotation
ascopes May 28, 2022
b06d4fd
Add missing package-info.java
ascopes May 28, 2022
2b7e79e
Disable ECJ tests for modules after more investigation work.
ascopes May 28, 2022
46c819c
Update dependencies and enable dependabot
ascopes May 29, 2022
3e0ea7e
Implement diagnostic assertions, fix checkstyle hanging for a minute …
ascopes May 29, 2022
8ce8f41
Fix checkstyle issues
ascopes May 29, 2022
0cec374
Silence spurious warning by Maven JAR plugin about missing sources in…
ascopes May 29, 2022
79ce1ac
Silence module warnings we cannot fix, and enable -Werror for javac
ascopes May 29, 2022
bba0773
Add IntelliJ file templates to simplify compliance a little.
ascopes May 29, 2022
69941a2
Add more assertion types
ascopes May 29, 2022
3240e7b
Work around ECJ bug in Java 11 causing problems
ascopes May 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "ascopes"
labels:
- "enhancement"
- "housekeeping"
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
java-version: [ 11, 12, 13, 14, 15, 16, 17, 18 ]
Expand Down Expand Up @@ -73,7 +74,7 @@ jobs:
- name: Annotate test reports
if: always()
run: >-
.github/scripts/prepare-test-outputs-for-merge.sh
scripts/prepare-test-outputs-for-merge.sh
${{ matrix.java-version }}
${{ matrix.os }}

Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ build/
out/
target/

# IntelliJ
.idea/
# IntelliJ junk
*.iml
.idea/*
# Allow providing file templates for simplicity.
!.idea/fileTemplates

# VSCode
.vscode/
Expand Down
33 changes: 33 additions & 0 deletions .idea/fileTemplates/internal/AnnotationType.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/fileTemplates/internal/Class.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/fileTemplates/internal/Enum.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/fileTemplates/internal/Interface.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/fileTemplates/internal/package-info.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .mvn/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
<!--
NOTE(ascopes): modified this to also ignore extends/implements clauses in class
and interface declarations, as formatting becomes less readable if we follow the google style
here.
-->
<property name="ignorePattern"
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
value="^package.*|^import.*|a href|href|http://|https://|ftp://|\s+extends |\s+implements "/>
</module>

<module name="TreeWalker">
Expand Down
148 changes: 83 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,95 +27,113 @@ prevent future issues for any projects deciding to use it.
**This module is still under development.** Any contributions or feedback
are always welcome!

## Example
## Examples

The following is an example of using this library with JUnit Jupiter to run both javac and ECJ:
The following is an example of using this library with JUnit Jupiter to run both javac and ECJ
across a single package:

```java
class HelloWorldTest {

@Test
void i_can_compile_hello_world_with_javac() {
// Given
var sources = RamPath
.createPath("sources")
.createFile(
"org/me/test/examples/HelloWorld.java",
"package org.me.test.examples;",
"",
"public class HelloWorld {",
" public static void main(String[] args) {",
" System.out.println(\"Hello, World!\");",
" }",
"}"
)
@DisplayName("Example tests")
class ExampleTest {

@DisplayName("I can compile a Hello World application")
@EcjCompilers
@JavacCompilers
@ParameterizedTest(name = "using {0}")
void canCompileHelloWorld(Compilable<?, ?> compiler) {
var sources = createPath("src")
.createFile(
"module-info.java",
"module org.me.test.examples {",
" exports org.me.test.examples;",
"}"
"org/example/Message.java",
"""
package org.example;

import lombok.Data;
import lombok.NonNull;

@Data
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
"""
);

// When
var compilation = Compilers
.javac()
.addSourceRamPaths(sources)
.release(11)
var compilation = compiler
.addSourcePath(sources)
.compile();

// Then
assertThatCompilation(compilation).isSuccessfulWithoutWarnings();
assertThatCompilation(compilation).diagnostics().isEmpty();
assertThatCompilation(compilation).classOutput()
.file("org/me/test/examples/HelloWorld.class")
.exists()
.isNotEmptyFile();
assertThatCompilation(compilation).classOutput()
.file("module-info.class")
.exists()
.isNotEmptyFile();
assertThatCompilation(compilation)
.isSuccessfulWithoutWarnings();
}
}
```

Likewise, the following shows an example of compiling a multi-module style application with JPMS
support, running the Lombok annotation processor over the input. This assumes that the Lombok
JAR is already on the classpath for the JUnit test runner.

```java
@DisplayName("Example tests")
class ExampleTest {

@Test
void i_can_compile_hello_world_with_ecj() {
@DisplayName("I can compile a module that is using Lombok")
@JavacCompilers(modules = true)
@ParameterizedTest(name = "using {0}")
void canCompileModuleUsingLombok(Compilable<?, ?> compiler) {
// Given
var sources = RamPath
.createPath("sources")
var sources = createPath("hello.world")
.createFile(
"org/example/Message.java",
"""
package org.example;

import lombok.Data;
import lombok.NonNull;

@Data
public class Message {
@NonNull
private final String content;
}
"""
)
.createFile(
"org/me/test/examples/HelloWorld.java",
"package org.me.test.examples;",
"",
"public class HelloWorld {",
" public static void main(String[] args) {",
" System.out.println(\"Hello, World!\");",
" }",
"}"
"org/example/Main.java",
"""
package org.example;

public class Main {
public static void main(String[] args) {
for (var arg : args) {
var message = new Message(arg);
System.out.println(arg);
}
}
}
"""
)
.createFile(
"module-info.java",
"module org.me.test.examples {",
" exports org.me.test.examples;",
"}"
"""
module hello.world {
requires java.base;
requires static lombok;
}
"""
);

// When
var compilation = Compilers
.ecj()
.addSourceRamPaths(sources)
.release(11)
var compilation = compiler
.addModuleSourcePath("hello.world", sources)
.compile();

// Then
assertThatCompilation(compilation).isSuccessfulWithoutWarnings();
assertThatCompilation(compilation).diagnostics().isEmpty();
assertThatCompilation(compilation).classOutput()
.file("org/me/test/examples/HelloWorld.class")
.exists()
.isNotEmptyFile();
assertThatCompilation(compilation).classOutput()
.file("module-info.class")
.exists()
.isNotEmptyFile();
assertThatCompilation(compilation)
.isSuccessfulWithoutWarnings();
}
}
```
Expand Down
Loading