if (!props.containsKey("rootdir"))
{
props.put("rootdir", rootdir);
}
InvocationRequest request = new DefaultInvocationRequest();
if (!StringUtils.isEmpty(target.goals))
{
List<String> goals = Arrays.asList(StringUtils.split(target.goals, ", "));
targetCmdMessage.append(" "+StringUtils.join( goals.iterator(), " " ));
request.setGoals(goals);
}
if (!StringUtils.isEmpty(target.profiles))
{
List<String> profiles = Arrays.asList(StringUtils.split(target.profiles, ", "));
targetCmdMessage.append(" "+StringUtils.join( profiles.iterator(), " " ));
request.setProfiles(profiles);
}
request.setProperties(props);
request.setInteractive( false );
request.setShowErrors(getLog().isErrorEnabled());
request.setDebug(getLog().isDebugEnabled());
request.setOffline(settings.isOffline());
if (settings.getLocalRepository() != null)
{
request.setLocalRepositoryDirectory(new File(settings.getLocalRepository()));
}
String mavenOpts = props.getProperty("jetspeed.mvn.mavenOpts", null);
if (StringUtils.isEmpty(mavenOpts) && !StringUtils.isEmpty(target.mavenOpts))
{
mavenOpts = target.mavenOpts;
}
if (StringUtils.isEmpty(mavenOpts) && !StringUtils.isEmpty(this.mavenOpts))
{
mavenOpts = this.mavenOpts;
}
if (!StringUtils.isEmpty(mavenOpts))
{
request.setMavenOpts(mavenOpts);
}
request.setBaseDirectory( targetPom.getParentFile() );
if (target.name != null)
{
targetPom = buildInterpolatedFile( targetPom, targetPom.getParentFile(), targetPomName+".interpolated", filter);
}
request.setPomFile(targetPom);
File settingsFile = null;
String settingsFileName = (String)filter.get("jetspeed.mvn.settings.xml");
if (settingsFileName == null)
{
settingsFileName = target.settingsFile;
}
if (settingsFileName != null )
{
settingsFileName = interpolateRootDir(settingsFileName);
settingsFile = new File(settingsFileName);
if (!settingsFile.exists() || !settingsFile.isFile())
{
settingsFile = null;
}
}
if (settingsFile == null && useSettings)
{
settingsFile = getLocalOrProjectFile(targetPom.getParentFile(), project, "jetspeed-mvn-settings.xml");
}
if (settingsFile != null)
{
settingsFile = buildInterpolatedFile( settingsFile, settingsFile.getParentFile(), settingsFile.getName()+".interpolated", filter);
request.setUserSettingsFile(settingsFile);
}
try
{
getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) );
}