Search in sources :

Example 66 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project meecrowave by apache.

the class MeecrowaveBundleMojoTest method bundle.

@Test
public void bundle() throws Exception {
    final File moduleBase = jarLocation(MeecrowaveBundleMojoTest.class).getParentFile().getParentFile();
    final File basedir = new File(moduleBase, "src/test/resources/" + getClass().getSimpleName());
    final File pom = new File(basedir, "pom.xml");
    final MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setBaseDirectory(basedir);
    final ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
    final DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
    repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory().newInstance(repositorySession, new LocalRepository(new File(moduleBase, "target/fake"), "")));
    configuration.setRepositorySession(repositorySession);
    final MavenProject project = mojo.lookup(ProjectBuilder.class).build(pom, configuration).getProject();
    final Build build = new Build();
    final File buildDir = new File("target/" + getClass().getName() + "/build");
    build.setDirectory(buildDir.getAbsolutePath());
    project.setBuild(build);
    final MavenSession session = mojo.newMavenSession(project);
    final MojoExecution execution = mojo.newMojoExecution("bundle");
    execution.getConfiguration().addChild(new Xpp3Dom("enforceMeecrowave") {

        {
            setValue(Boolean.FALSE.toString());
        }
    });
    execution.getConfiguration().addChild(new Xpp3Dom("enforceCommonsCli") {

        {
            setValue(Boolean.FALSE.toString());
        }
    });
    execution.getConfiguration().addChild(new Xpp3Dom("conf") {

        {
            setValue("src/main/meecrowave/conf");
        }
    });
    execution.getConfiguration().addChild(new Xpp3Dom("webapp") {

        {
            setValue("src/main/webapp");
        }
    });
    mojo.executeMojo(session, project, execution);
    assertTrue(buildDir.exists());
    try (final ZipFile zip = new ZipFile(new File(buildDir, "test-meecrowave-distribution.zip"))) {
        assertTrue(zip.getEntry("test-distribution/docBase/sub/index.html") != null);
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) LocalRepository(org.eclipse.aether.repository.LocalRepository) ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) MavenSession(org.apache.maven.execution.MavenSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) ZipFile(java.util.zip.ZipFile) MojoExecution(org.apache.maven.plugin.MojoExecution) Build(org.apache.maven.model.Build) SimpleLocalRepositoryManagerFactory(org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 67 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project docker-maven-plugin by fabric8io.

the class AuthConfigFactory method extractFromServerConfiguration.

private String extractFromServerConfiguration(Object configuration, String prop) {
    if (configuration != null) {
        Xpp3Dom dom = (Xpp3Dom) configuration;
        Xpp3Dom element = dom.getChild(prop);
        if (element != null) {
            return element.getValue();
        }
    }
    return null;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Example 68 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project docker-maven-plugin by fabric8io.

the class MojoExecutionService method toXpp3Dom.

private Xpp3Dom toXpp3Dom(PlexusConfiguration config) {
    Xpp3Dom result = new Xpp3Dom(config.getName());
    result.setValue(config.getValue(null));
    for (String name : config.getAttributeNames()) {
        result.setAttribute(name, config.getAttribute(name));
    }
    for (PlexusConfiguration child : config.getChildren()) {
        result.addChild(toXpp3Dom(child));
    }
    return result;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration)

Example 69 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project docker-maven-plugin by fabric8io.

the class AuthConfigFactoryTest method setupServers.

private void setupServers() {
    new Expectations() {

        {
            List<Server> servers = new ArrayList<>();
            servers.add(create(ECR_NAME, "roland", "secret", "roland@jolokia.org"));
            servers.add(create("test.org", "fabric8io", "secret2", "fabric8io@redhat.com"));
            servers.add(create("test.org/roland", "roland", "secret", "roland@jolokia.org"));
            servers.add(create("docker.io", "tanja", "doublesecret", "tanja@jolokia.org"));
            servers.add(create("another.repo.org/joe", "joe", "3secret", "joe@foobar.com"));
            settings.getServers();
            result = servers;
        }

        private Server create(String id, String user, String password, String email) {
            Server server = new Server();
            server.setId(id);
            server.setUsername(user);
            server.setPassword(password);
            Xpp3Dom dom = new Xpp3Dom("configuration");
            Xpp3Dom emailD = new Xpp3Dom("email");
            emailD.setValue(email);
            dom.addChild(emailD);
            server.setConfiguration(dom);
            return server;
        }
    };
}
Also used : Expectations(mockit.Expectations) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Server(org.apache.maven.settings.Server) HttpServer(org.apache.http.impl.bootstrap.HttpServer) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 70 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project kie-wb-common by kiegroup.

the class MavenProjectConfigExecutor method extractConfig.

private void extractConfig(final Map<String, Object> content, final Xpp3Dom xmlData) {
    if (xmlData.getChildCount() > 0) {
        final Map<String, Object> config = new HashMap<>(xmlData.getChildCount());
        for (final Xpp3Dom child : xmlData.getChildren()) {
            extractConfig(config, child);
        }
        content.put(xmlData.getName(), config);
    } else {
        content.put(xmlData.getName(), xmlData.getValue());
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) HashMap(java.util.HashMap)

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