*
* @return The new repository system session, never {@code null}.
*/
public static DefaultRepositorySystemSession newSession()
{
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
DependencyTraverser depTraverser = new FatArtifactTraverser();
session.setDependencyTraverser( depTraverser );
DependencyManager depManager = new ClassicDependencyManager();
session.setDependencyManager( depManager );
DependencySelector depFilter =
new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
new OptionalDependencySelector(), new ExclusionDependencySelector() );
session.setDependencySelector( depFilter );
DependencyGraphTransformer transformer =
new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(),
new SimpleOptionalitySelector(), new JavaScopeDeriver() );
new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() );
session.setDependencyGraphTransformer( transformer );
DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
stereotypes.add( new DefaultArtifactType( "pom" ) );
stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) );
stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) );
stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) );
stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) );
stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) );
stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) );
stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) );
stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) );
stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) );
stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) );
stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) );
session.setArtifactTypeRegistry( stereotypes );
session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) );
Properties sysProps = System.getProperties();
session.setSystemProperties( sysProps );
session.setConfigProperties( sysProps );
return session;
}