maven-compiler-plugin icon indicating copy to clipboard operation
maven-compiler-plugin copied to clipboard

[MCOMPILER-423] Unable to define qualified exports to unknown modules without triggering compiler warning

Open jira-importer opened this issue 5 years ago • 1 comments

Gili opened MCOMPILER-423 and commented

Following up on a discussion with Karl Heinz Marbaise at https://stackoverflow.com/q/53670052/14731

It doesn't seem to be possible to compile the attached testcase without triggering a compiler warning.

Expected behavior: Maven compiler plugin should pass --module-source-path to avoid the compiler warning.


Affects: 3.8.1

Attachments:

jira-importer avatar Jun 29 '20 14:06 jira-importer

Gili commented

Passing the following options to the compiler plugin fixes the problem, but I am looking for a way to configure Maven to do this automatically on my behalf:  

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.8.1</version>
	<configuration>
		<compilerArgs>
			<arg>-Werror</arg>
			<arg>--module-source-path</arg>
			<arg>${project.basedir}/../*/src/main/java</arg>
			<arg>--module</arg>
			<arg>${module.name}</arg>
		</compilerArgs>
	</configuration>
</plugin>
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<version>3.1.0</version>
	<executions>
		<execution>
			<id>default-jar</id>
			<goals>
				<goal>jar</goal>
			</goals>
			<configuration>
				<!-- module-source-path causes the compiler to output into classes/${module.name} instead of just classes -->
				<classesDirectory>${project.build.outputDirectory}/${module.name}</classesDirectory>
			</configuration>
		</execution>
	</executions>
</plugin>

jira-importer avatar Jun 29 '20 14:06 jira-importer