Search in sources :

Example 6 with Xpp3Dom

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);
        }
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Feature(org.apache.sling.provisioning.model.Feature) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) MavenExecutionException(org.apache.maven.MavenExecutionException) RunMode(org.apache.sling.provisioning.model.RunMode) ArtifactGroup(org.apache.sling.provisioning.model.ArtifactGroup)

Example 7 with Xpp3Dom

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);
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Example 8 with Xpp3Dom

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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) Server(org.apache.maven.settings.Server) LocalRepository(org.eclipse.aether.repository.LocalRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) File(java.io.File) JarFile(java.util.jar.JarFile) VersionConstraint(org.eclipse.aether.version.VersionConstraint)

Example 9 with Xpp3Dom

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());
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Example 10 with Xpp3Dom

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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Aggregations

Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)156 Plugin (org.apache.maven.model.Plugin)39 File (java.io.File)26 ArrayList (java.util.ArrayList)18 PluginExecution (org.apache.maven.model.PluginExecution)18 IOException (java.io.IOException)13 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 MavenSession (org.apache.maven.execution.MavenSession)10 MavenProject (org.apache.maven.project.MavenProject)10 Model (org.apache.maven.model.Model)9 Reader (java.io.Reader)8 Build (org.apache.maven.model.Build)8 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)8 BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)8 MojoExecution (org.apache.maven.plugin.MojoExecution)7 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)7 Map (java.util.Map)6 Dependency (org.apache.maven.model.Dependency)6 StringReader (java.io.StringReader)5