use of org.codehaus.plexus.util.xml.Xpp3Dom in project sling by apache.
the class ModelPreprocessor method processAttachments.
private void processAttachments(final Environment env, final ProjectInfo info) throws MavenExecutionException {
final Xpp3Dom config = info.plugin == null ? null : (Xpp3Dom) info.plugin.getConfiguration();
final Xpp3Dom[] nodes = (config == null ? null : config.getChildren("attach"));
if (nodes != null) {
for (final Xpp3Dom node : nodes) {
final String type = nodeValue(node, "type", null);
if (type == null) {
throw new MavenExecutionException("Attachment for provisioning model has no type.", (File) null);
}
final String classifier = nodeValue(node, "classifier", null);
final String featureName = nodeValue(node, "feature", null);
int startLevel = 0;
final String level = nodeValue(node, "startLevel", null);
if (level != null) {
startLevel = Integer.valueOf(level);
}
final Feature f;
if (featureName != null) {
f = info.localModel.getFeature(featureName);
} else if (info.localModel.getFeatures().isEmpty()) {
f = null;
} else {
f = info.localModel.getFeatures().get(0);
}
if (f == null) {
if (featureName == null) {
throw new MavenExecutionException("No feature found in provisioning model for attachment.", (File) null);
}
throw new MavenExecutionException("Feature with name '" + featureName + "' not found in provisioning model for attachment.", (File) null);
}
final RunMode runMode = f.getOrCreateRunMode(null);
final ArtifactGroup group = runMode.getOrCreateArtifactGroup(startLevel);
final org.apache.sling.provisioning.model.Artifact artifact = new org.apache.sling.provisioning.model.Artifact(info.project.getGroupId(), info.project.getArtifactId(), info.project.getVersion(), classifier, type);
env.logger.debug("Attaching " + artifact + " to feature " + f.getName());
group.add(artifact);
}
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project sling by apache.
the class ModelPreprocessor method hasNodeValue.
/**
* Checks if plugin configuration value is set in POM for a specific configuration parameter.
* @param plugin Plugin
* @param name Configuration parameter.
* @return {@code true} in case the configuration has been set in the pom, otherwise {@code false}
*/
private boolean hasNodeValue(final Plugin plugin, final String name) {
final Xpp3Dom config = plugin == null ? null : (Xpp3Dom) plugin.getConfiguration();
final Xpp3Dom node = (config == null ? null : config.getChild(name));
return (node != null);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8 by jboss-fuse.
the class AetherBasedResolver method createSession.
public DefaultRepositorySystemSession createSession(LocalRepository repo) {
DefaultRepositorySystemSession session = newRepositorySystemSession();
if (repo != null) {
session.setLocalRepositoryManager(m_repoSystem.newLocalRepositoryManager(session, repo));
} else {
File local;
if (m_config.getLocalRepository() != null) {
local = m_config.getLocalRepository().getFile();
} else {
local = new File(System.getProperty("user.home"), ".m2/repository");
}
LocalRepository localRepo = new LocalRepository(local);
session.setLocalRepositoryManager(m_repoSystem.newLocalRepositoryManager(session, localRepo));
}
session.setMirrorSelector(m_mirrorSelector);
session.setProxySelector(m_proxySelector);
String updatePolicy = m_config.getGlobalUpdatePolicy();
if (null != updatePolicy) {
session.setUpdatePolicy(updatePolicy);
}
String checksumPolicy = m_config.getGlobalChecksumPolicy();
if (null != checksumPolicy) {
session.setChecksumPolicy(checksumPolicy);
}
for (Server server : m_settings.getServers()) {
if (server.getConfiguration() != null && ((Xpp3Dom) server.getConfiguration()).getChild("httpHeaders") != null) {
addServerConfig(session, server);
}
}
// org.eclipse.aether.transport.wagon.WagonTransporter.connectWagon() sets connection timeout
// as max of connection timeout and request timeout taken from aether session config
// but on the other hand, request timeout is used in org.eclipse.aether.connector.basic.PartialFile.Factory
//
// because real socket read timeout is used again (correctly) in
// org.ops4j.pax.url.mvn.internal.wagon.ConfigurableHttpWagon.execute() - directly from wagon configuration
// (from org.apache.maven.wagon.AbstractWagon.getReadTimeout()), we explicitly configure aether session
// config with: PartialFile.Factory timeout == connection timeout
int defaultTimeut = m_config.getTimeout();
Integer timeout = m_config.getProperty(ServiceConstants.PROPERTY_SOCKET_CONNECTION_TIMEOUT, defaultTimeut, Integer.class);
session.setConfigProperty(ConfigurationProperties.CONNECT_TIMEOUT, timeout);
session.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, timeout);
session.setConfigProperty("aether.updateCheckManager.sessionState", "no");
session.setOffline(m_config.isOffline());
// - this is required for correct SNAPSHOT handling
if (repo != null) {
RemoteRepository remoteRepository = defaultRepositories.get(repo.getBasedir());
session.getData().set(SmartMetadataResolver.DEFAULT_REPOSITORY, null, remoteRepository);
}
boolean updateReleases = m_config.getProperty(ServiceConstants.PROPERTY_UPDATE_RELEASES, false, Boolean.class);
session.setConfigProperty(SmartLocalRepositoryManagerFactory.PROPERTY_UPDATE_RELEASES, updateReleases);
return session;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class MavenUtil method setConfigValue.
public static void setConfigValue(Xpp3Dom configuration, String childName, Object value) {
Xpp3Dom childNode = configuration.getChild(childName);
if (childNode == null) {
childNode = new Xpp3Dom(childName);
configuration.addChild(childNode);
}
childNode.setValue((value == null) ? null : value.toString());
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.
the class MavenUtil method getLiferayMavenPluginConfig.
public static String getLiferayMavenPluginConfig(MavenProject mavenProject, String childElement) {
String retval = null;
Xpp3Dom liferayMavenPluginConfig = getLiferayMavenPluginConfig(mavenProject);
if (liferayMavenPluginConfig != null) {
Xpp3Dom childNode = liferayMavenPluginConfig.getChild(childElement);
if (childNode != null) {
retval = childNode.getValue();
}
}
return retval;
}
Aggregations