Search in sources :

Example 16 with MavenSession

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

the class TychoInterpolatorTest method setUp.

@Before
public void setUp() {
    MavenSession session = mock(MavenSession.class);
    project = mock(MavenProject.class);
    settings = mock(Settings.class);
    File baseDir = mock(File.class);
    Properties projectProperties = new Properties();
    projectProperties.put("myProjectPropertyKey", "myProjectPropertyValue");
    Properties userProperties = new Properties();
    userProperties.put("myUserPropertyKey", "myUserPropertyValue");
    Properties systemProperties = new Properties();
    systemProperties.put("mySystemPropertyKey", "mySystemPropertyValue");
    when(project.getProperties()).thenReturn(projectProperties);
    when(session.getSystemProperties()).thenReturn(systemProperties);
    when(session.getUserProperties()).thenReturn(userProperties);
    when(session.getSettings()).thenReturn(settings);
    when(settings.getLocalRepository()).thenReturn("myLocalRepo");
    when(project.getBasedir()).thenReturn(baseDir);
    when(project.getVersion()).thenReturn("1.0.0");
    when(baseDir.getAbsolutePath()).thenReturn("absolutePathToBaseDir");
    interpolator = new TychoInterpolator(session, project);
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) Properties(java.util.Properties) File(java.io.File) Settings(org.apache.maven.settings.Settings) Before(org.junit.Before)

Example 17 with MavenSession

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

the class OsgiSourceMojoTest method testDefaultClassifier.

public void testDefaultClassifier() throws Exception {
    File basedir = getBasedir("bundle01");
    List<MavenProject> projects = getSortedProjects(basedir, basedir);
    MavenSession session = newMavenSession(projects.get(0));
    OsgiSourceMojo sourceMojo = (OsgiSourceMojo) lookupMojoWithDefaultConfiguration(projects.get(0), session, "plugin-source");
    assertEquals(ReactorProject.SOURCE_ARTIFACT_CLASSIFIER, sourceMojo.getClassifier());
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) File(java.io.File)

Example 18 with MavenSession

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

the class BuildPropertiesParserImpl method interpolate.

protected void interpolate(Properties properties, File baseDir) {
    if (properties.isEmpty()) {
        return;
    }
    MavenSession mavenSession = legacySupport.getSession();
    if (mavenSession == null) {
        logger.warn("No maven session available, values in the build.properties will not be interpolated!");
        return;
    }
    // find the maven project for the currently used basedir, so that the correct maven project is used by the interpolator.
    // if no project could be found, it does not make sense to interpolate the properties
    MavenProject mavenProject = MavenSessionUtils.getMavenProject(mavenSession, baseDir);
    if (mavenProject == null) {
        logger.warn("No maven project found for baseDir '" + baseDir.getAbsolutePath() + "', values in the build.properties will not be interpolated!");
        return;
    }
    TychoInterpolator interpolator = new TychoInterpolator(mavenSession, mavenProject);
    for (Entry<Object, Object> entry : properties.entrySet()) {
        entry.setValue(interpolator.interpolate((String) entry.getValue()));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) TychoInterpolator(org.eclipse.tycho.core.maven.TychoInterpolator)

Example 19 with MavenSession

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

the class OSGiProxyConfigurator method afterFrameworkStarted.

@Override
public void afterFrameworkStarted(EmbeddedEquinox framework) {
    MavenSession session = context.getSession();
    ProxyServiceFacade proxyService = framework.getServiceFactory().getService(ProxyServiceFacade.class);
    // make sure there is no old state from previous aborted builds
    clearProxyConfiguration(proxyService);
    for (Proxy proxy : session.getSettings().getProxies()) {
        if (proxy.isActive()) {
            setProxy(proxyService, proxy);
        }
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Proxy(org.apache.maven.settings.Proxy) ProxyServiceFacade(org.eclipse.tycho.core.shared.ProxyServiceFacade)

Example 20 with MavenSession

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

the class TychoOsgiRuntimeLocator method locateRuntime.

@Override
public void locateRuntime(EquinoxRuntimeDescription description) throws MavenExecutionException {
    WorkspaceTychoOsgiRuntimeLocator workspaceLocator = WorkspaceTychoOsgiRuntimeLocator.getResolver(this.workspaceState);
    MavenSession session = buildContext.getSession();
    addRuntimeArtifacts(workspaceLocator, session, description);
    for (String systemPackage : SYSTEM_PACKAGES_EXTRA) {
        description.addExtraSystemPackage(systemPackage);
    }
    if (workspaceLocator != null) {
        workspaceLocator.addPlatformProperties(description);
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession)

Aggregations

MavenSession (org.apache.maven.execution.MavenSession)117 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)19 Properties (java.util.Properties)18 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)18 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)11 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