-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build output must be consistent between reactor projects and dependen…
…cies (#105) The "bytecode" and "apt" tasks have been officially merged now - while these separate output types were an attempt to keep generated sources separate from bytecode, in order to have reactor projects produce equivalent contents to the contents one might expect to find in distributed jars. This patch also modifies the maven goals from permitting generated-sources/annotations source directories from being added as source directories. Some basic logic is present to try to permit this directory instead of allowing the BytecodeTask run annotation processors (see SkipAptTask), but this is incomplete and doesn't work in reactor tasks yet. Output directories are also created at the beginning of goals now to hopefully make it clear where output will be written to users while waiting for compilation to complete. Error from javac are improved, to include the filename and line number with each error, if present. Added an integration test project that includes an annotation processor in the reactor so we can confirm it can build, and a project with resources to ensure they can be found from other projects in the same reactor. Fixes #101 Fixes #14
- Loading branch information
Showing
31 changed files
with
654 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
j2cl-maven-plugin/src/it/annotation-processor-in-reactor/app/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>annotation-processor-in-reactor</groupId> | ||
<artifactId>app</artifactId> | ||
<version>1.0</version> | ||
<packaging>war</packaging> | ||
|
||
<dependencies> | ||
<!-- Annotation processor and resources to use to generate output --> | ||
<dependency> | ||
<groupId>annotation-processor-in-reactor</groupId> | ||
<artifactId>processor</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>annotation-processor-in-reactor</groupId> | ||
<artifactId>resources</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<!-- J2cl Test dependencies --> | ||
<dependency> | ||
<groupId>com.vertispan.j2cl</groupId> | ||
<artifactId>junit-annotations</artifactId> | ||
<version>@j2cl.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vertispan.j2cl</groupId> | ||
<artifactId>junit-emul</artifactId> | ||
<version>@j2cl.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vertispan.j2cl</groupId> | ||
<artifactId>junit-emul</artifactId> | ||
<version>@j2cl.version@</version> | ||
<classifier>sources</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vertispan.j2cl</groupId> | ||
<artifactId>gwttestcase-emul</artifactId> | ||
<version>@j2cl.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>build-js</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-js</id> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<compilationLevel>ADVANCED</compilationLevel> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>google-snapshots</id> | ||
<url>https://oss.sonatype.org/content/repositories/google-snapshots/</url> | ||
</repository> | ||
</repositories> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
...in/src/it/annotation-processor-in-reactor/app/src/main/java/com/example/MyAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.SOURCE) | ||
@interface MyAnnotation { | ||
String value() default ""; | ||
} |
7 changes: 7 additions & 0 deletions
7
...en-plugin/src/it/annotation-processor-in-reactor/app/src/main/java/com/example/MyApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example; | ||
|
||
public class MyApp { | ||
public static void start() { | ||
MyResources.INSTANCE.resourceInRoot(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...gin/src/it/annotation-processor-in-reactor/app/src/main/java/com/example/MyResources.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example; | ||
|
||
@MyAnnotation | ||
public interface MyResources { | ||
public static final MyResources INSTANCE = new MyResources_Impl(); | ||
|
||
@MyAnnotation("res-in-root-dir.txt") | ||
String resourceInRoot(); | ||
@MyAnnotation("com/example/res-in-package.txt") | ||
String resourceInPackage(); | ||
|
||
@MyAnnotation("res-in-java-default-package.txt") | ||
String resourceInJavaSourceRoot(); | ||
|
||
@MyAnnotation("com/example/res-in-java-nested-package.txt") | ||
String resourceInJavaPackage(); | ||
} |
1 change: 1 addition & 0 deletions
1
j2cl-maven-plugin/src/it/annotation-processor-in-reactor/app/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<web-app></web-app> |
20 changes: 20 additions & 0 deletions
20
...in/src/it/annotation-processor-in-reactor/app/src/test/java/com/example/ResourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example; | ||
|
||
import com.google.j2cl.junit.apt.J2clTestInput; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
@J2clTestInput(ResourceTest.class) | ||
public class ResourceTest { | ||
@Test | ||
public void resourceContents() { | ||
// This test verifies that the resource contents were correctly read at build time | ||
MyResources res = MyResources.INSTANCE; | ||
|
||
Assert.assertEquals("res-in-root-dir.txt", res.resourceInRoot()); | ||
Assert.assertEquals("res-in-package.txt", res.resourceInPackage()); | ||
Assert.assertEquals("res-in-java-default-package.txt", res.resourceInJavaSourceRoot()); | ||
Assert.assertEquals("res-in-java-nested-package.txt", res.resourceInJavaPackage()); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
j2cl-maven-plugin/src/it/annotation-processor-in-reactor/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>annotation-processor-in-reactor</groupId> | ||
<artifactId>annotation-processor-in-reactor</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<description> | ||
This project tests not only if an annotation processor can be in the reactor (as a dependency of | ||
the actual j2cl app), but also if the processor can correctly read files out of java and resources | ||
directories of projects and dependencies. | ||
</description> | ||
|
||
<modules> | ||
<module>processor</module> | ||
<module>resources</module> | ||
<module>app</module> | ||
</modules> | ||
|
||
<repositories> | ||
<repository> | ||
<id>google-snapshots</id> | ||
<url>https://oss.sonatype.org/content/repositories/google-snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
j2cl-maven-plugin/src/it/annotation-processor-in-reactor/processor/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>annotation-processor-in-reactor</groupId> | ||
<artifactId>annotation-processor-in-reactor</artifactId> | ||
<version>1.0</version> | ||
</parent> | ||
<artifactId>processor</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.squareup</groupId> | ||
<artifactId>javapoet</artifactId> | ||
<version>1.13.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto</groupId> | ||
<artifactId>auto-common</artifactId> | ||
<version>1.0.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<proc>none</proc> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.