use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class ThemePluginBuildParticipant method executeThemeMojo.
protected IStatus executeThemeMojo(IMavenProjectFacade facade, IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
IStatus retval = null;
List<String> goals = Collections.singletonList(getGoal());
MavenProject mavenProject = facade.getMavenProject(monitor);
MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, goals, true, monitor);
monitor.worked(10);
MojoExecution liferayMojoExecution = MavenUtil.getExecution(plan, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_ARTIFACT_ID);
Xpp3Dom originalConfig = liferayMojoExecution.getConfiguration();
Xpp3Dom config = Xpp3DomUtils.mergeXpp3Dom(new Xpp3Dom("configuration"), originalConfig);
configureExecution(facade, config);
boolean parentHierarchyLoaded = false;
try {
parentHierarchyLoaded = MavenUtil.loadParentHierarchy(facade, monitor);
monitor.worked(10);
ResolverConfiguration configuration = facade.getResolverConfiguration();
configuration.setResolveWorkspaceProjects(true);
liferayMojoExecution.setConfiguration(config);
maven.execute(mavenProject, liferayMojoExecution, monitor);
monitor.worked(50);
MavenSession mavenSession = context.getSession();
List<Throwable> exceptions = mavenSession.getResult().getExceptions();
if (exceptions.size() == 1) {
retval = LiferayMavenCore.createErrorStatus(exceptions.get(0));
} else if (exceptions.size() > 1) {
List<IStatus> statuses = new ArrayList<>();
for (Throwable t : exceptions) {
statuses.add(LiferayMavenCore.createErrorStatus(t));
}
retval = LiferayMavenCore.createMultiStatus(IStatus.ERROR, statuses.toArray(new IStatus[0]));
}
retval = retval == null ? Status.OK_STATUS : retval;
} catch (CoreException ce) {
retval = LiferayMavenCore.createErrorStatus(ce);
} finally {
liferayMojoExecution.setConfiguration(originalConfig);
if (parentHierarchyLoaded) {
mavenProject.setParent(null);
}
}
return retval;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _warSourceDirectory.
private IFolder _warSourceDirectory(IProject project, MavenProject mavenProject) {
IFolder retval = null;
Xpp3Dom warPluginConfiguration = (Xpp3Dom) mavenProject.getPlugin(_mavenWarPluginKey).getConfiguration();
if (warPluginConfiguration != null) {
Xpp3Dom[] warSourceDirs = warPluginConfiguration.getChildren("warSourceDirectory");
if (ListUtil.isNotEmpty(warSourceDirs)) {
String resourceLocation = warSourceDirs[0].getValue();
retval = project.getFolder(resourceLocation);
}
}
if (retval == null) {
/*
* if no explicit warSourceDirectory set we assume the default warSource
* directory ${basedir}/src/main/webapp refer to
* http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html for more
* information
*/
retval = project.getFolder(_warSourceFolder);
}
return retval;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class MavenProjectBuilder method initBundle.
public IStatus initBundle(IProject project, String bundleUrl, IProgressMonitor monitor) throws CoreException {
if (bundleUrl != null) {
File pomFile = FileUtil.getFile(project.getFile("pom.xml"));
MavenXpp3Reader mavenReader = new MavenXpp3Reader();
MavenXpp3Writer mavenWriter = new MavenXpp3Writer();
try (FileReader reader = new FileReader(pomFile)) {
Model model = mavenReader.read(reader);
if (model != null) {
Build build = model.getBuild();
Plugin plugin = build.getPluginsAsMap().get("com.liferay:com.liferay.portal.tools.bundle.support");
if (plugin != null) {
try (FileWriter fileWriter = new FileWriter(pomFile)) {
Xpp3Dom origin = (Xpp3Dom) plugin.getConfiguration();
Xpp3Dom newConfiguration = new Xpp3Dom("configuration");
Xpp3Dom url = new Xpp3Dom("url");
url.setValue(bundleUrl);
newConfiguration.addChild(url);
plugin.setConfiguration(Xpp3Dom.mergeXpp3Dom(newConfiguration, origin));
mavenWriter.write(fileWriter, model);
}
}
}
} catch (Exception e) {
LiferayMavenCore.logError("Could not write file in" + pomFile, e);
}
}
IMavenProjectFacade facade = MavenUtil.getProjectFacade(project, monitor);
if (_execMavenLaunch(project, MavenGoalUtil.getMavenInitBundleGoal(project), facade, monitor)) {
return Status.OK_STATUS;
}
return LiferayMavenCore.createErrorStatus("run init-bundle error");
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class MavenProjectBuilder method getPortletProject.
public IProject getPortletProject(IMavenProjectFacade projectFacade, IProgressMonitor monitor) {
IProject retVal = null;
try {
Xpp3Dom config = MavenUtil.getLiferayMavenPluginConfig(projectFacade.getMavenProject());
if (config != null) {
Xpp3Dom webAppDir = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_WEBAPPBASE_DIR);
Xpp3Dom pluginName = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_PLUGIN_NAME);
if (webAppDir != null) {
String webAppDirValue = webAppDir.getValue();
String projectPath = Path.fromOSString(webAppDirValue).lastSegment();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
retVal = workspace.getRoot().getProject(projectPath);
} else if (pluginName != null) {
String pluginNameValue = pluginName.getValue();
retVal = CoreUtil.getProject(pluginNameValue);
}
}
} catch (Exception e) {
LiferayMavenCore.logError("Could not refresh sibling service project.", e);
}
return retVal;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8-maven-plugin by fabric8io.
the class DockerServerUtilTest method createSettings.
private Settings createSettings() {
Settings settings = new Settings();
Server server = new Server();
server.setId("docker.io");
server.setUsername("username");
server.setPassword("password");
settings.addServer(server);
Server server1 = new Server();
server1.setId("docker1.io");
server1.setUsername("username1");
server1.setPassword("password1");
Xpp3Dom mail = new Xpp3Dom("email");
mail.setValue("bar@bar.com");
Xpp3Dom configuration = new Xpp3Dom("configuration");
configuration.addChild(mail);
server1.setConfiguration(configuration);
settings.addServer(server1);
Server server2 = new Server();
server2.setId("docker2.io");
server2.setUsername("username2");
server2.setPassword("password2");
Xpp3Dom configuration1 = new Xpp3Dom("configuration");
server2.setConfiguration(configuration1);
settings.addServer(server2);
return settings;
}
Aggregations