[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16329120#comment-16329120 ] ASF GitHub Bot commented on MCOMPILER-320: -- dmlloyd opened a new pull request #1: [MCOMPILER-320] Introduce additionalCompilePathItems property URL: https://github.com/apache/maven-compiler-plugin/pull/1 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16329124#comment-16329124 ] David M. Lloyd commented on MCOMPILER-320: -- https://github.com/apache/maven-compiler-plugin/pull/1 > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16329312#comment-16329312 ] Robert Scholte commented on MCOMPILER-320: -- Hi David, I think it would already help if there was an example attached to better understand what you're trying to achieve (and which we can translate to an integration test). My first concern is that you will loose control over the order of the classpath. I'd prefer to see a solution where the issue is solved with dependencies, which might require a new scope. In the end a dependency is just a reference to a file, like all entries on the classpath, so I would expect there's a more elegant way to solve this. > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16329558#comment-16329558 ] David M. Lloyd commented on MCOMPILER-320: -- Thanks for the feedback. A new "compile-only" scope would definitely be good but it would not solve either of my two present immediate use cases. Case 1 is that if you build a project in Java 9, and use {{--release=8}} (i.e. {{8}}) then the sun.misc and sun.reflect packages are not included in the class path. They must be stubbed, however you absolutely do _not_ want to have the stubs appear in _any_ context other than the exact compilation, otherwise severe problems will occur: the JVM could even crash. A new scope _almost_ solves this, but not quite, because you might only want to include the stub in one execution. What if you have more than one? Which brings us to case 2. Case 2 is that currently the best way of building an MR JAR can be done by way of multiple executions. But in order to do this, the overlay executions must include, on the class path, each earlier execution's output classes. Here's an example of both cases being done at once; this is using a version of the plugin which contains my proposed patch: {code:xml} maven-compiler-plugin 3.7.1-SNAPSHOT default-compile none compile-java8 compile compile 8 ${project.build.directory} ${project.compileSourceRoots} ${project.build.outputDirectory} ${project.build.directory}/sun-misc.jar compile-java9 compile compile 9 ${project.build.directory} ${project.basedir}/src/main/java9 ${project.build.directory}/classes/META-INF/versions/9 ${project.build.outputDirectory} maven-dependency-plugin fetch-misc generate-sources get copy org.jboss:sun-misc:1.Final-SNAPSHOT ${project.build.directory} true {code} This makes use of several basic defining features of Maven: the ability to have multiple executions, the usage of maven-dependency-plugin to fetch dependencies by way of specific goals, etc. The only missing piece is the ability to add class path entries. I am enormously skeptical that a practical high-level solution to MR JARs will appear in Maven _ever_. Even if I was wrong and it would happen, I am extremely confident that it would be inadequate for any non-trivial case, and furthermore, as a maintainer of many frameworks, I contend that most any case where a framework _would_ require MR JARs would be a non-trivial case. This is due to the fact that some of the key APIs that are motivating factors in producing MR JARs - namely sun.misc.Unsafe and sun.reflect.ReflectionFactory - have to be specially handled in the way that I have done above. It is unlikely that a single compiler plugin pass, no matter how enhanced, would be able to cope with this situation, nor would it be able to cope with any other situation where different layers of the JAR would require different compiler parameters - a situation that seems inevitable to me. I don't think there is a better solution to MR JAR than the one I've worked up in this example. We could maintain our own fork of this plugin, but that would be a bit ridiculous: nothing in this proposed change opposes what I would call a rational interpretation of the spirit of Maven's design, or of the design of javac. > Allow additional class
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332145#comment-16332145 ] Robert Scholte commented on MCOMPILER-320: -- I made an integration test, all seems possible without any changes, unless I'm missing something https://github.com/apache/maven-compiler-plugin/commit/4a95b1614803158484e9114fcbdc03635e43ef0e > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332339#comment-16332339 ] David M. Lloyd commented on MCOMPILER-320: -- Your example won't quite work: * The supplementary classes must not be on the compile path for Java 9 or later as they may cause split package errors when compiling with modules - or worse yet, they may overlap a Java 9 API which is used by the Java 9 code overlay * The Java 9 layer does not seem to include the classes from the Java 8 layer; in your example this may work because the Java 9 layer doesn't use any code from the Java 8 layer but in our code, we only provide Java 9 (or 10 or 11) classes when we actually need to use a newer API or something that is specific to that version; otherwise we inherit the earlier layer * If you add more layers to your example, they in turn must depend on the classes output of each prior layer in order * The dependency infects all other executions of all other mojos - which we definitely do not want. It's better to include it in the one place we need it then deal with the heisenbug situation of excluding it from every other plugin everywhere > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332343#comment-16332343 ] Robert Scholte commented on MCOMPILER-320: -- Please extend the IT > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332416#comment-16332416 ] ASF GitHub Bot commented on MCOMPILER-320: -- dmlloyd opened a new pull request #2: [MCOMPILER-320] Show cases where failures occur URL: https://github.com/apache/maven-compiler-plugin/pull/2 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332430#comment-16332430 ] David M. Lloyd commented on MCOMPILER-320: -- https://github.com/apache/maven-compiler-plugin/pull/2 should illustrate the problem. You need Java 10 to do it "right", otherwise just change the "release" to "9" in the java 10 part and it's close enough to show the problems. Here's the first one: {noformat} [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.1-SNAPSHOT:compile (compile-java10) on project mcompiler320: Compilation failure [ERROR] /home/david/src/java/maven-compiler-plugin/src/it/MCOMPILER-320_mrjar/lib/src/main/java10/asset/MyClass3.java:[29,16] cannot find symbol [ERROR] symbol: method exampleMethod() [ERROR] location: class asset.MyClass {noformat} > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-320) Allow additional class path items to be given during compilation
[ https://issues.apache.org/jira/browse/MCOMPILER-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332977#comment-16332977 ] David M. Lloyd commented on MCOMPILER-320: -- I see that {{maven-surefire-plugin}} has a {{additionalClasspathElements}} element which does the same thing. I think I should rename the new {{maven-compiler-plugin}} attribute to have the same name; I'll update the PR accordingly. > Allow additional class path items to be given during compilation > > > Key: MCOMPILER-320 > URL: https://issues.apache.org/jira/browse/MCOMPILER-320 > Project: Maven Compiler Plugin > Issue Type: New Feature >Reporter: David M. Lloyd >Priority: Major > > At present it is very difficult to include additional class path items during > compilation that are not dependencies. But this is a very useful capability, > especially when doing partial builds, MR JARs, JDK API stubbing, including > dependency items that cannot be included in any other build phase or > execution, etc. > This enhancement and pull request are to request the addition of a > {{additionalCompilePathItems}} property in CompilerMojo or > AbstractCompilerMojo which includes additional filesystem paths in the > compilation class path. -- This message was sent by Atlassian JIRA (v7.6.3#76005)