Skip to content
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

Maven Update Project wipes out Run Configuration #1872

Open
SiKing opened this issue Oct 9, 2024 · 5 comments
Open

Maven Update Project wipes out Run Configuration #1872

SiKing opened this issue Oct 9, 2024 · 5 comments

Comments

@SiKing
Copy link

SiKing commented Oct 9, 2024

  1. Start with any Maven project. I used simple mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart.
  2. Open the project in Eclipse.
  3. Select the test and Run As > JUnit Test.
  4. The previous step will have created a Run Configuration. Open this Configuration: Run > Run Configurations.
  5. Under the Environment tab create an environment variable. Anything will do: this=that.
  6. Apply and Close. Go back a verify the environment variable still exists!
  7. Back in the Package Explorer, right click on the project > Maven > Update Project. Leave all the default checkboxes and click OK. The project is cleaned and rebuilt.
  8. Go back to the Run Configuration and check the environment variable. It is gone!
  9. I often use VM Arguments, under Arguments tab. These get wiped as well.

If you save the run configuration to disk first, it still gets wiped.

I tried all this with a TestNG run configuration, and this problem does not happen in this case.

This started happening after an update a few months back? So I decided to completely reinstall the latest and greatest:

  • Version: 2024-09 (4.33.0)
  • Build id: 20240905-0614

It is still happening there.

@treilhes
Copy link
Contributor

treilhes commented Oct 13, 2024

Hello @SiKing,

The only issue i see here is that the testng configuration isn't updated.
https://github.com/eclipse-m2e/m2e-core/blob/master/RELEASE_NOTES.md#262

As a workaround you can disable it in the meantime by launching Eclipse with the JVM system property
-Dm2e.process.test.configuration=false.

Another less absolute workaround would be to exclude your tests from surefire/failsafe


<configuration>
  <excludes>
    <exclude>**/MyExcludedTest1.java</exclude>
    <exclude>**/MyExcludedTest2.java</exclude>
  </excludes>
</configuration>

@SiKing
Copy link
Author

SiKing commented Oct 14, 2024

My issue is that using Maven Update Project wipes my environment settings (and some others) from the Run Configuration. I am sure this started happening only a few months ago. Is this a new feature?

The m2e.process.test.configuration=false setting does what I need.

@treilhes
Copy link
Contributor

treilhes commented Oct 16, 2024

Yes it is a new feature in 2.6.2

Surefire/Failsafe plugin configuration propagated to Junit/TestNG launch configuration
The following arguments are supported:
<argLine>,
<environmentVariables>,
<systemPropertyVariables>,
<workingDirectory>,
<enableAssertions>,

Configuration is propagated on unit test launch configuration creation and also when executing maven > update project

@SiKing
Copy link
Author

SiKing commented Oct 16, 2024

Seems strange for Maven plugin to modify non-Maven files - the run configuration.

In our case, environment variables is how we pass passwords into our code. For obvious reasons, we do not want these in the Surefire configuration.

@treilhes
Copy link
Contributor

For a maven plugin yes but for m2e no
It is one of the goal of m2e to propagate maven configuration into eclipse to have the same behaviour between cli and eclipse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants