mirror of https://github.com/apache/maven.git
transitive deps in mboot. Will now proceed to trim up the POMs. Still need to trim ~/maven2/lib also.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163764 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ccbd046a7
commit
2e3e41fddf
|
@ -169,6 +169,13 @@ public class SnapshotArtifactMetadata
|
||||||
String version = FileUtils.fileRead( file );
|
String version = FileUtils.fileRead( file );
|
||||||
lastModified = file.lastModified();
|
lastModified = file.lastModified();
|
||||||
|
|
||||||
|
/* TODO: try this
|
||||||
|
if( version.matches( "/^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$/" ))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int index = version.lastIndexOf( "-" );
|
int index = version.lastIndexOf( "-" );
|
||||||
if ( version.indexOf( "SNAPSHOT" ) >= 0 || index < 0 )
|
if ( version.indexOf( "SNAPSHOT" ) >= 0 || index < 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
<artifactId>plexus-marmalade-factory</artifactId>
|
<artifactId>plexus-marmalade-factory</artifactId>
|
||||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
<version>1.0-alpha-2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>marmalade</groupId>
|
<groupId>marmalade</groupId>
|
||||||
<artifactId>marmalade-core</artifactId>
|
<artifactId>marmalade-core</artifactId>
|
||||||
<version>1.0-alpha2-SNAPSHOT</version>
|
<version>1.0-alpha2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -11,24 +11,6 @@
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<description>Tool used to bootstrap m2.</description>
|
<description>Tool used to bootstrap m2.</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.modello</groupId>
|
|
||||||
<artifactId>modello-core</artifactId>
|
|
||||||
<version>1.0-alpha-1</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.modello</groupId>
|
|
||||||
<artifactId>modello-xdoc-plugin</artifactId>
|
|
||||||
<version>1.0-alpha-1</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.modello</groupId>
|
|
||||||
<artifactId>modello-xml-plugin</artifactId>
|
|
||||||
<version>1.0-alpha-1</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.modello</groupId>
|
<groupId>org.codehaus.modello</groupId>
|
||||||
<artifactId>modello-xpp3-plugin</artifactId>
|
<artifactId>modello-xpp3-plugin</artifactId>
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -242,11 +243,9 @@ public class MBoot
|
||||||
|
|
||||||
Repository localRepository = new Repository( mavenRepoLocal, Repository.LAYOUT_DEFAULT );
|
Repository localRepository = new Repository( mavenRepoLocal, Repository.LAYOUT_DEFAULT );
|
||||||
|
|
||||||
ModelReader reader = new ModelReader( localRepository );
|
|
||||||
|
|
||||||
if ( online )
|
if ( online )
|
||||||
{
|
{
|
||||||
downloader = new ArtifactDownloader( localRepository, reader.getRemoteRepositories() );
|
downloader = new ArtifactDownloader( localRepository, Collections.EMPTY_LIST );
|
||||||
if ( userModelReader.getActiveProxy() != null )
|
if ( userModelReader.getActiveProxy() != null )
|
||||||
{
|
{
|
||||||
Proxy proxy = userModelReader.getActiveProxy();
|
Proxy proxy = userModelReader.getActiveProxy();
|
||||||
|
@ -271,14 +270,14 @@ public class MBoot
|
||||||
// Install it-support POM
|
// Install it-support POM
|
||||||
installPomFile( localRepository, new File( basedir, "maven-core-it-support/pom.xml" ) );
|
installPomFile( localRepository, new File( basedir, "maven-core-it-support/pom.xml" ) );
|
||||||
|
|
||||||
reader = new ModelReader( localRepository );
|
ModelReader reader = new ModelReader( downloader, true );
|
||||||
|
|
||||||
reader.parse( new File( basedir, "maven-mboot2/pom.xml" ) );
|
reader.parse( new File( basedir, "maven-mboot2/pom.xml" ) );
|
||||||
|
|
||||||
ClassLoader bootstrapClassLoader = createClassloaderFromDependencies( reader.getDependencies(), null,
|
ClassLoader bootstrapClassLoader = createClassloaderFromDependencies( reader.getDependencies(), null,
|
||||||
localRepository );
|
localRepository );
|
||||||
|
|
||||||
reader = new ModelReader( localRepository );
|
reader = new ModelReader( downloader, true );
|
||||||
reader.parse( new File( basedir, "maven-plugins/maven-surefire-plugin/pom.xml" ) );
|
reader.parse( new File( basedir, "maven-plugins/maven-surefire-plugin/pom.xml" ) );
|
||||||
List surefireDependencies = new ArrayList();
|
List surefireDependencies = new ArrayList();
|
||||||
|
|
||||||
|
@ -297,9 +296,9 @@ public class MBoot
|
||||||
downloader.downloadDependencies( surefireDependencies );
|
downloader.downloadDependencies( surefireDependencies );
|
||||||
}
|
}
|
||||||
|
|
||||||
reader = new ModelReader( localRepository );
|
reader = new ModelReader( downloader, true );
|
||||||
|
|
||||||
List coreDeps = null;
|
Collection coreDeps = null;
|
||||||
Dependency corePom = null;
|
Dependency corePom = null;
|
||||||
|
|
||||||
for ( int i = 0; i < builds.length; i++ )
|
for ( int i = 0; i < builds.length; i++ )
|
||||||
|
@ -324,7 +323,7 @@ public class MBoot
|
||||||
System.out.println( "--------------------------------------------------------------------" );
|
System.out.println( "--------------------------------------------------------------------" );
|
||||||
}
|
}
|
||||||
|
|
||||||
reader = new ModelReader( localRepository );
|
reader = new ModelReader( downloader, true );
|
||||||
reader.parse( new File( basedir, "maven-plugin-tools/maven-plugin-tools-pluggy/pom.xml" ) );
|
reader.parse( new File( basedir, "maven-plugin-tools/maven-plugin-tools-pluggy/pom.xml" ) );
|
||||||
List dependencies = new ArrayList( reader.getDependencies() );
|
List dependencies = new ArrayList( reader.getDependencies() );
|
||||||
dependencies.add(
|
dependencies.add(
|
||||||
|
@ -394,6 +393,7 @@ public class MBoot
|
||||||
// lib
|
// lib
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// TODO: check this - we are transitively including in /lib...
|
||||||
File lib = new File( dist, "lib" );
|
File lib = new File( dist, "lib" );
|
||||||
|
|
||||||
lib.mkdirs();
|
lib.mkdirs();
|
||||||
|
@ -411,8 +411,9 @@ public class MBoot
|
||||||
{
|
{
|
||||||
FileUtils.copyFileToDirectory( source, core );
|
FileUtils.copyFileToDirectory( source, core );
|
||||||
}
|
}
|
||||||
else
|
else if ( !d.getScope().equals( SCOPE_TEST ) && !d.getArtifactId().equals( "plexus-utils" ) )
|
||||||
{
|
{
|
||||||
|
// only compile and runtime
|
||||||
FileUtils.copyFileToDirectory( source, lib );
|
FileUtils.copyFileToDirectory( source, lib );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,7 +466,7 @@ public class MBoot
|
||||||
{
|
{
|
||||||
System.out.println( "Building project in " + basedir );
|
System.out.println( "Building project in " + basedir );
|
||||||
|
|
||||||
ModelReader reader = new ModelReader( localRepository );
|
ModelReader reader = new ModelReader( downloader, true );
|
||||||
|
|
||||||
reader.parse( new File( basedir, "pom.xml" ) );
|
reader.parse( new File( basedir, "pom.xml" ) );
|
||||||
|
|
||||||
|
@ -483,8 +484,6 @@ public class MBoot
|
||||||
|
|
||||||
String generatedSources = new File( basedir, GENERATED_SOURCES ).getAbsolutePath();
|
String generatedSources = new File( basedir, GENERATED_SOURCES ).getAbsolutePath();
|
||||||
|
|
||||||
String generatedDocs = new File( basedir, GENERATED_DOCS ).getAbsolutePath();
|
|
||||||
|
|
||||||
File buildDirFile = new File( basedir, BUILD_DIR );
|
File buildDirFile = new File( basedir, BUILD_DIR );
|
||||||
String buildDir = buildDirFile.getAbsolutePath();
|
String buildDir = buildDirFile.getAbsolutePath();
|
||||||
|
|
||||||
|
@ -546,7 +545,6 @@ public class MBoot
|
||||||
classLoader );
|
classLoader );
|
||||||
generateSources( model.getAbsolutePath(), "xpp3-writer", generatedSources, modelVersion, "false",
|
generateSources( model.getAbsolutePath(), "xpp3-writer", generatedSources, modelVersion, "false",
|
||||||
classLoader );
|
classLoader );
|
||||||
generateSources( model.getAbsolutePath(), "xdoc", generatedDocs, modelVersion, "false", classLoader );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -591,7 +589,7 @@ public class MBoot
|
||||||
|
|
||||||
System.out.println( "Compiling test sources ..." );
|
System.out.println( "Compiling test sources ..." );
|
||||||
|
|
||||||
List testDependencies = reader.getDependencies();
|
Collection testDependencies = reader.getDependencies();
|
||||||
|
|
||||||
compile( testDependencies, testSources, testClasses, classes, null, SCOPE_TEST, localRepository );
|
compile( testDependencies, testSources, testClasses, classes, null, SCOPE_TEST, localRepository );
|
||||||
|
|
||||||
|
@ -666,7 +664,7 @@ public class MBoot
|
||||||
Thread.currentThread().setContextClassLoader( old );
|
Thread.currentThread().setContextClassLoader( old );
|
||||||
}
|
}
|
||||||
|
|
||||||
private IsolatedClassLoader createClassloaderFromDependencies( List dependencies, ClassLoader parent,
|
private IsolatedClassLoader createClassloaderFromDependencies( Collection dependencies, ClassLoader parent,
|
||||||
Repository localRepository )
|
Repository localRepository )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -719,7 +717,7 @@ public class MBoot
|
||||||
private void installPomFile( Repository localRepository, File pomIn )
|
private void installPomFile( Repository localRepository, File pomIn )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
ModelReader reader = new ModelReader( localRepository );
|
ModelReader reader = new ModelReader( downloader, false );
|
||||||
|
|
||||||
reader.parse( pomIn );
|
reader.parse( pomIn );
|
||||||
|
|
||||||
|
@ -814,13 +812,13 @@ public class MBoot
|
||||||
// Compile
|
// Compile
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private List classpath( List dependencies, String extraClasspath, String scope, Repository localRepository )
|
private List classpath( Collection dependencies, String extraClasspath, String scope, Repository localRepository )
|
||||||
{
|
{
|
||||||
List classpath = new ArrayList( dependencies.size() + 1 );
|
List classpath = new ArrayList( dependencies.size() + 1 );
|
||||||
|
|
||||||
for ( int i = 0; i < dependencies.size(); i++ )
|
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Dependency d = (Dependency) dependencies.get( i );
|
Dependency d = (Dependency) i.next();
|
||||||
|
|
||||||
String element = localRepository.getArtifactFile( d ).getAbsolutePath();
|
String element = localRepository.getArtifactFile( d ).getAbsolutePath();
|
||||||
|
|
||||||
|
@ -849,8 +847,8 @@ public class MBoot
|
||||||
return classpath;
|
return classpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compile( List dependencies, String sourceDirectory, String outputDirectory, String extraClasspath,
|
private void compile( Collection dependencies, String sourceDirectory, String outputDirectory,
|
||||||
String generatedSources, String scope, Repository localRepository )
|
String extraClasspath, String generatedSources, String scope, Repository localRepository )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
JavacCompiler compiler = new JavacCompiler();
|
JavacCompiler compiler = new JavacCompiler();
|
||||||
|
@ -874,7 +872,6 @@ public class MBoot
|
||||||
{
|
{
|
||||||
if ( new File( sourceDirectory ).exists() )
|
if ( new File( sourceDirectory ).exists() )
|
||||||
{
|
{
|
||||||
|
|
||||||
sourceDirectories = new String[]{sourceDirectory};
|
sourceDirectories = new String[]{sourceDirectory};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -882,7 +879,6 @@ public class MBoot
|
||||||
if ( sourceDirectories != null )
|
if ( sourceDirectories != null )
|
||||||
{
|
{
|
||||||
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
||||||
|
|
||||||
compilerConfiguration.setOutputLocation( outputDirectory );
|
compilerConfiguration.setOutputLocation( outputDirectory );
|
||||||
compilerConfiguration.setClasspathEntries(
|
compilerConfiguration.setClasspathEntries(
|
||||||
classpath( dependencies, extraClasspath, scope, localRepository ) );
|
classpath( dependencies, extraClasspath, scope, localRepository ) );
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class ArtifactDownloader
|
public class ArtifactDownloader
|
||||||
{
|
{
|
||||||
|
@ -60,14 +61,14 @@ public class ArtifactDownloader
|
||||||
System.out.println( "Using the following proxy : " + proxyHost + "/" + proxyPort );
|
System.out.println( "Using the following proxy : " + proxyHost + "/" + proxyPort );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadDependencies( List dependencies )
|
public void downloadDependencies( Collection dependencies )
|
||||||
throws Exception
|
throws DownloadFailedException
|
||||||
{
|
{
|
||||||
for ( Iterator j = dependencies.iterator(); j.hasNext(); )
|
for ( Iterator j = dependencies.iterator(); j.hasNext(); )
|
||||||
{
|
{
|
||||||
Dependency dep = (Dependency) j.next();
|
Dependency dep = (Dependency) j.next();
|
||||||
|
|
||||||
if ( !downloadedArtifacts.contains( dep.getId() ) )
|
if ( !downloadedArtifacts.contains( dep ) )
|
||||||
{
|
{
|
||||||
File destinationFile = localRepository.getArtifactFile( dep );
|
File destinationFile = localRepository.getArtifactFile( dep );
|
||||||
// The directory structure for this project may
|
// The directory structure for this project may
|
||||||
|
@ -94,10 +95,10 @@ public class ArtifactDownloader
|
||||||
|
|
||||||
if ( !destinationFile.exists() )
|
if ( !destinationFile.exists() )
|
||||||
{
|
{
|
||||||
throw new Exception( "Failed to download " + dep );
|
throw new DownloadFailedException( "Failed to download " + dep );
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadedArtifacts.add( dep.getId() );
|
downloadedArtifacts.add( dep );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,4 +210,9 @@ public class ArtifactDownloader
|
||||||
{
|
{
|
||||||
System.out.println( message );
|
System.out.println( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Repository getLocalRepository()
|
||||||
|
{
|
||||||
|
return localRepository;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package download;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Failed download.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DownloadFailedException extends Exception
|
||||||
|
{
|
||||||
|
public DownloadFailedException( String message )
|
||||||
|
{
|
||||||
|
super( message );
|
||||||
|
}
|
||||||
|
}
|
|
@ -199,4 +199,52 @@ public class Dependency
|
||||||
{
|
{
|
||||||
return getId() + ":" + getVersion() + ":" + getType();
|
return getId() + ":" + getVersion() + ":" + getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int result = 17;
|
||||||
|
result = 37 * result + groupId.hashCode();
|
||||||
|
result = 37 * result + artifactId.hashCode();
|
||||||
|
result = 37 * result + type.hashCode();
|
||||||
|
result = 37 * result + version.hashCode();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals( Object o )
|
||||||
|
{
|
||||||
|
if ( o == this )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !( o instanceof Dependency ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dependency d = (Dependency) o;
|
||||||
|
|
||||||
|
if ( !d.getGroupId().equals( groupId ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ( !d.getArtifactId().equals( artifactId ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ( !d.getVersion().equals( version ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ( !d.getType().equals( type ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConflictId()
|
||||||
|
{
|
||||||
|
return getGroupId() + ":" + getArtifactId() + ":" + getType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ package model;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import download.ArtifactDownloader;
|
||||||
|
import download.DownloadFailedException;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import util.AbstractReader;
|
import util.AbstractReader;
|
||||||
|
@ -23,7 +25,14 @@ import util.AbstractReader;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a POM.
|
* Parse a POM.
|
||||||
|
@ -49,7 +58,7 @@ public class ModelReader
|
||||||
|
|
||||||
private String parentVersion;
|
private String parentVersion;
|
||||||
|
|
||||||
private List dependencies = new ArrayList();
|
private Map dependencies = new HashMap();
|
||||||
|
|
||||||
private List repositories = new ArrayList();
|
private List repositories = new ArrayList();
|
||||||
|
|
||||||
|
@ -71,13 +80,23 @@ public class ModelReader
|
||||||
|
|
||||||
private StringBuffer bodyText = new StringBuffer();
|
private StringBuffer bodyText = new StringBuffer();
|
||||||
|
|
||||||
private final Repository localRepository;
|
private final boolean resolveTransitiveDependencies;
|
||||||
|
|
||||||
private Repository currentRepository;
|
private Repository currentRepository;
|
||||||
|
|
||||||
public ModelReader( Repository downloader )
|
private final ArtifactDownloader downloader;
|
||||||
|
|
||||||
|
private static Set inProgress = new HashSet();
|
||||||
|
|
||||||
|
private Map parentDependencies = new HashMap();
|
||||||
|
|
||||||
|
private Map transitiveDependencies = new HashMap();
|
||||||
|
|
||||||
|
public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies )
|
||||||
{
|
{
|
||||||
this.localRepository = downloader;
|
this.downloader = downloader;
|
||||||
|
|
||||||
|
this.resolveTransitiveDependencies = resolveTransitiveDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getRemoteRepositories()
|
public List getRemoteRepositories()
|
||||||
|
@ -85,9 +104,13 @@ public class ModelReader
|
||||||
return repositories;
|
return repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDependencies()
|
public Collection getDependencies()
|
||||||
{
|
{
|
||||||
return dependencies;
|
Map m = new HashMap();
|
||||||
|
m.putAll( transitiveDependencies );
|
||||||
|
m.putAll( parentDependencies );
|
||||||
|
m.putAll( dependencies );
|
||||||
|
return m.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getResources()
|
public List getResources()
|
||||||
|
@ -169,22 +192,10 @@ public class ModelReader
|
||||||
version = parentVersion;
|
version = parentVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelReader p = new ModelReader( localRepository );
|
// actually, these should be transtive (see MNG-77) - but some projects have circular deps that way (marmalade, and currently m2)
|
||||||
|
ModelReader p = retrievePom( parentGroupId, parentArtifactId, parentVersion, false );
|
||||||
|
|
||||||
try
|
addDependencies( p.getDependencies(), parentDependencies );
|
||||||
{
|
|
||||||
p.parse( localRepository.getArtifactFile( parentGroupId, parentArtifactId, parentVersion, "pom" ) );
|
|
||||||
}
|
|
||||||
catch ( ParserConfigurationException e )
|
|
||||||
{
|
|
||||||
throw new SAXException( "Error getting parent POM", e );
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new SAXException( "Error getting parent POM", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies.addAll( p.getDependencies() );
|
|
||||||
|
|
||||||
resources.addAll( p.getResources() );
|
resources.addAll( p.getResources() );
|
||||||
|
|
||||||
|
@ -192,9 +203,19 @@ public class ModelReader
|
||||||
}
|
}
|
||||||
else if ( rawName.equals( "dependency" ) )
|
else if ( rawName.equals( "dependency" ) )
|
||||||
{
|
{
|
||||||
dependencies.add( currentDependency );
|
|
||||||
|
|
||||||
insideDependency = false;
|
insideDependency = false;
|
||||||
|
|
||||||
|
if ( !hasDependency( currentDependency, dependencies ) )
|
||||||
|
{
|
||||||
|
if ( resolveTransitiveDependencies )
|
||||||
|
{
|
||||||
|
ModelReader p = retrievePom( currentDependency.getGroupId(), currentDependency.getArtifactId(),
|
||||||
|
currentDependency.getVersion(), resolveTransitiveDependencies );
|
||||||
|
|
||||||
|
addDependencies( p.getDependencies(), transitiveDependencies );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies.put( currentDependency.getConflictId(), currentDependency );
|
||||||
}
|
}
|
||||||
else if ( rawName.equals( "resource" ) )
|
else if ( rawName.equals( "resource" ) )
|
||||||
{
|
{
|
||||||
|
@ -311,6 +332,79 @@ public class ModelReader
|
||||||
depth--;
|
depth--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addDependencies( Collection dependencies, Map target )
|
||||||
|
{
|
||||||
|
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency d = (Dependency) i.next();
|
||||||
|
|
||||||
|
if ( !hasDependency( d, target ) )
|
||||||
|
{
|
||||||
|
target.put( d.getConflictId(), d );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasDependency( Dependency d, Map dependencies )
|
||||||
|
{
|
||||||
|
String conflictId = d.getConflictId();
|
||||||
|
if ( dependencies.containsKey( conflictId ) )
|
||||||
|
{
|
||||||
|
// We only care about pushing in compile scope dependencies I think
|
||||||
|
// if not, we'll need to be able to get the original and pick the appropriate scope
|
||||||
|
if ( d.getScope().equals( "compile" ) )
|
||||||
|
{
|
||||||
|
dependencies.remove( conflictId );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModelReader retrievePom( String groupId, String artifactId, String version,
|
||||||
|
boolean resolveTransitiveDependencies )
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
String key = groupId + ":" + artifactId + ":" + version;
|
||||||
|
|
||||||
|
if ( inProgress.contains( key ) )
|
||||||
|
{
|
||||||
|
throw new SAXException( "Circular dependency found, looking for " + key + "\nIn progress:" + inProgress );
|
||||||
|
}
|
||||||
|
|
||||||
|
inProgress.add( key );
|
||||||
|
|
||||||
|
ModelReader p = new ModelReader( downloader, resolveTransitiveDependencies );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Dependency pom = new Dependency( groupId, artifactId, version, "pom" );
|
||||||
|
downloader.downloadDependencies( Collections.singletonList( pom ) );
|
||||||
|
|
||||||
|
Repository localRepository = downloader.getLocalRepository();
|
||||||
|
p.parse( localRepository.getArtifactFile( pom ) );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new SAXException( "Error getting parent POM", e );
|
||||||
|
}
|
||||||
|
catch ( ParserConfigurationException e )
|
||||||
|
{
|
||||||
|
throw new SAXException( "Error getting parent POM", e );
|
||||||
|
}
|
||||||
|
catch ( DownloadFailedException e )
|
||||||
|
{
|
||||||
|
throw new SAXException( "Error getting parent POM", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
inProgress.remove( key );
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
public String getArtifactId()
|
public String getArtifactId()
|
||||||
{
|
{
|
||||||
return artifactId;
|
return artifactId;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package util;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
import org.xml.sax.ext.LexicalHandler;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
@ -27,6 +28,10 @@ import javax.xml.parsers.SAXParserFactory;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an XML file.
|
* Parse an XML file.
|
||||||
|
@ -45,7 +50,13 @@ public abstract class AbstractReader
|
||||||
|
|
||||||
SAXParser parser = saxFactory.newSAXParser();
|
SAXParser parser = saxFactory.newSAXParser();
|
||||||
|
|
||||||
InputSource is = new InputSource( new FileInputStream( file ) );
|
// Cheap and cheerful. Please add more to skip if the parser chokes (or use the actual
|
||||||
|
StringWriter output = new StringWriter();
|
||||||
|
IOUtil.copy( new FileReader( file ), output);
|
||||||
|
String out = output.toString();
|
||||||
|
out = StringUtils.replace( out, "ø", "\u00f8" );
|
||||||
|
|
||||||
|
InputSource is = new InputSource( new StringReader( out ) );
|
||||||
|
|
||||||
parser.parse( is, this );
|
parser.parse( is, this );
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>marmalade</groupId>
|
<groupId>marmalade</groupId>
|
||||||
<artifactId>marmalade-core</artifactId>
|
<artifactId>marmalade-core</artifactId>
|
||||||
<version>1.0-alpha2-SNAPSHOT</version>
|
<version>1.0-alpha2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
<artifactId>plexus-marmalade-factory</artifactId>
|
<artifactId>plexus-marmalade-factory</artifactId>
|
||||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
<version>1.0-alpha-2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
<name>Maven Plugin</name>
|
<name>Maven Plugin</name>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>plexus</groupId>
|
||||||
|
<artifactId>plexus-container-default</artifactId>
|
||||||
|
<version>1.0-alpha-2</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-monitor</artifactId>
|
<artifactId>maven-monitor</artifactId>
|
||||||
|
|
|
@ -28,14 +28,14 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>marmalade</groupId>
|
<groupId>marmalade</groupId>
|
||||||
<artifactId>marmalade-core</artifactId>
|
<artifactId>marmalade-core</artifactId>
|
||||||
<version>1.0-alpha2-SNAPSHOT</version>
|
<version>1.0-alpha2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
<artifactId>plexus-marmalade-factory</artifactId>
|
<artifactId>plexus-marmalade-factory</artifactId>
|
||||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
<version>1.0-alpha-2</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
<artifactId>maven-settings</artifactId>
|
<artifactId>maven-settings</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<name>Maven Local Settings Model</name>
|
<name>Maven Local Settings Model</name>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
<version>1.0-alpha-2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
Loading…
Reference in New Issue