-
Notifications
You must be signed in to change notification settings - Fork 116
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
Deferred properties in surefire argLine cause problems in 2.6.2 #1824
Comments
Same here :) I have this settings in my surefire-plugin:
And this jacoco-maven-plugin:
This properties:
And now when I want to run a junit-test in eclipse (Alt+Shift+X, T) ... then the launcher for test have this vm arguments:
And the run itself crash with
Until yet I think that was working because the surefire argLine was not injected by m2e. Or? But even if the new way is to inject this all the time, that would be fine for me, but then I need a way to override somehow the dynamic part of '@{jacoco.surefireArgLine}' which works only in a normal maven build. |
That's right. It looks like a regression from adding this feature in #1672. As a workaround you can disable it in the meantime by launching Eclipse with the JVM system property m2e-core/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/UnitTestSupport.java Lines 61 to 62 in fc65987
|
Hello @reckart, @ahoehma, @HannesWell @HannesWell : i don't know if you remember but my first version of #1672 was executing a list of plugins provided inside a custom property in order to generate variables created by those plugins. This sub feature was removed and it was the right choice because m2e already have this feature available. I won't be able to provide a sample conf for @reckart case as i don't know from which plugin argLineExtra comes from but So we need to flag this plugin as needed for the configuration phase by customizing the plugin execution with
@ahoehma can you try to add this lifecycle configuration into you pom.xml
and replace @ by $ into argLine replace On my side it worked, what about you @ahoehma ? |
@treilhes in my case, the value doesn't come from a plugin at all. It comes from a property manually set in the properties section of the POM. |
@reckart So can you try replacing @{argLineExtra} by ${argLineExtra}, i think it will just work in this case |
@treilhes maybe - but when I run this normally via the CLI, the deferred property is also properly resolved when a |
Because m2e is not a CLI invocation ... a deferred property makes no sense given that this is evaluated at random times (e.g. when a project is updated) maybe when you create the launch config or ... So this looks like waiting for bad things to happen. So basically in such case one needs to (re) evaluate it every time you run the JUnit, something that is not that trivial as it sounds. |
I still don't get it. If you go through all the trouble of resolving deferred properties against dynamically set properties values for plugins like jacoco, why not resolve them also against regular properties? |
@reckart variable with leading @ isn't a core maven feature but some kind of workaround used by failsafe/surefire plugins to load dynamicaly set variables during the build as maven replace variable leading with a $ during pom loading (so before any execution). In your case, i think using @ is unneeded as your variable is a constant set in standard maven properties element Your point is still valid for dynamic variable and i was thinking running @ahoehma case will successfully run in eclipse configuration but fail using cli but i did launch some test project and it runs successfully in eclipse and in cli with variable starting with $. I'm a bit confused now, maybe some fix in failsafe/surefire was done removing the need for @ |
"deferred properties" are not supported at all.... see @treilhes comment(s). |
@reckart : can you confirm your use case works (or not) in eclipse and in cli using $ ? |
Ok, got it. I can probably replace the properties I have with the However, when using JaCoCo, this will not work. If I would replace the |
That's what i was expecting also but contrary to my assumption it worked with ${jacoco.argLine} |
@treilhes For me, when I use Just for good measure, I also tried with Maven 4.0.0-beta-4 - but does also not work. Assuming |
It's not as easy as you think, nothing was specificaly done to resolve variables, they just already were when accessing the argLine property. Can you share a simplified version of your failing project as mine seems to work well ? |
Thank you, at least I can run again unit tests from eclipse with this ini setting - after I prematuraly updated my m2e plugin. I think this is the solution for most eclipse users until plugin is fixed in newer release. |
@treilhes sure - built you a new project from scratch to demonstrate. With
With
|
PR done #1827 |
Hi guys, for me the whole argLine is not really relevant inside eclipse. More specific the "jacoco.argLine" I don't really need when I run tests inside eclipse ... because for that I'm using "EclEmma" :) For me it would be fine if I can define "somehwere"
|
I usually have JaCoCo configured in an optional profile that I activate using So IMHO the same should work in Eclipse. Assuming you do not configure the I believe additional mechanism to ignore That said, for people who always run JaCoCo during CLI builds and have not set up an empty |
Surefire/failsafe does not ignore unset property @{x} and fail so it seems logic for m2e to do the same in order to have the same behaviour in eclipse than in cli (which is by the way the initial requirement of this issue) |
hi, for my eclipse Version: 2024-09 (4.33.0) - M2E 2.6.2.20240828-1954 none of the mentioned workarounds works. I've put into my eclipse.ini. Also changed: I've verified the system property on about dialog an is set to false. |
Did you Maven -> Update project configuration...? If not, try - it should regenerate the run line. |
Realy a bad idea as long as you are not resolving the expressions as on cli. |
My Problem was that the run-configurations where not cleaned up. I've updated the project config multiple times. But the old @{surefireArgLine} where still present in the run-configs of the unit-tests. Looks like the update feature is one-way. |
I also stumbled over this. Maybe the new feature could simply be automatically be disabled if the argLine contains "@{"? |
https://maven.apache.org/surefire/maven-surefire-plugin/faq.html#late-property-evaluation |
Looks like the new support for
argLine
causes trouble. If one uses a deferred property in the argline like, this ends up unresolved in the JUnit run configuration.E.g.
will create an unrunnable test run configuration that fails with
The text was updated successfully, but these errors were encountered: