From issues-return-135053-archive-asf-public=cust-asf.ponee.io@maven.apache.org Thu Jul 19 22:24:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E956018067E for ; Thu, 19 Jul 2018 22:24:04 +0200 (CEST) Received: (qmail 29241 invoked by uid 500); 19 Jul 2018 20:24:03 -0000 Mailing-List: contact issues-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list issues@maven.apache.org Received: (qmail 29076 invoked by uid 99); 19 Jul 2018 20:24:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jul 2018 20:24:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6A890C1815 for ; Thu, 19 Jul 2018 20:24:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.5 X-Spam-Level: X-Spam-Status: No, score=-109.5 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 0UqJO4qgrptM for ; Thu, 19 Jul 2018 20:24:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id A08F55F3B4 for ; Thu, 19 Jul 2018 20:24:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 3883BE0D27 for ; Thu, 19 Jul 2018 20:24:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id E1F7F27140 for ; Thu, 19 Jul 2018 20:24:00 +0000 (UTC) Date: Thu, 19 Jul 2018 20:24:00 +0000 (UTC) From: "foo bar (JIRA)" To: issues@maven.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (MCOMPILER-348) Can't make test-scoped dependencies work with Java 9 modules MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MCOMPILER-348?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1= 6549751#comment-16549751 ]=20 foo bar edited comment on MCOMPILER-348 at 7/19/18 8:23 PM: ------------------------------------------------------------ Ho ho, if you're right this is going to be an interesting issue to investig= ate for me. I'm very much a Java lover so if the problem comes from that I'= m going to feel a need to signal this to the higher powers or understand wh= at I can't do.How confident are you that this is a javac bug? Maybe the con= fusion comes from "unnamed module" vs "automatic modules", but I need to re= ad up on that. Also the reason I want to be able to use these test-scoped dependencies so = much is that that is required for my usual pattern for implementing a modul= ar "DDD application" or "DDD mini-framework" as an application programmer. Good idea contacting the Jigsaw mailing list. I do read Java mailing lists = from time to time, including the Jigsaw one. But I'm going to investigate a= nd make a dichotomy/minimization branch on my side before doing that.I will= probably ask you for some more pointers after I do a bit of investigation = if that's ok for you. =C2=A0 *edit*: I do use surefire/failsafe 2.22.0 (and Java 10.0.2, so the latest). I pushe= d a commit into branch {{REPRODUCE_JAVAC_EXPORTS_WARNING}} to show that. For me it doesn't change anything whether I say source/target or release. S= ame for running with Java 9 or 10 (that's only a point for "release 9" of c= ourse). =C2=A0On the other hand, if i say "'release 9" I get: {code:java} [WARNING] /G:/projets/wires/wires/wires/wires-core/src/test/java/fr/cla/wir= es/core/MavenVsJavaModulesReproduceTest.java:[9,54] class fr.cla.wires.supp= ort.oo.ddd.AbstractValueObjectTest in module=C2=A0 is not exported [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plug= in:3.7.0:testCompile (default-testCompile) on project wires-core: Compilati= on failure [ERROR] /G:/projets/wires/wires/wires/wires-core/src/test/java/fr/cla/wires= /core/MavenVsJavaModulesReproduceTest.java: warnings found and -Werror spec= ified {code} Whereas if i say "'release 10" I get: {code:java} [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plug= in:3.7.0:testCompile (default-testCompile) on project wires-support: Execut= ion default-testCompile of goal org.apache.maven.plugins:maven-compiler-plu= gin:3.7.0:testCompile failed.: IllegalArgumentException {code} =C2=A0 was (Author: vandekeizer): Ho ho, if you're right this is going to be an interesting issue to investig= ate for me. I'm very much a Java lover so if the problem comes from that I'= m going to feel a need to signal this to the higher powers or understand wh= at I can't do.How confident are you that this is a javac bug? Maybe the con= fusion comes from "unnamed module" vs "automatic modules", but I need to re= ad up on that. Also the reason I want to be able to use these test-scoped dependencies so = much is that that is required for my usual pattern for implementing a modul= ar "DDD application" or "DDD mini-framework" as an application programmer. Good idea contacting the Jigsaw mailing list. I do read Java mailing lists = from time to time, including the Jigsaw one. But I'm going to investigate a= nd make a dichotomy/minimization branch on my side before doing that.I will= probably ask you for some more pointers after I do a bit of investigation = if that's ok for you. =C2=A0 *edit*: I do use surefire/failsafe 2.22.0 (and Java 10.0.2, so the latest). I pushe= d a commit into branch {{REPRODUCE_JAVAC_EXPORTS_WARNING}} to show that. =C2=A0 For me it doesn't change anything whether I say source/target or release. S= ame for running with Java 9 or 10 (that's only a point for "release 9" of c= ourse). =C2=A0On the other hand, if i say "'release 9" I get: {code:java} [WARNING] /G:/projets/wires/wires/wires/wires-core/src/test/java/fr/cla/wir= es/core/MavenVsJavaModulesReproduceTest.java:[9,54] class fr.cla.wires.supp= ort.oo.ddd.AbstractValueObjectTest in module=C2=A0 is not exported [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plug= in:3.7.0:testCompile (default-testCompile) on project wires-core: Compilati= on failure [ERROR] /G:/projets/wires/wires/wires/wires-core/src/test/java/fr/cla/wires= /core/MavenVsJavaModulesReproduceTest.java: warnings found and -Werror spec= ified {code} Whereas if i say "'release 10" I get: {code:java} [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plug= in:3.7.0:testCompile (default-testCompile) on project wires-support: Execut= ion default-testCompile of goal org.apache.maven.plugins:maven-compiler-plu= gin:3.7.0:testCompile failed.: IllegalArgumentException {code} =C2=A0 > Can't make test-scoped dependencies work with Java 9 modules > ------------------------------------------------------------ > > Key: MCOMPILER-348 > URL: https://issues.apache.org/jira/browse/MCOMPILER-348 > Project: Maven Compiler Plugin > Issue Type: Bug > Affects Versions: 3.7.0 > Environment: $ mvn -version > Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T= 20:33:14+02:00) > Maven home: G:\software\apache-maven-3.5.4-bin\apache-maven-3.5.4 > Java version: 9.0.4, vendor: Oracle Corporation, runtime: C:\Program File= s\Java\jdk-9.0.4 > Default locale: fr_FR, platform encoding: Cp1252 > OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows" > Reporter: foo bar > Priority: Major > Labels: Java9, jigsaw, scope, test > Attachments: MCOMPILER-348-reproduce.7z, mvn-X-clean-install-outp= ut.txt > > > h1. In short > With Java 9 if I declare both the test-scoped dependency and the Java 9 m= odules the test doesn't compile anymore (mvn clean install output): > {code:java} > [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-pl= ugin:3.7.0:testCompile (default-testCompile) on project clientmod: Compilat= ion failure: Compilation failure: > [ERROR] /G:/projets/wires/wires/wires/clientmod/src/test/java/qux/Derived= Test.java:[3,11] package api does not exist > [ERROR] /G:/projets/wires/wires/wires/clientmod/src/test/java/qux/Derived= Test.java:[11,13] cannot find symbol > [ERROR] symbol: class Base > [ERROR] location: class qux.DerivedTest > [ERROR] -> [Help 1] > {code} > *That same test {{DerivedTest}} compiles and runs just fine in IntelliJ!*= So it's probably worth it to look at the different flags that Maven passes= to javac and java compared to IJ?=20 > h1. Explanation of the 2 modules, and what fails > I have a java 9 maven project with 2 modules: {{apimod}} and {{clientmod}= }. Module {{clientmod}} depends on module {{apimod}} (those modules are bot= h Maven modules and Java 9 modules). > Also, i want module {{clientmod}} to be able to reuse not only production= code from {{apimod}}, *but also test code*. This is a common pattern, that= I used many times with Java 8. With Java 9 (it's the same with Java 10) it= also works fine, as long as i don't declare module-info.java (that is, as = long as I don't run with the module system). > But as soon as I do, enabling the test dependency seems to disable the pr= oduction dependency: {{api.Base}} (an {{src/main}} class of module {{apimod= }}) is no longer visible from {{qux.DerivedTest}} (an {{src/test}} class of= module {{clientmod}}). The test doesn't compile anymore. (_Note that every= class is in a different package to eliminate split packages as a cause of = the problem_) > This is with: Java 9.0.4 (it's the same with Java 10), Maven 3.5.3, maven= -compiler-plugin 3.7.0 > =C2=A0 > h1. A project to reproduce the issue > h2. The code > I "dichotomized" the issue with a failing test in a branch: > {code:java} > git clone https://github.com/vandekeiser/wires.git > git checkout MCOMPILER_ISSUE2 > mvn clean install{code} > -> BUILD FAIL (compilation error in the test of {{clientmod}}) > h2. The Maven test-scoped dependency > I want module {{clientmod}} to be able to reuse not only production code = from {{apimod}} but also test code. With Maven you do it like that ({{clien= tmod/pom.xml}}): > {code:java} > > =C2=A0=C2=A0=C2=A0 fr.cla > =C2=A0=C2=A0=C2=A0 apimod > =C2=A0=C2=A0=C2=A0 ${project.version} > =C2=A0=C2=A0=C2=A0 tests > =C2=A0=C2=A0=C2=A0 test > > {code} > h2. The Java 9 modules > {code:java} > module apimod { > =C2=A0=C2=A0=C2=A0 exports api; > } > module clientmod { > =C2=A0=C2=A0=C2=A0 requires apimod; > } > {code} > h2. The failure when trying to enable both module systems > With Java 9 if I declare both the test-scoped dependency and the Java 9 m= odules the test doesn't compile anymore ({{mvn clean install}} output): > {code:java} > [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-pl= ugin:3.7.0:testCompile (default-testCompile) on project clientmod: Compilat= ion failure: Compilation failure: > [ERROR] /G:/projets/wires/wires/wires/clientmod/src/test/java/qux/Derived= Test.java:[3,11] package api does not exist > [ERROR] /G:/projets/wires/wires/wires/clientmod/src/test/java/qux/Derived= Test.java:[11,13] cannot find symbol > [ERROR] symbol: class Base > [ERROR] location: class qux.DerivedTest > [ERROR] -> [Help 1] > {code} > h1. My analysis so far > h2. It works if i remove the test-scope dependency > If i comment the test-dependency, {{mvn clean install}} passes: > {code:java} > //import baz.BaseTest; > DerivedTest /*extends BaseTest*/ > {code} > {code:java} > > > > > > > > {code} > =C2=A0 > h2. Trying to pass explicit module flags to the JVM > After asking here: [https://stackoverflow.com/questions/50122838/cant-mak= e-maven-test-scoped-dependencies-work-with-java-9-nor-10-modules] > I tried the following flags to move {{apimod-1.0-SNAPSHOT-tests.jar}} fro= m {{--module-path-}} to {{-patch-module clientmod}}, it compiles but then s= urefire fails so it must not be right either (anyway passing all those flag= s is fragile): > {code:java} >