use of org.codehaus.plexus.util.xml.Xpp3Dom in project pom-manipulation-ext by release-engineering.
the class ModelIO method processChildren.
/**
* Recursively process the DOM elements to inline any property values from the model.
* @param userProperties
* @param model
* @param parent
*/
private void processChildren(Properties userProperties, Model model, Xpp3Dom parent) {
for (int i = 0; i < parent.getChildCount(); i++) {
Xpp3Dom child = parent.getChild(i);
if (child.getChildCount() > 0) {
processChildren(userProperties, model, child);
}
if (child.getValue() != null && child.getValue().startsWith("${")) {
String replacement = resolveProperty(userProperties, model.getProperties(), child.getValue());
if (replacement != null && !replacement.isEmpty()) {
logger.debug("Replacing child value " + child.getValue() + " with " + replacement);
child.setValue(replacement);
}
}
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project pom-manipulation-ext by release-engineering.
the class BOMBuilderManipulator method applyChanges.
/**
* If enabled, grab the execution root pom (which will be the topmost POM in terms of directory structure). Within that
* handle the manipulation of the bom injection.
*/
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
final BOMInjectingState state = session.getState(BOMInjectingState.class);
if (!session.isEnabled() || !state.isEnabled()) {
logger.debug(getClass().getSimpleName() + ": Nothing to do!");
return Collections.emptySet();
}
List<Dependency> projectArtifacts = getArtifacts(projects);
for (final Project project : projects) {
if (project.isExecutionRoot()) {
logger.info("Examining {} to add BOM generation.", project);
final Model model = project.getModel();
Build build = model.getBuild();
if (build == null) {
build = new Build();
model.setBuild(build);
}
Model bomModel = createModel(project, IDBOM);
bomModel.setDescription("PME Generated BOM for other projects to use to align to.");
DependencyManagement dm = new DependencyManagement();
dm.setDependencies(projectArtifacts);
bomModel.setDependencyManagement(dm);
// Write new bom back out.
File pmebom = new File(session.getTargetDir(), IDBOM + ".xml");
session.getTargetDir().mkdir();
pomIO.writeModel(bomModel, pmebom);
final Map<String, Plugin> pluginMap = build.getPluginsAsMap();
if (!pluginMap.containsKey(POM_DEPLOYER_COORD)) {
final PluginExecution execution = new PluginExecution();
execution.setId(IDBOM);
execution.setPhase("install");
execution.setGoals(Collections.singletonList("add-pom"));
final Plugin plugin = new Plugin();
plugin.setGroupId(POM_DEPLOYER_GID);
plugin.setArtifactId(POM_DEPLOYER_AID);
plugin.setVersion(POM_DEPLOYER_VID);
plugin.addExecution(execution);
plugin.setInherited(false);
build.addPlugin(plugin);
final Xpp3Dom xml = new Xpp3Dom("configuration");
final Map<String, Object> config = new HashMap<>();
config.put("pomName", "target" + File.separatorChar + pmebom.getName());
config.put("errorOnMissing", false);
config.put("artifactId", bomModel.getArtifactId());
config.put("groupId", bomModel.getGroupId());
for (final Map.Entry<String, Object> entry : config.entrySet()) {
final Xpp3Dom child = new Xpp3Dom(entry.getKey());
if (entry.getValue() != null) {
child.setValue(entry.getValue().toString());
}
xml.addChild(child);
}
execution.setConfiguration(xml);
}
return Collections.singleton(project);
}
}
return Collections.emptySet();
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project meghanada-server by mopemope.
the class POMParser method parsePlugins.
private void parsePlugins(POMInfo pomInfo, Build build) {
for (Plugin plugin : build.getPlugins()) {
if (plugin.getArtifactId().equals("build-helper-maven-plugin")) {
for (PluginExecution pluginExecution : plugin.getExecutions()) {
Object conf = pluginExecution.getConfiguration();
if (nonNull(conf) && conf instanceof Xpp3Dom) {
Xpp3Dom confDom = (Xpp3Dom) conf;
Xpp3Dom sources = confDom.getChild("sources");
if (nonNull(sources)) {
Xpp3Dom[] children = sources.getChildren();
if (nonNull(children)) {
for (Xpp3Dom s : sources.getChildren()) {
String value = s.getValue();
if (!Strings.isNullOrEmpty(value)) {
pomInfo.sourceDirectory.add(normalize(pomInfo, value));
}
}
}
}
}
}
}
if (plugin.getArtifactId().equals("maven-compiler-plugin")) {
Object conf = plugin.getConfiguration();
if (nonNull(conf) && conf instanceof Xpp3Dom) {
Xpp3Dom confDom = (Xpp3Dom) conf;
Xpp3Dom source = confDom.getChild("source");
if (nonNull(source)) {
pomInfo.compileSource = source.getValue();
}
Xpp3Dom target = confDom.getChild("target");
if (nonNull(target)) {
pomInfo.compileTarget = target.getValue();
}
}
}
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8 by jboss-fuse.
the class AetherBasedResolver method addServerConfig.
private void addServerConfig(DefaultRepositorySystemSession session, Server server) {
Map<String, String> headers = new HashMap<String, String>();
Xpp3Dom configuration = (Xpp3Dom) server.getConfiguration();
Xpp3Dom httpHeaders = configuration.getChild("httpHeaders");
for (Xpp3Dom httpHeader : httpHeaders.getChildren("httpHeader")) {
Xpp3Dom name = httpHeader.getChild("name");
String headerName = name.getValue();
Xpp3Dom value = httpHeader.getChild("value");
String headerValue = value.getValue();
headers.put(headerName, headerValue);
}
session.setConfigProperty(String.format("%s.%s", ConfigurationProperties.HTTP_HEADERS, server.getId()), headers);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _findLiferayMavenPluginProblems.
private List<MavenProblemInfo> _findLiferayMavenPluginProblems(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
List<MavenProblemInfo> warnings = new ArrayList<>();
// first check to make sure that the AppServer* properties are available and
// pointed to valid location
Plugin liferayMavenPlugin = MavenUtil.getPlugin(request.getMavenProjectFacade(), ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
if (liferayMavenPlugin != null) {
Xpp3Dom config = (Xpp3Dom) liferayMavenPlugin.getConfiguration();
MavenProblemInfo validLiferayProblemInfo = _checkValidVersion(liferayMavenPlugin, config, ILiferayMavenConstants.PLUGIN_CONFIG_LIFERAY_VERSION);
if (validLiferayProblemInfo != null) {
warnings.add(validLiferayProblemInfo);
}
Version mavenPluginVersion = new Version(MavenUtil.getVersion(liferayMavenPlugin.getVersion()));
if ((mavenPluginVersion == null) || mavenPluginVersion.equals(ILiferayConstants.EMPTY_VERSION)) {
// could not get valid version for liferaymavenPlugin
SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, "version");
String problemMsg = NLS.bind(Msgs.invalidVersion, "liferay-maven-plugin", liferayMavenPlugin.getVersion());
MavenProblemInfo versionProblem = new MavenProblemInfo(problemMsg, IMarker.SEVERITY_WARNING, location);
warnings.add(versionProblem);
}
String[] configDirParams = { ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_PORTAL_DIR };
for (String configParam : configDirParams) {
MavenProblemInfo configProblemInfo = _checkValidConfigDir(liferayMavenPlugin, config, configParam);
if (configProblemInfo != null) {
warnings.add(configProblemInfo);
}
}
}
return warnings;
}
Aggregations