mirror of https://github.com/apache/maven.git
o removing many old embedder tests that are performing what is now done far better by the underlying components
o remove ties to the Configuration class in the populator which means it can be moved back to the core git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@794919 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2aa1e07e0b
commit
a5be13b93b
|
@ -144,18 +144,10 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenEmbedder mavenEmbedder;
|
MavenEmbedder mavenEmbedder;
|
||||||
MavenEmbedderLogger logger;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mavenEmbedder = new MavenEmbedder( configuration );
|
mavenEmbedder = new MavenEmbedder( configuration );
|
||||||
|
|
||||||
logger = mavenEmbedder.getLogger();
|
|
||||||
|
|
||||||
if ( mavenEmbedder.isOffline( request ) )
|
|
||||||
{
|
|
||||||
logger.info( "You are working in offline mode." );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch ( MavenEmbedderException e )
|
catch ( MavenEmbedderException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class MavenEmbedder
|
||||||
|
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
private MavenExecutionRequest request;
|
//private MavenExecutionRequest request;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Constructors
|
// Constructors
|
||||||
|
@ -130,10 +130,12 @@ public class MavenEmbedder
|
||||||
start( embedderConfiguration );
|
start( embedderConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public MavenExecutionRequest getDefaultRequest()
|
public MavenExecutionRequest getDefaultRequest()
|
||||||
{
|
{
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Accessors
|
// Accessors
|
||||||
|
@ -144,6 +146,7 @@ public class MavenEmbedder
|
||||||
return classWorld;
|
return classWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public ArtifactRepository getLocalRepository()
|
public ArtifactRepository getLocalRepository()
|
||||||
{
|
{
|
||||||
return request.getLocalRepository();
|
return request.getLocalRepository();
|
||||||
|
@ -153,6 +156,7 @@ public class MavenEmbedder
|
||||||
{
|
{
|
||||||
return request.getSettings();
|
return request.getSettings();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public MavenEmbedderLogger getLogger()
|
public MavenEmbedderLogger getLogger()
|
||||||
{
|
{
|
||||||
|
@ -261,65 +265,6 @@ public class MavenEmbedder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Project
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public MavenProject readProject( File mavenProject )
|
|
||||||
throws ProjectBuildingException, MavenExecutionException
|
|
||||||
{
|
|
||||||
return readProject( mavenProject, request );
|
|
||||||
}
|
|
||||||
|
|
||||||
private MavenProject readProject( File mavenProject, MavenExecutionRequest request )
|
|
||||||
throws ProjectBuildingException, MissingModuleException
|
|
||||||
{
|
|
||||||
getLogger().debug( "Building MavenProject instance: " + mavenProject );
|
|
||||||
|
|
||||||
return projectBuilder.build( mavenProject, request.getProjectBuildingRequest() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to grab the list of dependencies that belong to a project so that a UI
|
|
||||||
* can be populated. For example, a list of libraries that are used by an Eclipse, Netbeans, or
|
|
||||||
* IntelliJ project.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// currently in m2eclipse each project is read read a single project for dependencies
|
|
||||||
// Project
|
|
||||||
// Exceptions
|
|
||||||
// explicit for exceptions where coordinate are involved.
|
|
||||||
// m2eclipse is not using the topological sorting at all because it keeps track itself.
|
|
||||||
|
|
||||||
public MavenExecutionResult readProjectWithDependencies( MavenExecutionRequest request )
|
|
||||||
{
|
|
||||||
MavenExecutionResult result = new DefaultMavenExecutionResult();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
request = populator.populateDefaults( request, configuration );
|
|
||||||
}
|
|
||||||
catch ( MavenEmbedderException e )
|
|
||||||
{
|
|
||||||
return result.addException( e );
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MavenProjectBuildingResult projectBuildingResult = projectBuilder.buildProjectWithDependencies( request.getPom(), request.getProjectBuildingRequest() );
|
|
||||||
|
|
||||||
result.setProject( projectBuildingResult.getProject() );
|
|
||||||
|
|
||||||
result.setArtifactResolutionResult( projectBuildingResult.getArtifactResolutionResult() );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch ( ProjectBuildingException e )
|
|
||||||
{
|
|
||||||
return result.addException( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -397,9 +342,9 @@ public class MavenEmbedder
|
||||||
|
|
||||||
// This is temporary as we can probably cache a single request and use it for default values and
|
// This is temporary as we can probably cache a single request and use it for default values and
|
||||||
// simply cascade values in from requests used for individual executions.
|
// simply cascade values in from requests used for individual executions.
|
||||||
request = new DefaultMavenExecutionRequest();
|
//request = new DefaultMavenExecutionRequest();
|
||||||
|
//
|
||||||
populator.populateDefaults( request, configuration );
|
//populator.populateDefaults( request, configuration );
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
|
@ -496,18 +441,6 @@ public class MavenEmbedder
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Start of new embedder API
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public boolean isOffline( MavenExecutionRequest request )
|
|
||||||
throws MavenEmbedderException
|
|
||||||
{
|
|
||||||
request = populator.populateDefaults( request, configuration );
|
|
||||||
|
|
||||||
return request.isOffline();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MavenExecutionResult execute( MavenExecutionRequest request )
|
public MavenExecutionResult execute( MavenExecutionRequest request )
|
||||||
{
|
{
|
||||||
LoggerManager loggerManager = container.getLoggerManager();
|
LoggerManager loggerManager = container.getLoggerManager();
|
||||||
|
@ -520,7 +453,7 @@ public class MavenEmbedder
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
request = populator.populateDefaults( request, configuration );
|
request = populator.populateDefaults( request );
|
||||||
}
|
}
|
||||||
catch ( MavenEmbedderException e )
|
catch ( MavenEmbedderException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Set;
|
||||||
import org.apache.maven.Maven;
|
import org.apache.maven.Maven;
|
||||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.embedder.Configuration;
|
|
||||||
import org.apache.maven.embedder.MavenEmbedder;
|
import org.apache.maven.embedder.MavenEmbedder;
|
||||||
import org.apache.maven.embedder.MavenEmbedderException;
|
import org.apache.maven.embedder.MavenEmbedderException;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
|
@ -36,12 +35,10 @@ import org.apache.maven.settings.SettingsUtils;
|
||||||
import org.apache.maven.toolchain.ToolchainsBuilder;
|
import org.apache.maven.toolchain.ToolchainsBuilder;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
@Component(role = MavenExecutionRequestPopulator.class)
|
@Component(role = MavenExecutionRequestPopulator.class)
|
||||||
public class DefaultMavenExecutionRequestPopulator
|
public class DefaultMavenExecutionRequestPopulator
|
||||||
extends AbstractLogEnabled
|
|
||||||
implements MavenExecutionRequestPopulator
|
implements MavenExecutionRequestPopulator
|
||||||
{
|
{
|
||||||
//TODO: this needs to be pushed up to the front-end
|
//TODO: this needs to be pushed up to the front-end
|
||||||
|
@ -54,45 +51,6 @@ public class DefaultMavenExecutionRequestPopulator
|
||||||
@Requirement
|
@Requirement
|
||||||
private ToolchainsBuilder toolchainsBuilder;
|
private ToolchainsBuilder toolchainsBuilder;
|
||||||
|
|
||||||
public MavenExecutionRequest populateDefaults( MavenExecutionRequest request, Configuration configuration )
|
|
||||||
throws MavenEmbedderException
|
|
||||||
{
|
|
||||||
// copy configuration to request
|
|
||||||
if ( request.getSettings() == null )
|
|
||||||
{
|
|
||||||
if ( configuration.getGlobalSettingsFile() != null )
|
|
||||||
{
|
|
||||||
request.setGlobalSettingsFile( configuration.getGlobalSettingsFile() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( configuration.getUserSettingsFile() != null )
|
|
||||||
{
|
|
||||||
request.setUserSettingsFile( configuration.getUserSettingsFile() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String localRepositoryPath = null;
|
|
||||||
|
|
||||||
if ( request.getLocalRepositoryPath() != null )
|
|
||||||
{
|
|
||||||
localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( StringUtils.isEmpty( localRepositoryPath ) && ( configuration.getLocalRepository() != null ) )
|
|
||||||
{
|
|
||||||
localRepositoryPath = configuration.getLocalRepository().getAbsolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !StringUtils.isEmpty( localRepositoryPath ) )
|
|
||||||
{
|
|
||||||
request.setLocalRepositoryPath( localRepositoryPath );
|
|
||||||
}
|
|
||||||
|
|
||||||
// populate the defaults
|
|
||||||
|
|
||||||
return populateDefaults( request );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pom( MavenExecutionRequest request )
|
private void pom( MavenExecutionRequest request )
|
||||||
{
|
{
|
||||||
if ( request.getPom() != null && !request.getPom().isAbsolute() )
|
if ( request.getPom() != null && !request.getPom().isAbsolute() )
|
||||||
|
|
|
@ -19,17 +19,11 @@ package org.apache.maven.embedder.execution;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.embedder.Configuration;
|
|
||||||
import org.apache.maven.embedder.MavenEmbedderException;
|
import org.apache.maven.embedder.MavenEmbedderException;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
|
|
||||||
public interface MavenExecutionRequestPopulator
|
public interface MavenExecutionRequestPopulator
|
||||||
{
|
{
|
||||||
String ROLE = MavenExecutionRequestPopulator.class.getName();
|
|
||||||
|
|
||||||
MavenExecutionRequest populateDefaults( MavenExecutionRequest request, Configuration configuration )
|
|
||||||
throws MavenEmbedderException;
|
|
||||||
|
|
||||||
MavenExecutionRequest populateDefaults( MavenExecutionRequest request )
|
MavenExecutionRequest populateDefaults( MavenExecutionRequest request )
|
||||||
throws MavenEmbedderException;
|
throws MavenEmbedderException;
|
||||||
|
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
package org.apache.maven.embedder;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
|
||||||
import org.apache.maven.execution.MavenExecutionResult;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.plugin.PluginManagerException;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
|
||||||
import org.codehaus.plexus.logging.Logger;
|
|
||||||
|
|
||||||
/** @author Jason van Zyl */
|
|
||||||
public class MavenEmbedderProjectWithExtensionReadingTest
|
|
||||||
extends MavenEmbedderTest
|
|
||||||
{
|
|
||||||
public void testProjectWithExtensionsReading()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
|
|
||||||
.setPom( new File( basedir, "src/test/resources/pom2.xml" ) )
|
|
||||||
// TODO: Remove this!
|
|
||||||
.setLoggingLevel( Logger.LEVEL_DEBUG );
|
|
||||||
|
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
|
||||||
|
|
||||||
MavenEmbedder embedder = new ExtendableMavenEmbedder( classLoader );
|
|
||||||
|
|
||||||
// Here we take the artifact handler and programmatically place it into the container
|
|
||||||
|
|
||||||
ComponentDescriptor cd = new ComponentDescriptor();
|
|
||||||
|
|
||||||
cd.setRole( ArtifactHandler.ROLE );
|
|
||||||
|
|
||||||
cd.setRoleHint( "mkleint" );
|
|
||||||
|
|
||||||
cd.setImplementation( MyArtifactHandler.class.getName() );
|
|
||||||
|
|
||||||
embedder.getPlexusContainer().addComponentDescriptor( cd );
|
|
||||||
|
|
||||||
// At this point the artifact handler will be inside the container and
|
|
||||||
// Maven internally will pick up the artifact handler and use it accordingly to
|
|
||||||
// create the classpath appropriately.
|
|
||||||
|
|
||||||
MavenExecutionResult result = embedder.readProjectWithDependencies( request );
|
|
||||||
|
|
||||||
assertNoExceptions( result );
|
|
||||||
|
|
||||||
// sources, test sources, and the junit jar..
|
|
||||||
|
|
||||||
assertEquals( 3, result.getProject().getTestClasspathElements().size() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ExtendableMavenEmbedder
|
|
||||||
extends MavenEmbedder
|
|
||||||
{
|
|
||||||
|
|
||||||
public ExtendableMavenEmbedder( ClassLoader classLoader )
|
|
||||||
throws MavenEmbedderException
|
|
||||||
{
|
|
||||||
super( new SimpleConfiguration().setClassLoader( classLoader ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Map<String, ArtifactHandler> getPluginExtensionComponents( Plugin plugin )
|
|
||||||
throws PluginManagerException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getPlexusContainer().lookupMap( ArtifactHandler.class );
|
|
||||||
}
|
|
||||||
catch ( ComponentLookupException e )
|
|
||||||
{
|
|
||||||
throw new PluginManagerException( plugin, null );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void verifyPlugin( Plugin plugin,
|
|
||||||
MavenProject project )
|
|
||||||
{
|
|
||||||
//ignore don't want to actually verify in test
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -23,10 +23,8 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -57,7 +55,6 @@ public class MavenEmbedderTest
|
||||||
|
|
||||||
protected MavenEmbedder mavenEmbedder;
|
protected MavenEmbedder mavenEmbedder;
|
||||||
|
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -321,11 +318,13 @@ public class MavenEmbedderTest
|
||||||
// Repository
|
// Repository
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
public void testLocalRepositoryRetrieval()
|
public void testLocalRepositoryRetrieval()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
assertNotNull( mavenEmbedder.getLocalRepository().getBasedir() );
|
assertNotNull( mavenEmbedder.getLocalRepository().getBasedir() );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Model Reading
|
// Model Reading
|
||||||
|
@ -343,79 +342,6 @@ public class MavenEmbedderTest
|
||||||
assertEquals( "org.apache.maven", model.getGroupId() );
|
assertEquals( "org.apache.maven", model.getGroupId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testProjectReading()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true ).setPom( getPomFile() );
|
|
||||||
|
|
||||||
MavenExecutionResult result = mavenEmbedder.readProjectWithDependencies( request );
|
|
||||||
|
|
||||||
assertNoExceptions( result );
|
|
||||||
|
|
||||||
assertEquals( "org.apache.maven", result.getProject().getGroupId() );
|
|
||||||
|
|
||||||
Set<Artifact> artifacts = result.getProject().getArtifacts();
|
|
||||||
|
|
||||||
assertEquals( 1, artifacts.size() );
|
|
||||||
|
|
||||||
artifacts.iterator().next();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testProjectReadingNoDependencies()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
MavenExecutionRequest request =
|
|
||||||
new DefaultMavenExecutionRequest().setShowErrors( true ).setPom(
|
|
||||||
getPomFile( "pom-without-dependencies.xml" ) );
|
|
||||||
|
|
||||||
MavenExecutionResult result = mavenEmbedder.readProjectWithDependencies( request );
|
|
||||||
|
|
||||||
assertNoExceptions( result );
|
|
||||||
|
|
||||||
assertEquals( new ArrayList<Artifact>(), new ArrayList<Artifact>( result.getProject().getArtifacts() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testProjectReading_FromChildLevel_ScmInheritanceCalculations()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
File pomFile = new File( basedir, "src/test/projects/readProject-withScmInheritance/modules/child1/pom.xml" );
|
|
||||||
|
|
||||||
MavenProject project = mavenEmbedder.readProject( pomFile );
|
|
||||||
assertNotNull(project.getScm());
|
|
||||||
assertEquals( "http://host/viewer?path=/trunk/parent/modules/child1", project.getScm().getUrl() );
|
|
||||||
assertEquals( "scm:svn:http://host/trunk/parent/modules/child1", project.getScm().getConnection() );
|
|
||||||
assertEquals( "scm:svn:https://host/trunk/parent/modules/child1", project.getScm().getDeveloperConnection() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testProjectReading_SkipMissingModuleSilently()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
File pomFile = new File( basedir,
|
|
||||||
"src/test/projects/readProject-missingModuleIgnored/pom.xml" );
|
|
||||||
|
|
||||||
mavenEmbedder.readProject( pomFile );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testProjectReadingWithDistributionStatus()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
File pom = new File( basedir, "src/test/resources/pom-with-distribution-status.xml" );
|
|
||||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
|
|
||||||
.setPom( pom );
|
|
||||||
|
|
||||||
MavenProject project = mavenEmbedder.readProject( pom );
|
|
||||||
|
|
||||||
assertEquals( "deployed", project.getDistributionManagement().getStatus() );
|
|
||||||
|
|
||||||
MavenExecutionResult result = mavenEmbedder.readProjectWithDependencies( request );
|
|
||||||
|
|
||||||
assertNoExceptions( result );
|
|
||||||
|
|
||||||
assertEquals( "org.apache.maven", result.getProject().getGroupId() );
|
|
||||||
|
|
||||||
assertEquals( "deployed", result.getProject().getDistributionManagement().getStatus() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Model Writing
|
// Model Writing
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package org.apache.maven.embedder.execution;
|
|
||||||
|
|
||||||
import org.apache.maven.embedder.DefaultConfiguration;
|
|
||||||
import org.apache.maven.embedder.MavenEmbedderException;
|
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
|
||||||
|
|
||||||
public class DefaultMavenExecutionRequestPopulatorTest
|
|
||||||
extends PlexusTestCase
|
|
||||||
{
|
|
||||||
private MavenExecutionRequestPopulator populator;
|
|
||||||
|
|
||||||
public void setUp()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
populator = (MavenExecutionRequestPopulator) lookup( MavenExecutionRequestPopulator.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tearDown() throws Exception {
|
|
||||||
populator = null;
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testWagonManagerOfflineFlagIsPopulatedFromSettings()
|
|
||||||
throws MavenEmbedderException
|
|
||||||
{
|
|
||||||
MavenExecutionRequest req = new DefaultMavenExecutionRequest().setOffline( true );
|
|
||||||
|
|
||||||
populator.populateDefaults( req, new DefaultConfiguration() );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package org.apache.maven.embedder.project;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.apache.maven.embedder.Configuration;
|
|
||||||
import org.apache.maven.embedder.MavenEmbedder;
|
|
||||||
import org.apache.maven.embedder.SimpleConfiguration;
|
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|
||||||
import org.apache.maven.execution.MavenExecutionResult;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
|
||||||
|
|
||||||
public class BadModuleNotRecursiveTest
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
public void test()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Configuration configuration = new SimpleConfiguration();
|
|
||||||
MavenEmbedder embedder = new MavenEmbedder( configuration );
|
|
||||||
|
|
||||||
File pom = new File( "src/test/projects/bad-module-non-recursive/pom.xml" ).getCanonicalFile();
|
|
||||||
|
|
||||||
System.out.println( pom.getCanonicalFile() );
|
|
||||||
|
|
||||||
DefaultMavenExecutionRequest request = new DefaultMavenExecutionRequest();
|
|
||||||
request.setOffline( false );
|
|
||||||
request.setUseReactor( false );
|
|
||||||
request.setRecursive( false );
|
|
||||||
//request.setLoggingLevel( Logger.LEVEL_DEBUG );
|
|
||||||
request.setPom( pom );
|
|
||||||
request.setBaseDirectory( pom.getParentFile() );
|
|
||||||
MavenExecutionResult result = embedder.readProjectWithDependencies( request );
|
|
||||||
MavenProject project = result.getProject();
|
|
||||||
|
|
||||||
if ( result.hasExceptions() )
|
|
||||||
{
|
|
||||||
for ( Exception e : result.getExceptions() )
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertNotNull( project );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -53,7 +53,7 @@ public class MavenEmbedderCrappySettingsConfigurationTest
|
||||||
|
|
||||||
MavenEmbedder embedder = new MavenEmbedder( configuration );
|
MavenEmbedder embedder = new MavenEmbedder( configuration );
|
||||||
|
|
||||||
assertNotNull( embedder.getLocalRepository().getBasedir() );
|
//assertNotNull( embedder.getLocalRepository().getBasedir() );
|
||||||
|
|
||||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
||||||
.setBaseDirectory( projectDirectory )
|
.setBaseDirectory( projectDirectory )
|
||||||
|
|
Loading…
Reference in New Issue