import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.repository.ArtifactUtils;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.repository.ArtifactUtils;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
*
* @author John Casey
* @author Brett Porter
- * @plexus.component role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="default" instantiation-strategy="per-lookup"
+ * @plexus.component role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="org.apache.maven.repository.discovery.DefaultArtifactDiscoverer"
*/
public class DefaultArtifactDiscoverer
extends AbstractArtifactDiscoverer
try
{
Model model = mavenReader.read( new FileReader( filename ) );
- if ( ( pomArtifact != null ) && ( "pom".equals( model.getPackaging() ) ) )
+ if ( ( model != null ) && ( "pom".equals( model.getPackaging() ) ) )
+ {
+ artifacts.add( model );
+ }
+ /*if ( ( pomArtifact != null ) && ( "pom".equals( model.getPackaging() ) ) )
{
if ( convertSnapshots || !pomArtifact.isSnapshot() )
{
artifacts.add( pomArtifact );
}
}
+ */
}
catch ( Exception e )
{
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
-import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
/**
* This class gets all the paths that contain the metadata files.
*
- * @plexus.component role="org.apache.maven.repository.discovery.MetadataDiscoverer" role-hint="default" instantiation-strategy="per-lookup"
+ * @plexus.component role="org.apache.maven.repository.discovery.MetadataDiscoverer" role-hint="org.apache.maven.repository.discovery.DefaultMetadataDiscoverer"
*/
public class DefaultMetadataDiscoverer
extends AbstractArtifactDiscoverer
implements MetadataDiscoverer
{
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactFactory artifactFactory;
+
/**
* Standard patterns to include in discovery of metadata files.
*/
Iterator it = pathParts.iterator();
String tmpDir = (String) it.next();
- ArtifactHandler handler = new DefaultArtifactHandler( "jar" );
- VersionRange version = VersionRange.createFromVersion( metaVersion );
- Artifact artifact =
- new DefaultArtifact( metaGroupId, metaArtifactId, version, "compile", "jar", "", handler );
+ //ArtifactHandler handler = new DefaultArtifactHandler( "jar" );
+ //if( metaVersion != null && !metaVersion.equals( "" ) )
+ //{
+ // VersionRange version = VersionRange.createFromVersion( metaVersion );
+ //}
+
+ Artifact artifact = null;
+ if ( metaVersion != null && !metaVersion.equals( "" ) )
+ {
+ artifact = artifactFactory.createBuildArtifact( metaGroupId, metaArtifactId, metaVersion, "jar" );
+ }
// snapshotMetadata
- if ( tmpDir.equals( metaVersion ) )
+ if ( tmpDir != null && tmpDir.equals( metaVersion ) )
{
- metadata = new SnapshotArtifactRepositoryMetadata( artifact );
+ if ( artifact != null )
+ {
+ metadata = new SnapshotArtifactRepositoryMetadata( artifact );
+ }
}
- else if ( tmpDir.equals( metaArtifactId ) )
+ else if ( tmpDir != null && tmpDir.equals( metaArtifactId ) )
{
// artifactMetadata
- metadata = new ArtifactRepositoryMetadata( artifact );
+ if ( artifact != null )
+ {
+ metadata = new ArtifactRepositoryMetadata( artifact );
+ }
}
else
{
}
// groupMetadata
- if ( metaGroupId.equals( groupDir ) )
+ if ( metaGroupId != null && metaGroupId.equals( groupDir ) )
{
metadata = new GroupRepositoryMetadata( metaGroupId );
}
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
*
* @author John Casey
* @author Brett Porter
- * @plexus.component role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="legacy" instantiation-strategy="per-lookup"
+ * @plexus.component role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="org.apache.maven.repository.discovery.LegacyArtifactDiscoverer"
*/
public class LegacyArtifactDiscoverer
extends AbstractArtifactDiscoverer
implements ArtifactDiscoverer
{
private final static String POM = ".pom";
+
private final static String DELIM = "\\";
/**
return artifacts;
}
- public List discoverStandalonePoms( ArtifactRepository repository, String blacklistedPatterns, boolean convertSnapshots )
+ public List discoverStandalonePoms( ArtifactRepository repository, String blacklistedPatterns,
+ boolean convertSnapshots )
{
List artifacts = new ArrayList();
try
{
Model model = mavenReader.read( new FileReader( filename ) );
- if ( ( pomArtifact != null ) && ( "pom".equals(model.getPackaging()) ) )
+ if ( ( pomArtifact != null ) && ( "pom".equals( model.getPackaging() ) ) )
{
if ( convertSnapshots || !pomArtifact.isSnapshot() )
{
}
}
}
- catch (Exception e)
+ catch ( Exception e )
{
- System.out.println( "error reading file: " + filename );
+ System.out.println( "error reading file: " + filename );
e.printStackTrace();
}
}
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.model.Model;
import org.codehaus.plexus.PlexusTestCase;
import java.io.File;
{
super.setUp();
- discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, "default" );
+ discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE,
+ "org.apache.maven.repository.discovery.DefaultArtifactDiscoverer" );
factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
File basedir = getTestFile( "src/test/repository" );
-
ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
List artifacts = discoverer.discoverStandalonePoms( repository, null, false );
assertEquals( 4, artifacts.size() );
Iterator itr = artifacts.iterator();
- Artifact artifact = (Artifact) itr.next();
+ //Artifact artifact = (Artifact) itr.next();
+ Model model = (Model) itr.next();
+ Artifact artifact =
+ createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() );
assertEquals( "org.apache.maven", artifact.getGroupId() );
assertEquals( "B", artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
- artifact = (Artifact) itr.next();
+ model = (Model) itr.next();
+ artifact =
+ createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() );
assertEquals( "org.apache.maven", artifact.getGroupId() );
assertEquals( "B", artifact.getArtifactId() );
assertEquals( "2.0", artifact.getVersion() );
- artifact = (Artifact) itr.next();
+ model = (Model) itr.next();
+ artifact =
+ createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() );
assertEquals( "org.apache.maven", artifact.getGroupId() );
assertEquals( "discovery", artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
- artifact = (Artifact) itr.next();
+ model = (Model) itr.next();
+ artifact =
+ createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() );
assertEquals( "org.apache.testgroup", artifact.getGroupId() );
assertEquals( "discovery", artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
{
super.setUp();
- discoverer = (MetadataDiscoverer) lookup( MetadataDiscoverer.ROLE, "default" );
+ discoverer = (MetadataDiscoverer) lookup( MetadataDiscoverer.ROLE,
+ "org.apache.maven.repository.discovery.DefaultMetadataDiscoverer" );
repositoryLocation = getTestFile( "src/test/repository" );
}
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.artifact.factory.ArtifactFactory;
import org.codehaus.plexus.PlexusTestCase;
+import java.io.File;
+import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.List;
-import java.net.MalformedURLException;
-import java.io.File;
/**
* Test the legacy artifact discoverer.
{
super.setUp();
- discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, "legacy" );
+ discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE,
+ "org.apache.maven.repository.discovery.LegacyArtifactDiscoverer" );
factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );