takari / takari-plugin-testing-project

Maven Plugin Testing Framework
Eclipse Public License 1.0
27 stars 19 forks source link

Error when ~/.m2/settings.xml does not exist and no custom user settings file provided #11

Closed psiroky closed 8 years ago

psiroky commented 9 years ago

When there is no default user settings file (~/.m2/settings.xml) and no custom one is specified via -s, the build will fail with.

java.lang.AssertionError: Can read user settings.xml
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at io.takari.maven.testing.TestProperties.getUserSettings(TestProperties.java:83)
    at io.takari.maven.testing.executor.MavenExecution.execute(MavenExecution.java:37)

I am hitting this with version 2.8.0. It seems the default path is saved into test.properties file even though the file does not exist.

This obivously depends on the particular machine configuration and can be easily workarounded by putting empty settings.xml file into ~./m2. However, I think it would be nice if the tooling could cope with this corner case as well.

ifedorenko commented 9 years ago

What puts userSettingsFile to test.properties? If it's takari-lifecycle, what lifecycle version do you use? What version of maven do you use?

psiroky commented 9 years ago

Thanks for a quick response!

It seems it is the takari-lifecycle-plugin, version 1.10.2. I will try with the latest 1.11.11.

This is the POM I am using: https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/kie-maven-plugin/pom.xml. Sorry, should have linked that one in the original report.

ifedorenko commented 9 years ago

Unrelated, but you probably want to use takari-maven-plugin packaging type. You'll be able to cleanup pom.xml file of your plugin, also m2e will work much better for the plugin.

psiroky commented 9 years ago

Thanks for the suggestion, I will look into that. I am still quite new to the Takari stuff.

I am using maven 3.2.3 to run the outer build and the test with 3.0.5 and 3.2.3 (forgot to add that to the previous comment).

psiroky commented 9 years ago

Result is the same when using latest takari-lifecycle-plugin version 1.11.11.

ifedorenko commented 9 years ago

I think the fix should be in takari-lifecycle. The fix is quite simple but I don't know when I be able to implement it. Somebody else may be able/willing to review a quality pull request, however ;-)

In the mean time, you should be able to add empty settings.xml in your project source tree and specify it via explicit userSettingsFile property in src\test\test.properties.

psiroky commented 9 years ago

So if I understand correctly, the takari-lifecycle should put the default settings.xml path into the test.properties only if the setting file actually exists? If you could give me few pointers as to where to look, I should be able to find some time to fix it directly in takari-lifecycle.

About the workaround -- would that work if I then specified custom settings.xml via maven arg line, E.g. mvn clean install -s <custom-file>? Would be the custom-file used instead of the default empty one?

ifedorenko commented 9 years ago

Look at TestPropertiesMojo. The fix itself should be quite straightforward, but I am not sure about unit tests... probably can skip unit tests for this one.

If you specify userSettingsFile property in src\test\test.properties, -s <custom-file> command line parameter will be ignored. Which I believe should be fine in your case since your tests appear to run without settings.xml.

psiroky commented 9 years ago

Thanks I will take a look at creating a PR with the fix.

We usually run the build without settings.xml, but when during releases we do need to add other staging repositories, so we need the ability to plug in custom settings file.