jgitver / jgitver-maven-plugin

maven core extension to automatically define versions using jgitver & git tags
https://jgitver.github.io/
Other
159 stars 41 forks source link

Intellij + jgitver + multi-module reports problem "detection of jgitver old setting mechanism" #70

Closed vromero closed 6 years ago

vromero commented 6 years ago

Issue

version: 1.1.5

usage context:

Problem description:

When using a multi-module maven project in the latest IntelliJ (older versions also tested) that uses jgitver-maven-plugin an error is reported in the Maven tab: "detection of jgitver old setting mechanism". This generates a number of problems for the user as most of the project data cannot be inferred.

screenshot from 2017-12-11 09-39-12

The project does work correctly using the command line.

I have created a sample project in order to reproduce it, just follow these steps:

McFoggy commented 6 years ago

I already saw such kind of errors, I'll try to understand how jgitver is launched when used inside IDEA, not sure it is launched as maven core extension as expected.

vromero commented 6 years ago

FWIW it seems to work fine on non-multi-module projects

McFoggy commented 6 years ago

On the other hand, I have no problems in IDEA for project: https://github.com/McFoggy/GuardEE

vromero commented 6 years ago

On the other hand, I have no problems in IDEA for project: https://github.com/McFoggy/GuardEE

Indeed, its a single module project. The problem seems to occur only in multi-module.

McFoggy commented 6 years ago

@vromero what do you mean? it is a multi-module wit 2 sub modules: impl & tck-runner

vromero commented 6 years ago

You are right, my bad. 'm trying to download it and check I'll let you know. My co-workers also had experiences where it does work when the project was already imported into idea before jgirver is added.

fededonna commented 6 years ago

Hi @McFoggy I work with @vromero your example multimodule project works because you use mvnw. After removing mvnw and importing the project from the scratch I get the same problem:

image

vromero commented 6 years ago

Funny enough, vanilla guardee doesn't work for me with no changes: screenshot from 2017-12-11 14-09-21

McFoggy commented 6 years ago

I need to dig/debug the loading mechanism of IDEA. The error states that the plugin is active but not as a core extension.

One possibility could be perhaps just to log the fact instead of throwing a build failure. I would prefer in such case to be able to detect the usage from within an IDE loading (badly) project metadatas than from normal usage where I would like to keep the error.

McFoggy commented 6 years ago

As stated in commit, you need a manual action in IDEA to skip jgitver execution

image

then the import should work

image

Notice that in this case for Intellij IDEA the project version will be the one in the pom (0 probably).

vromero commented 6 years ago

Manual intervention feels like a deal breaker for us. I tried to automate but of course didn't work as jgitver get initiated before the profiles (as it should be):

  <profiles>
        <profile>
            <id>idea-only</id>
            <activation>
                <property>
                    <name>idea.version</name>
                </property>
            </activation>

            <properties>
                <jgitver.skip>true</jgitver.skip>
            </properties>
        </profile>
  </profiles>

Sadly I'm not an expert in extensions, any idea if there is any kind of expression language or profiling that we can leverage there to automatically disable execution of jgitver if idea.version is present?

McFoggy commented 6 years ago

Manual intervention feels like a deal breaker for us.

Where do you see a manual intervention? It is just a configuration of your IDEA installation.

image

And if really your developers cannot even modify a setting in their IDEA because you control all by automation, I am sure this settings is part of some IDE config file.

fededonna commented 6 years ago

I really appreciate your help but having to change vm options in the IDE seems to manual intervention to me. Have you found the root cause of this issue while idea compiles with his own maven? Maybe there is a env var that we can set from outside the IDE.

vromero commented 6 years ago

Where do you see a manual intervention? It is just a configuration of your IDEA installation.

Hi @McFoggy, please don't missunderstand me, I'm grateful for the help and the software (that is great BTW).

I think we are on the same page on this, the manual intervention is the IDE manual configuration. This requires documentation that developers shall read (and very likely won't read).

Back in the day there was the idea maven plugin, I checked this morning and not its retired so AFAIK there is no way from maven to suggest a VM option to intellij but of course I might be wrong.

I think we can agree that automation is the ideal state to be pursued. Shall we perhaps raise this issue to intellij?

McFoggy commented 6 years ago

The problem is that IDEA or Eclipse or Netbeans, during loading of projects DO NOT exactly execute the normal build system, maven in our case. They use their own modified versions of those build systems in the best case to extract metadatas from the project descriptors, the poms here. In the worst case their just try to parse the descriptors manually. As jgitver is a core maven extension, ie something really deeply integrated in maven loading mechanism (and not that much used) perhaps IDEA loading does not trigger it in the same way maven is doing.

The parameter I proposed you to use has to be set only ONCE and interfere only with the loading mechanism not the builds. I think it is really something acceptable.

If it is not enough for you then please open an issue on IDEA side.

vromero commented 6 years ago

Sure thing, thanks

vromero commented 6 years ago

@McFoggy apologies for commenting in an closed issue. I gave it another try using your approach with 1.1.6 and the aforementioned -Djgitver.skip=true with no luck.

I'm doing the following:

Am I missing something?

33897863-e58364d0-df66-11e7-9024-e635b65c2c97

McFoggy commented 6 years ago

I again see it also.

McFoggy commented 6 years ago

@vromero Please re-test with 1.1.7 once it is visible in central (or look directly in sonatype repo if in hurry).

vromero commented 6 years ago

Will do a bit later today. We are talking to the idea guys here, just in case you want to chime in.

McFoggy commented 6 years ago

@vromero as I stated before, the test to skip jgitver was made against maven session userproperties ; in IDEA it looks like this is not set and that's why I added a test in latest commit against System properties that were filled. Let's see what they will say.

fededonna commented 6 years ago

@McFoggy we spoke with intellij guys and they found the main problem. Everything is explained in the issue that @vromero talked about before. We tested the latest version of the EAP which includes the fix and it works like a charm. If you like you can remove the flag that you added because of this issue. Thanks for your help and time.

P.S.: version can be found here: https://confluence.jetbrains.com/display/IDEADEV/IDEA+2017.3+EAP

Tested version:

IntelliJ IDEA 2017.3.4 EAP (Ultimate Edition)
Build #IU-173.4548.2, built on January 16, 2018
Licensed to MuleSoft / Federico Donnarumma
Subscription is active until April 20, 2018
JRE: 1.8.0_152-release-1024-b11 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.2
McFoggy commented 6 years ago

Thx I'll test it ASAP.

Hope you will be now able to work correctly with jgtiver inside IDEA as you expect.

McFoggy commented 6 years ago

@fededonna @vromero unfortunately I still have issues with this version if I remove the
-Djgitver.skip=true flag

image

I still find that jgitver does load correctly with the embedded maven version of IDEA.

2018-01-18 11:20:33,053 [ 200527]   INFO -      #org.jetbrains.idea.maven - org.apache.maven.MavenExecutionException: detection of jgitver old setting mechanism 
java.lang.RuntimeException: org.apache.maven.MavenExecutionException: detection of jgitver old setting mechanism
    at fr.brouillard.oss.jgitver.JGitverUtils.failAsOldMechanism(JGitverUtils.java:216)
    at fr.brouillard.oss.jgitver.JGitverExtension.afterProjectsRead(JGitverExtension.java:124)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.loadExtensions(Maven3ServerEmbedderImpl.java:810)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.access$400(Maven3ServerEmbedderImpl.java:121)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl$3.run(Maven3ServerEmbedderImpl.java:685)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.executeWithMavenSession(Maven3ServerEmbedderImpl.java:633)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.doResolveProject(Maven3ServerEmbedderImpl.java:652)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.resolveProject(Maven3ServerEmbedderImpl.java:586)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: jgitver must now use maven core extensions only
    ... 25 more
fededonna commented 6 years ago

@McFoggy @vromero according to the idea guys the version with the fix has not been released yet. Here is the issue to keep track. It will be RC on the 23rd. https://youtrack.jetbrains.com/issue/IDEA-184983

McFoggy commented 6 years ago

Ok but I have tested the exact same version as you mentionned (the current EAP one) and it was not correct during my tests.

fededonna commented 6 years ago

Yes, my mistake. I still had the flag. As they say in the last comment the version will be 173.4548.5 that is coming out as an RC on the 23rd of January.

fededonna commented 6 years ago

@McFoggy @vromero 2017.3.4 RC is out. I tested it several times and jgitver is working. https://confluence.jetbrains.com/display/IDEADEV/IDEA+2017.3+EAP

McFoggy commented 6 years ago

I'll give it a try. Thx for info.

fededonna commented 6 years ago

image IntelliJIDEA released with the fix for this issue. https://youtrack.jetbrains.com/issue/IDEA-184983

Thanks @McFoggy and @vromero for your help.