Search in sources :

Example 81 with MavenSession

use of org.apache.maven.execution.MavenSession in project docker-maven-plugin by fabric8io.

the class DockerAssemblyConfigurationSource method createCommandLinePropertiesInterpolator.

private FixedStringSearchInterpolator createCommandLinePropertiesInterpolator() {
    Properties commandLineProperties = System.getProperties();
    final MavenSession session = getMavenSession();
    if (session != null) {
        commandLineProperties = new Properties();
        if (session.getSystemProperties() != null) {
            commandLineProperties.putAll(session.getSystemProperties());
        }
        if (session.getUserProperties() != null) {
            commandLineProperties.putAll(session.getUserProperties());
        }
    }
    PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource(commandLineProperties);
    return FixedStringSearchInterpolator.create(cliProps);
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Properties(java.util.Properties) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource)

Example 82 with MavenSession

use of org.apache.maven.execution.MavenSession in project build-info by JFrogDev.

the class BuildInfoRecorder method extract.

@Override
public Build extract(ExecutionEvent event) {
    MavenSession session = event.getSession();
    if (!session.getResult().hasExceptions()) {
        if (conf.isIncludeEnvVars()) {
            Properties envProperties = new Properties();
            envProperties.putAll(conf.getAllProperties());
            envProperties = BuildInfoExtractorUtils.getEnvProperties(envProperties, conf.getLog());
            for (Map.Entry<Object, Object> envProp : envProperties.entrySet()) {
                buildInfoBuilder.addProperty(envProp.getKey(), envProp.getValue());
            }
        }
        Date finish = new Date();
        long time = finish.getTime() - session.getRequest().getStartTime().getTime();
        return buildInfoBuilder.durationMillis(time).build();
    }
    return null;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) BuildInfoConfigProperties(org.jfrog.build.api.BuildInfoConfigProperties) ClientProperties(org.jfrog.build.extractor.clientConfiguration.ClientProperties)

Example 83 with MavenSession

use of org.apache.maven.execution.MavenSession in project tycho by eclipse.

the class BuildPropertiesParserImplTest method setup.

@Before
public void setup() throws IllegalArgumentException, IllegalAccessException {
    legacySupport = mock(LegacySupport.class);
    mavenSession = mock(MavenSession.class);
    project1 = mock(MavenProject.class);
    project2 = mock(MavenProject.class);
    logger = mock(Logger.class);
    when(legacySupport.getSession()).thenReturn(mavenSession);
    when(mavenSession.getProjects()).thenReturn(Arrays.asList(project1, project2));
    when(project1.getBasedir()).thenReturn(new File("/bathToProject1"));
    when(project2.getBasedir()).thenReturn(new File("/bathToProject2"));
    parser = new BuildPropertiesParserImpl(legacySupport, logger);
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenProject(org.apache.maven.project.MavenProject) Logger(org.codehaus.plexus.logging.Logger) File(java.io.File) Before(org.junit.Before)

Example 84 with MavenSession

use of org.apache.maven.execution.MavenSession in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithValidTargetDefinition.

@Test
public void testAddTargetWithValidTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration("myGroupId", "myArtifactId", "myVersion");
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    configurationReader.addTargetArtifact(configuration, session, null, dom);
    assertEquals(1, configuration.getTargets().size());
    assertEquals(new File("/basedir/myArtifactId.target").getPath(), configuration.getTargets().get(0).getPath());
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) File(java.io.File) Test(org.junit.Test)

Example 85 with MavenSession

use of org.apache.maven.execution.MavenSession in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingVersionInTargetDefinition.

@Test
public void testAddTargetWithMissingVersionInTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration("myGroupId", "myArtifactId", null);
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    try {
        configurationReader.addTargetArtifact(configuration, session, null, dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Aggregations

MavenSession (org.apache.maven.execution.MavenSession)118 File (java.io.File)65 MavenProject (org.apache.maven.project.MavenProject)47 SimpleLocalRepositoryManager (org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager)30 DefaultRepositorySystemSession (org.sonatype.aether.util.DefaultRepositorySystemSession)23 Test (org.junit.Test)21 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)20 LegacySupport (org.apache.maven.plugin.LegacySupport)20 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)18 Properties (java.util.Properties)17 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)16 MojoExecution (org.apache.maven.plugin.MojoExecution)13 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)13 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)12 Artifact (org.apache.maven.artifact.Artifact)10 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)9 ManipulationSession (org.commonjava.maven.ext.core.ManipulationSession)8 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)7 Settings (org.apache.maven.settings.Settings)7 ArrayList (java.util.ArrayList)6