Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry picked the fix for the bad packaging back to the main branch #602

Merged
merged 1 commit into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
104 changes: 86 additions & 18 deletions andhow-annotation-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,91 @@
<artifactId>compile-testing</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!--
-proc:none turns off annotation processors so that the
AndHowCompileProcessor does not attempt to process the
AndHow module itself.
-->
<compilerArgument>
-proc:none
</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>DisableAnnotationProcOnJDK8</id>
<activation>
<jdk>[1.8,1.9)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<!--
proc:none turns off annotation processors so AndHowCompileProcessor
does not attempt to process itself.
-->
<arg>-proc:none</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>SomeJDK8s</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
<jdk>[1.8,1.9)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
<profile>
<id>java9AndBeyond</id>
<!--
Its not possible to build a JRE 1.8 compatible jar file using JDK9+ bc of the need to
use the '-add-modules' feature of JDK9. When '-add-modules' is used, javac refuses to
compile to a version earlier than 1.9. Thus, until 1.8 support is dumped by AndHow,
distributed releases and snapshots need to be done w/ JDK 1.8.
-->
<activation>
<jdk>[1.9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<!--
Include the compile libs (tools.jar) for the annotation
processor to compile against.
-->
<arg>--add-modules=jdk.compiler</arg>
<!--
proc:none turns off annotation processors so AndHowCompileProcessor
does not attempt to process itself.
-->
<arg>-proc:none</arg>
</compilerArgs>
<!-- without forking compilation happens in the
same process, so no arguments are applied -->
<fork>true</fork>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically moved this profile section from the parent pom, where it applied to all modules, to just this pom. The annotation processor has special requirements for compilation:

  • It needs tools.jar (JDK8) or --add-modules=jdk.compiler (JDK9+) to compile.
  • It also needs to turn off annotation processing with the proc:none compile flag, so that the compiler doesn't attempt to have the annotation processor its compiling process the annotations in the code its compiling.

The tools.jar dependency of JDK8 caused issues b/c w/ the prior setup (declared in the parent pom), the andhow module inherited the dependency. Thus, it ended up as a dependency in the main distributed artifact's pom file, forcing projects using andhow to provide it. Tools.jar is not available via Maven repos, so this caused other projects to fail unless they were on linux w/ JDK 8.


</project>
14 changes: 0 additions & 14 deletions andhow-core/src/main/resources/logback.xml

This file was deleted.

19 changes: 17 additions & 2 deletions andhow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>andhow</artifactId>
<packaging>jar</packaging>

<dependencies>
<!--
Note that added dependencies will cause them to be included in the bundled
Expand All @@ -33,7 +33,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -47,6 +47,21 @@
<include>org.yarnandtail:andhow-annotation-processor</include>
</includes>
</artifactSet>
<filters>
<!-- Prevent dup MANIFEST file warning -->
<filter>
<artifact>org.yarnandtail:andhow-core</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
<filter>
<artifact>org.yarnandtail:andhow-annotation-processor</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
<createSourcesJar>true</createSourcesJar>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
</configuration>
Expand Down
52 changes: 2 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<module>andhow-testing/andhow-annotation-processor-test-harness</module>
<module>andhow-shared-test-utils</module>
<module>andhow-junit5-extensions</module>
<module>andhow-test-stubs</module>
<module>andhow-test-stubs</module>
</modules>

<repositories>
Expand Down Expand Up @@ -351,6 +351,7 @@
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<skipLocalStaging>true</skipLocalStaging>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a new issue - It turns out that if the last module is skipped for nexus deploy and nexus is in 'defer' mode (it waits to see if the entire build was successful before uploading artifacts), nexus forgets to go back and do the rest of the uploads.

Its a bug, but apparently they don't plan to fix it:
https://issues.sonatype.org/browse/NEXUS-9138
(Thats me complaining in the last comment on that ticket)

<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
Expand Down Expand Up @@ -425,54 +426,5 @@
</plugins>
</build>
</profile>
<profile>
<id>SomeJDK8s</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
<profile>
<id>java9AndBeyond</id>
<!--
Its not possible to build a JRE 1.8 compatable jar file using JDK9
because of the need to use the '-add-modules' feature of JDK9.
Currently the use of jdk9 is blocked by the enforcer plugin, above.
For the 0.5.0 release, the JRE8 will be left behind and only this
profile will be active.
-->
<activation>
<jdk>[1.9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>--add-modules=jdk.compiler</arg>
</compilerArgs>
<!-- without forking compilation happens in the
same process, so no arguments are applied -->
<fork>true</fork>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>