adoroszlai commented on code in PR #6939:
URL: https://github.com/apache/hadoop/pull/6939#discussion_r1677988021
##########
hadoop-common-project/hadoop-auth/pom.xml:
##########
@@ -272,5 +272,68 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-8</id>
+ <activation>
+ <jdk>1.8</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>enforce-java-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.8</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>x509-suppress</id>
+ <activation>
+ <jdk>[9,)</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
Review Comment:
Looks like these properties are set regardless of Java version. So they
could be moved out of the profiles.
However, we can use the profiles to set `maven.compiler.release` for Java 9+
instead of the other two properties.
Java 9 introduced new [`javac` option
`--release`](https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release),
which helps ensure compatibility with the given Java version ([blog with great
explanation](https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/)).
The goal of this change is to set this option when compiling with JDK 9+,
instead of `--source` and `--target`.
`--release` expects version without the old-style `1.` prefix (i.e. `8`
instead of `1.8`). `maven-enforcer-plugin` [added support for the
same](https://issues.apache.org/jira/browse/MENFORCER-440) in version 3.2.1, so
we also need to bump the plugin.
##########
hadoop-common-project/hadoop-auth/pom.xml:
##########
@@ -272,5 +272,68 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-8</id>
+ <activation>
+ <jdk>1.8</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>enforce-java-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.8</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>x509-suppress</id>
+ <activation>
+ <jdk>[9,)</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>--add-exports=java.base/sun.security.x509=ALL-UNNAMED
--add-exports=java.base/sun.security.util=ALL-UNNAMED</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ </configuration>
+ </plugin>
Review Comment:
Setting properties `maven.compiler.source` and `maven.compiler.target` has
the same effect as creating a `configuration` for the plugin with `source` and
`target` set. We only need one of these changes.
I'd keep the properties.
```suggestion
```
##########
hadoop-common-project/hadoop-auth/pom.xml:
##########
@@ -272,5 +272,68 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-8</id>
+ <activation>
+ <jdk>1.8</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>enforce-java-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.8</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>x509-suppress</id>
+ <activation>
+ <jdk>[9,)</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>--add-exports=java.base/sun.security.x509=ALL-UNNAMED
--add-exports=java.base/sun.security.util=ALL-UNNAMED</argLine>
Review Comment:
@pan3793 Can you please clarify "unconditionally" here? Do you mean
"regardless of Java version"? `--add-exports` and `--add-opens` do not work
with Java 8. I guess Spark does not support Java 8.
##########
hadoop-common-project/hadoop-auth/pom.xml:
##########
@@ -272,5 +272,68 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-8</id>
+ <activation>
+ <jdk>1.8</jdk>
+ </activation>
Review Comment:
Why are these profiles being added in
`hadoop-common-project/hadoop-auth/pom.xml` instead of the root POM?
1. We may need the `--add-opens` args for other tests.
2. More importantly, the compiler settings should be global.
##########
hadoop-common-project/hadoop-auth/pom.xml:
##########
@@ -272,5 +272,68 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-8</id>
+ <activation>
+ <jdk>1.8</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0</version>
Review Comment:
nit: version is not needed, defined in root POM.
```suggestion
```
##########
hadoop-common-project/hadoop-auth/pom.xml:
##########
@@ -272,5 +272,68 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-8</id>
+ <activation>
+ <jdk>1.8</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.source>${javac.version}</maven.compiler.source>
+ <maven.compiler.target>${javac.version}</maven.compiler.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>enforce-java-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.8</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
Review Comment:
Why require Java version 1.8 in a profile activated by `<jdk>1.8</jdk>`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]