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

Java 9 support #69

Closed
vietj opened this issue Sep 4, 2017 · 18 comments
Closed

Java 9 support #69

vietj opened this issue Sep 4, 2017 · 18 comments
Assignees

Comments

@vietj
Copy link

vietj commented Sep 4, 2017

No description provided.

@bsorrentino bsorrentino self-assigned this Sep 4, 2017
@bsorrentino
Copy link
Owner

Take a look to #64

@vietj
Copy link
Author

vietj commented Sep 4, 2017

will have a try and report :-)

@bsorrentino
Copy link
Owner

bsorrentino commented Sep 4, 2017

Thanks for support ;-)

@beikov
Copy link
Contributor

beikov commented Sep 7, 2017

Forking as needed to specify custom compiler options seems to work, but the options aren't passed properly yet. See #70 for a fix

bsorrentino added a commit that referenced this issue Sep 7, 2017
@beikov
Copy link
Contributor

beikov commented Sep 7, 2017

It should work now, but I haven't been able to get javac(build 9+181) to do the right thing yet. Investigating right now..

@bsorrentino bsorrentino reopened this Sep 7, 2017
@bsorrentino
Copy link
Owner

bsorrentino commented Sep 7, 2017

hug! .. I've just now released 3.3.2 with your pull

@beikov
Copy link
Contributor

beikov commented Sep 7, 2017

Well, according to the Javac documentation, it should already be working.. I guess they maybe introduced another regression or I am simply not seeing the problem...

@bsorrentino
Copy link
Owner

bsorrentino commented Sep 7, 2017

Really your fix has been to bypass the option.startsWith("-A") check to add custom compiler option (javacConf.addCompilerCustomArgument(option, "")).

Do you think that this could have affect the processor ?

The -A prefix is requested by javac specification

@beikov
Copy link
Contributor

beikov commented Sep 7, 2017

This should be safe. I also managed to get the processing work with JDK9 but now I think I'm facing a different problem(need to set addCompileSourceRoots for compilation to work). This issue can be closed I guess. I am going to investigate the new issue I have and open a new issue if necessary. To use a processor with JDK9 you need a configuration like

<plugin>
	<groupId>org.bsc.maven</groupId>
	<artifactId>maven-processor-plugin</artifactId>
	<executions>
		<execution>
			<id>process</id>
			<goals>
				<goal>process</goal>
			</goals>
			<phase>generate-sources</phase>
			<configuration>
				<fork>true</fork>
				<!-- Not sure why I need this flag to be set -->
				<addCompileSourceRoots>true</addCompileSourceRoots>
				<compilerArguments>--add-modules=java.se.ee -J--add-modules=java.se.ee</compilerArguments>
				<!-- source output directory -->
				<outputDirectory>${project.build.directory}/metamodel</outputDirectory>
				<processors>
					<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
				</processors>
			</configuration>
		</execution>
	</executions>
	<dependencies>
		<!-- Metamodel -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-jpamodelgen</artifactId>
			<version>1.3.0.Final</version>
		</dependency>
	</dependencies>
</plugin>

@bsorrentino
Copy link
Owner

thanks again for contribution

@plevart
Copy link

plevart commented Nov 20, 2017

Hi, I'm trying to run the plugin with JDK 9 as proposed above, but it gives me the following error:

[INFO] --- maven-processor-plugin:3.3.2:process (process) @ tt-server ---
...
...
[DEBUG] Source directory: /home/peter/work/git/thinktime/tt-server/target/metamodel added
[DEBUG] processing source directory [/home/peter/work/git/thinktime/tt-server/target/metamodel]
[DEBUG] processing source directory [/home/peter/work/git/thinktime/tt-server/src/main/java]
[DEBUG] Adding compiler arg: --add-modules=java.se.ee
[DEBUG] Adding compiler arg: -J--add-modules=java.se.ee
[DEBUG] javac option: -cp
[DEBUG] javac option: ......
[DEBUG] javac option: -sourcepath
[DEBUG] javac option: /home/peter/work/git/thinktime/tt-server/src/main/java:/home/peter/work/git/thinktime/tt-server/target/metamodel
[DEBUG] javac option: -proc:only
[DEBUG] javac option: --add-modules=java.se.ee
[DEBUG] javac option: -J--add-modules=java.se.ee
[DEBUG] javac option: -processor
[DEBUG] javac option: org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[DEBUG] javac option: -d
[DEBUG] javac option: /home/peter/work/git/thinktime/tt-server/target/classes
[DEBUG] javac option: -s
[DEBUG] javac option: /home/peter/work/git/thinktime/tt-server/target/metamodel
[DEBUG] PROCESSOR COMPILER FORKED!
warning: [options] bootstrap class path not set in conjunction with -source 1.7
javac: option --add-modules not allowed with target 1.7

I'm not adding any -source and/or -target options. Where does javac get -source 1.7 - target 1.7 ?

@bsorrentino
Copy link
Owner

the plugin use the following strategy:

if exists project property maven.processor.target use it
else if exists project property maven.compiler.target use it
else use 1.7

@plevart
Copy link

plevart commented Nov 20, 2017

Thanks. I found out that specifying <compilerArguments>-source 9 -target 9</compilerArguments> also overrides default 1.7 (perhaps because javac takes the later options and ignores the earlier). But I can not specify <compilerArguments>-release 9</compilerArguments> or maybe <compilerArguments>-release 8</compilerArguments> when compiling with JDK 9, because -release option can not be combined with default -source / -target given by plugin. There's no way to instruct the plugin to leave-out default -source / -target options, is it? Would it make sense for plugin to do that if maven.processor.target was defined to be an empty string?

@bsorrentino
Copy link
Owner

I guess that the simplest solution is to set in the project properties

<properties>
    <maven.compiler.source>1.9</maven.compiler.source>
    <maven.compiler.target>1.9</maven.compiler.target>
</properties>

as explained here

let me know if it works ... I never dealt with option -release until now

@plevart
Copy link

plevart commented Nov 20, 2017

When I set -source 8 / -target 8 on JDK 9, I don't get the same effect as when I set -release 8, because -release 8 also instructs javac to compile with Java 8 APIs only (like specifying --bootclasspath $JDK8_HOME/rt.jar with JDK 8 javac). This is important to be able to run with java 8. I want to compile with JDK 9 because I create java modules for most maven modules. Only a few maven modules become Java 8 compatible jars for consuming in other projects...

@plevart
Copy link

plevart commented Nov 20, 2017

maven-compiler-plugin 3.7.0 also supports <release>xxx</release> configuration element, but I don't know which property (if any) this sets. (maybe maven.compiler.release?). If this is true, you could detect that and pass -release option to javac instead of -source / -target. You could even have your own maven.processor.release option. What do you think?

@bsorrentino
Copy link
Owner

bsorrentino commented Nov 20, 2017

ok this is a new implementation, at now it is not supported

please cloud create a new issue in order that I can arrange its implementation?

note

Meanwhile can you try disabling fork compilation? <fork>false</fork>

@bsorrentino
Copy link
Owner

bsorrentino commented Nov 28, 2017

Released version 3.3.3-SNAPSHOT with new <release> configuration

@plevart please, test it and let me know if works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants