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
Support for passing a settings from my test resources #233
Comments
Could you please make a full working example and described more in detail what exactly the purpose of such setup is? |
For our use case we would like to be able to test access to our artifacts from our private repository with different user flavours. This means that all we need to have a e.g. settings.xml looks like <?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>my-mirror</id>
<username>${MAVEN_USER}</username>
<password>${MAVEN_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>my-artifacts</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>my-mirror</id>
<name>my-maven-all</name>
<url>${MY_MAVEN_REPO_URL}</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>central</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>my-artifacts</activeProfile>
</activeProfiles>
</settings>
a test case then looks like: @ExtendWith(MavenITExtension.class)
@MavenSourceProject("custom")
@MavenSettings("settings-test.xml")
class CustomAccessIT {
@MavenTest
@MavenGoal({ "clean", "verify" })
@SystemProperty(value = "MAVEN_USER", content = "base-reader")
void baseReader(MavenExecutionResult result) {
assertThat(result).isFailure();
assertThat(result)
.out()
.error()
.anySatisfy(error -> {
Assertions.assertThat(error)
.contains(
"403 Forbidden"
);
});
}
@MavenTest
@MavenGoal({ "clean", "verify" })
@SystemProperty(value = "MAVEN_USER", content = "custom-reader")
void customReader(MavenExecutionResult result) {
assertThat(result).isFailure();
}
} Does this help explain the use case I am trying to achieve? |
Providing a |
@faltfe You should already have a |
@khmarbaise what you are saying is right and things should work like that. However, the use case that I am trying to achieve is not the one that @faltfe explained. As I've mentioned earlier, I am more than happy to work on a contribution that is going to provide this functionality if you are ready to accept something like this. |
@filiphr Yes I know. I'm already thinking about a design to solve that... |
That's great to hear @khmarbaise. We already have something on our side using the examples I provided in #233 (comment) (the use of The alternative would be to support using resources in |
I tried to use a custom settings.xml via @MavenTest
@MavenGoal("\${project.groupId}:\${project.artifactId}:\${project.version}:update")
@MavenOption("--settings settings.xml")
fun jgitProviderIsSet_scmConfigIsSet(result: MavenExecutionResult) {
} but it produces the following error: // output of mvn-stderr.log
Unable to parse command line options: Unrecognized option: --settings settings.xml
// output of mvn-argument.log
/home/sparsick/.sdkman/candidates/maven/current/bin/mv
-Dmaven.repo.local=/home/sparsick/dev/workspace/dependency-update-maven-plugin/target/maven-it/io/github/georgberky/maven/plugins/depsupdate/UpdateMojoJGit2IT/jgitProviderIsSet_scmConfigIsSet/.m2/repository
--settings settings.xml
io.github.georgberky.maven.plugins.depsupdate:dependency-update-maven-plugin:0.9.0-SNAPSHOT:update Used Maven version is 3.8.6 The whole sample can be found here. Maybe this sample helps you. |
If you like to use that you should use it like this:
Or you can use:
|
Thanks, that works for me. It wasn't clear for me reading the docs, that |
That means the docs needs to be improved... |
I would like to be able to use a custom settings file available in my resources. I found
MavenCLIOptions.SETTINGS
. However, from what I could deduce, this does not allow me to point to a file in my test resources.I would like to be able to reference a file from my test resources and use that.
We have made this work for us by adding a new
@MavenSettings
annotation. However, I think that it would be better if we can expand@MavenOption
with a new methodresource
that would be able to resolve the full path to a test resource and use it in the tests. We are ready to work on this contribution to the project in case you are interested in this functionality.The text was updated successfully, but these errors were encountered: