use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _checkValidVersion.
private MavenProblemInfo _checkValidVersion(Plugin plugin, Xpp3Dom config, String versionNodeName) {
MavenProblemInfo retval = null;
Version liferayVersion = null;
String version = null;
if (config != null) {
// check for version config node
Xpp3Dom versionNode = config.getChild(versionNodeName);
if (versionNode != null) {
version = versionNode.getValue();
try {
liferayVersion = new Version(MavenUtil.getVersion(version));
} catch (IllegalArgumentException iae) {
// bad version
}
}
}
if ((liferayVersion == null) || liferayVersion.equals(ILiferayConstants.EMPTY_VERSION)) {
// could not get valid liferayVersion
SourceLocation location = SourceLocationHelper.findLocation(plugin, SourceLocationHelper.CONFIGURATION);
String problemMsg = NLS.bind(Msgs.unusableConfigValue, versionNodeName, version);
retval = new MavenProblemInfo(problemMsg, IMarker.SEVERITY_WARNING, location);
}
return retval;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _checkValidConfigDir.
private MavenProblemInfo _checkValidConfigDir(Plugin liferayMavenPlugin, Xpp3Dom config, String configParam) {
MavenProblemInfo retval = null;
String message = null;
String value = null;
if (configParam != null) {
if (config == null) {
message = NLS.bind(Msgs.missingConfigValue, configParam);
} else {
Xpp3Dom dirNode = config.getChild(configParam);
if (dirNode == null) {
message = NLS.bind(Msgs.missingConfigValue, configParam);
} else {
value = dirNode.getValue();
if (CoreUtil.isNullOrEmpty(value)) {
message = NLS.bind(Msgs.emptyConfigValue, configParam);
} else {
File configDir = new File(value);
if (FileUtil.notExists(configDir) || !configDir.isDirectory()) {
message = NLS.bind(Msgs.unusableConfigValue, configParam, value);
}
}
}
}
}
if (message != null) {
SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, SourceLocationHelper.CONFIGURATION);
retval = new MavenProblemInfo(message, IMarker.SEVERITY_WARNING, location);
}
return retval;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class MavenProjectBuilder method refreshSiblingProject.
public void refreshSiblingProject(IMavenProjectFacade projectFacade, IProgressMonitor monitor) throws CoreException {
try {
Plugin plugin6x = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
if (plugin6x != null) {
Xpp3Dom config = (Xpp3Dom) plugin6x.getConfiguration();
Xpp3Dom apiBaseDir = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_API_BASE_DIR);
String apiBaseDirValue = apiBaseDir.getValue();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile apiBasePomFile = workspace.getRoot().getFileForLocation(new Path(apiBaseDirValue).append(IMavenConstants.POM_FILE_NAME));
IMavenProjectFacade apiBaseFacade = this.projectManager.create(apiBasePomFile, true, monitor);
apiBaseFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
} else {
Plugin plugin7x = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_KEY, monitor);
if (plugin7x != null) {
Xpp3Dom config = (Xpp3Dom) plugin7x.getConfiguration();
Xpp3Dom apiDirName = config.getChild("apiDirName");
String apiDirNameValue = apiDirName.getValue();
int startIndex = apiDirNameValue.indexOf("../");
int endIndex = apiDirNameValue.indexOf("/src/main/java");
String projectName = apiDirNameValue.substring(startIndex + 3, endIndex);
IProject project = CoreUtil.getProject(projectName);
if (project != null) {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
}
} catch (Exception e) {
LiferayMavenCore.logError("Could not refresh sibling service project.", e);
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8-maven-plugin by fabric8io.
the class BaseBoosterIT method addRedeploymentAnnotations.
/**
* Appends some annotation properties to the fmp's configuration in test repository's pom
* just to distinguish whether the application is re-deployed or not.
*
* @param testRepository
* @throws Exception
*/
protected void addRedeploymentAnnotations(Repository testRepository, String relativePomPath, String annotationKey, String annotationValue, String fmpConfigFragmentFile) throws IOException, XmlPullParserException {
File pomFile = new File(testRepository.getWorkTree().getAbsolutePath(), relativePomPath);
Model model = readPomModelFromFile(pomFile);
File pomFragment = new File(getClass().getResource(fmpConfigFragmentFile).getFile());
String pomFragmentStr = String.format(FileUtils.readFileToString(pomFragment), annotationKey, annotationValue, annotationKey, annotationValue);
Xpp3Dom configurationDom = Xpp3DomBuilder.build(new ByteArrayInputStream(pomFragmentStr.getBytes()), "UTF-8");
int nOpenShiftProfile = getProfileIndexUsingFmp(model, fabric8MavenPluginKey);
model.getProfiles().get(nOpenShiftProfile).getBuild().getPluginsAsMap().get(fabric8MavenPluginKey).setConfiguration(configurationDom);
writePomModelToFile(pomFile, model);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8-maven-plugin by fabric8io.
the class KarafHealthCheckEnricher method discoverKarafProbe.
//
// Karaf has a readiness/health URL exposed if the fabric8-karaf-check feature is installed.
//
private Probe discoverKarafProbe(String path, int initialDelay) {
for (Plugin plugin : this.getProject().getBuildPlugins()) {
if ("karaf-maven-plugin".equals(plugin.getArtifactId())) {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration == null)
return null;
Xpp3Dom startupFeatures = configuration.getChild("startupFeatures");
if (startupFeatures == null)
return null;
for (Xpp3Dom feature : startupFeatures.getChildren("feature")) {
if ("fabric8-karaf-checks".equals(feature.getValue())) {
// TODO: handle the case where the user changes the default port
return new ProbeBuilder().withNewHttpGet().withNewPort(DEFAULT_HEALTH_CHECK_PORT).withPath(path).endHttpGet().withInitialDelaySeconds(initialDelay).build();
}
}
}
}
return null;
}
Aggregations