Skip to content

Commit

Permalink
Fix failures when no user settings file available
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Stastny committed Apr 1, 2021
1 parent 34b4e7b commit d052ee5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
28 changes: 26 additions & 2 deletions archetypes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<artifactId>maven-archetype-plugin</artifactId>
<configuration>
<localRepositoryPath>${session.request.localRepositoryPath.path}</localRepositoryPath>
<settingsFile>${session.request.userSettingsFile.path}</settingsFile>
</configuration>
</plugin>
</plugins>
Expand All @@ -33,7 +32,9 @@
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!productized</name>
</property>
</activation>
<modules>
<module>kogito-springboot-archetype</module>
Expand All @@ -52,6 +53,29 @@
<module>kogito-quarkus-dm-archetype</module>
</modules>
</profile>
<profile>
<!--
This profile serves at optionally passing settingsFile property to archetype::integration-test goal.
Reason is that the ${session.request.userSettingsFile.path} property defaults to ~/.m2/settings.xml even
if that file does not actually exist. Tests were in such case failing.
-->
<id>set-settings-when-provided</id>
<activation>
<file><exists>${session.request.userSettingsFile.path}</exists></file>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
<configuration>
<settingsFile>${session.request.userSettingsFile.path}</settingsFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ private List<String> getProvidedMavenProperties() {
additionalArguments.add(String.format("-D%s=%s", PROPERTY_MAVEN_REPO_LOCAL, MAVEN_REPO_LOCAL));
}
if (MAVEN_SETTINGS != null) {
additionalArguments.add(String.format("-s %s", MAVEN_SETTINGS));
/* Invoker would fail if the received settings.xml file did not exist.
* That can happen when ${session.request.userSettingsFile.path} is passed as value for maven.settings
* property from the pom.xml and at the same time user does not have settings.xml in ~/.m2/ nor they provided
* specific settings.xml using -s argument.
*/
if (new File(MAVEN_SETTINGS).exists()) {
additionalArguments.add(String.format("-s %s", MAVEN_SETTINGS));
}
}
return additionalArguments;
}
Expand Down

0 comments on commit d052ee5

Please sign in to comment.