[maven] Update startegy for resolving the root basesdir. Resolves
@@ -36,8 +36,12 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Properties;
+import static org.jreleaser.util.StringUtils.isNotBlank;
+
/**
* @author Andres Almiray
* @since 0.1.0
@@ -64,6 +68,9 @@ abstract class AbstractJReleaserMojo extends AbstractMojo {
@Parameter(defaultValue = "${session}", required = true)
private MavenSession session;
+ @Parameter(defaultValue = "${maven.multiModuleProjectDirectory}")
+ private String multiModuleProjectDirectory;
+
protected JReleaserLogger getLogger() throws MojoExecutionException {
return new JReleaserLoggerAdapter(createTracer(), getLog());
}
@@ -94,7 +101,7 @@ abstract class AbstractJReleaserMojo extends AbstractMojo {
getLogger(),
getMode(),
convertModel(),
- project.getBasedir().toPath(),
+ resolveBasedir(),
outputDirectory.toPath(),
dryrun);
} catch (JReleaserException e) {
@@ -105,4 +112,13 @@ abstract class AbstractJReleaserMojo extends AbstractMojo {
protected JReleaserContext.Mode getMode() {
return JReleaserContext.Mode.FULL;
}
+
+ private Path resolveBasedir() {
+ if (isNotBlank(multiModuleProjectDirectory)) {
+ return Paths.get(multiModuleProjectDirectory.trim());
+ } else if (isNotBlank(session.getExecutionRootDirectory())) {
+ return Paths.get(session.getExecutionRootDirectory().trim());
+ }
+ return project.getBasedir().toPath();
+ }
}
