Skip to content

Commit

Permalink
Avoid propagation of .mvn/maven.config to nested generated projects
Browse files Browse the repository at this point in the history
When generating a project and testing it, we don't want the config
coming from .mvn/maven.config to interfere, now that we are using it to
pass build arguments to the root on CI.

See quarkusio@67f7030
  • Loading branch information
gsmet committed Feb 26, 2025
1 parent 9ffe09c commit d3c2238
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public static File initEmptyProject(String name) {
}
boolean mkdirs = tc.mkdirs();

initDotMvn(tc);

Logger.getLogger(MojoTestBase.class.getName())
.log(Level.FINE, "test-classes created? %s", mkdirs);
return tc;
Expand All @@ -91,6 +93,9 @@ public static File initProject(String name) {
if (!in.isDirectory()) {
throw new RuntimeException("Cannot find directory: " + in.getAbsolutePath());
}

initDotMvn(in);

return in;
}

Expand Down Expand Up @@ -118,6 +123,9 @@ public static File initProject(String name, String output) {
boolean mkdirs = out.mkdirs();
Logger.getLogger(MojoTestBase.class.getName())
.log(Level.FINE, out.getAbsolutePath() + " created? " + mkdirs);

initDotMvn(out);

try {
org.codehaus.plexus.util.FileUtils.copyDirectoryStructure(in, out);
} catch (IOException e) {
Expand All @@ -127,6 +135,16 @@ public static File initProject(String name, String output) {
return out;
}

/**
* Initialize an empty .mvn to make sure we don't inherit from .mvn/maven.config from the root
* <p>
* .mvn/maven.config is used to pass args that might be too long for the Windows command line.
*/
private static void initDotMvn(File projectDirectory) {
File dotMvn = new File(projectDirectory, ".mvn");
dotMvn.mkdirs();
}

public static void filter(File input, Map<String, String> variables) throws IOException {
DevModeClient.filter(input, variables);
}
Expand Down

0 comments on commit d3c2238

Please sign in to comment.