mirror of
https://github.com/apache/maven.git
synced 2025-02-22 18:04:52 +00:00
make m2 use the local repository in the new layout
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d4e2de64cf
commit
1398ab68c4
@ -49,7 +49,7 @@ public class Verifier
|
||||
private final PrintStream originalErr;
|
||||
|
||||
// TODO: needs to be configurable
|
||||
private static String localRepoLayout = "legacy";
|
||||
private static String localRepoLayout = "default";
|
||||
|
||||
public Verifier( String basedir )
|
||||
{
|
||||
@ -96,7 +96,8 @@ public void displayStreamBuffers()
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void verify() throws VerificationException
|
||||
public void verify()
|
||||
throws VerificationException
|
||||
{
|
||||
List lines = loadFile( basedir, "expected-results.txt" );
|
||||
|
||||
@ -120,12 +121,14 @@ public void verify() throws VerificationException
|
||||
}
|
||||
}
|
||||
|
||||
private static List loadFile( String basedir, String filename ) throws VerificationException
|
||||
private static List loadFile( String basedir, String filename )
|
||||
throws VerificationException
|
||||
{
|
||||
return loadFile( new File( basedir, filename ) );
|
||||
}
|
||||
|
||||
private static List loadFile( File file ) throws VerificationException
|
||||
private static List loadFile( File file )
|
||||
throws VerificationException
|
||||
{
|
||||
List lines = new ArrayList();
|
||||
|
||||
@ -144,7 +147,6 @@ private static List loadFile( File file ) throws VerificationException
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
line = replaceArtifacts( line );
|
||||
|
||||
lines.add( line );
|
||||
@ -220,7 +222,8 @@ else if ( "default".equals( localRepoLayout ) )
|
||||
return localRepo + "/" + repositoryPath;
|
||||
}
|
||||
|
||||
public void executeHook( String filename ) throws VerificationException
|
||||
public void executeHook( String filename )
|
||||
throws VerificationException
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -250,7 +253,8 @@ public void executeHook( String filename ) throws VerificationException
|
||||
}
|
||||
}
|
||||
|
||||
private static void executeCommand( String line ) throws VerificationException
|
||||
private static void executeCommand( String line )
|
||||
throws VerificationException
|
||||
{
|
||||
int index = line.indexOf( " " );
|
||||
|
||||
@ -334,7 +338,8 @@ private static String retrieveLocalRepo()
|
||||
return repo;
|
||||
}
|
||||
|
||||
private void verifyExpectedResult( String line ) throws VerificationException
|
||||
private void verifyExpectedResult( String line )
|
||||
throws VerificationException
|
||||
{
|
||||
if ( line.indexOf( "!/" ) > 0 )
|
||||
{
|
||||
@ -378,7 +383,8 @@ private void verifyExpectedResult( String line ) throws VerificationException
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public void executeGoals( String filename ) throws VerificationException
|
||||
public void executeGoals( String filename )
|
||||
throws VerificationException
|
||||
{
|
||||
String mavenHome = System.getProperty( "maven.home" );
|
||||
|
||||
@ -584,8 +590,8 @@ public void fatalError( SAXParseException spe )
|
||||
|
||||
private final void printParseError( String type, SAXParseException spe )
|
||||
{
|
||||
System.err.println( type + " [line " + spe.getLineNumber() + ", row " + spe.getColumnNumber() + "]: "
|
||||
+ spe.getMessage() );
|
||||
System.err.println( type + " [line " + spe.getLineNumber() + ", row " + spe.getColumnNumber() + "]: " +
|
||||
spe.getMessage() );
|
||||
}
|
||||
|
||||
public Profile getActiveMavenProfile()
|
||||
@ -593,12 +599,14 @@ public Profile getActiveMavenProfile()
|
||||
return activeMavenProfile;
|
||||
}
|
||||
|
||||
public void characters( char[] ch, int start, int length ) throws SAXException
|
||||
public void characters( char[] ch, int start, int length )
|
||||
throws SAXException
|
||||
{
|
||||
currentBody.append( ch, start, length );
|
||||
}
|
||||
|
||||
public void endElement( String uri, String localName, String rawName ) throws SAXException
|
||||
public void endElement( String uri, String localName, String rawName )
|
||||
throws SAXException
|
||||
{
|
||||
if ( "profile".equals( rawName ) )
|
||||
{
|
||||
@ -609,15 +617,15 @@ public void endElement( String uri, String localName, String rawName ) throws SA
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SAXException( "Invalid mavenProfile entry. Missing one or more "
|
||||
+ "fields: {localRepository}." );
|
||||
throw new SAXException( "Invalid mavenProfile entry. Missing one or more " +
|
||||
"fields: {localRepository}." );
|
||||
}
|
||||
}
|
||||
else if ( currentProfile != null )
|
||||
{
|
||||
if ( "active".equals( rawName ) )
|
||||
{
|
||||
currentProfile.setActive( Boolean.valueOf(currentBody.toString().trim()).booleanValue() );
|
||||
currentProfile.setActive( Boolean.valueOf( currentBody.toString().trim() ).booleanValue() );
|
||||
}
|
||||
else if ( "localRepository".equals( rawName ) )
|
||||
{
|
||||
@ -630,16 +638,16 @@ else if ( "localRepository".equals( rawName ) )
|
||||
}
|
||||
else if ( "settings".equals( rawName ) )
|
||||
{
|
||||
if(profiles.size() == 1)
|
||||
if ( profiles.size() == 1 )
|
||||
{
|
||||
activeMavenProfile = (Profile) profiles.get(0);
|
||||
activeMavenProfile = (Profile) profiles.get( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( Iterator it = profiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
if(profile.isActive())
|
||||
if ( profile.isActive() )
|
||||
{
|
||||
activeMavenProfile = profile;
|
||||
}
|
||||
@ -677,6 +685,7 @@ public static class Profile
|
||||
{
|
||||
|
||||
private String localRepository;
|
||||
|
||||
private boolean active = false;
|
||||
|
||||
public void setLocalRepo( String localRepo )
|
||||
@ -688,12 +697,12 @@ public String getLocalRepo()
|
||||
{
|
||||
return localRepository;
|
||||
}
|
||||
|
||||
|
||||
public void setActive( boolean active )
|
||||
{
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return active;
|
||||
|
@ -149,22 +149,8 @@ else if ( commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) )
|
||||
artifactRepositoryFactory.setGlobalSnapshotPolicy( ArtifactRepository.SNAPSHOT_POLICY_ALWAYS );
|
||||
}
|
||||
|
||||
// TODO: Switch the default repository layout id to "default" when the
|
||||
// conversion is done.
|
||||
String repoLayoutId = "legacy";
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.VERSION_1_REPO ) )
|
||||
{
|
||||
repoLayoutId = "legacy";
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.VERSION_2_REPO ) )
|
||||
{
|
||||
repoLayoutId = "default";
|
||||
}
|
||||
|
||||
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) embedder.lookup(
|
||||
ArtifactRepositoryLayout.ROLE, repoLayoutId );
|
||||
ArtifactRepositoryLayout.ROLE, "default" );
|
||||
|
||||
ArtifactRepository localRepository = getLocalRepository( settings, artifactRepositoryFactory, repositoryLayout );
|
||||
|
||||
@ -306,11 +292,6 @@ static class CLIManager
|
||||
|
||||
public static final char NON_RECURSIVE = 'N';
|
||||
|
||||
public static final char VERSION_1_REPO = 'A';
|
||||
|
||||
// TODO: this is a hack until we can get the main repo converted...
|
||||
public static final char VERSION_2_REPO = 'a';
|
||||
|
||||
public static final char UPDATE_SNAPSHOTS = 'U';
|
||||
|
||||
public CLIManager()
|
||||
@ -334,11 +315,6 @@ public CLIManager()
|
||||
"Execute goals for project found in the reactor" ).create( REACTOR ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription(
|
||||
"Do not recurse into sub-projects" ).create( NON_RECURSIVE ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "v1-local-repository" ).withDescription(
|
||||
"Use legacy layout for local artifact repository" ).create( VERSION_1_REPO ) );
|
||||
|
||||
options.addOption( OptionBuilder.withLongOpt( "v2-local-repository" ).withDescription(
|
||||
"Use new layout for local artifact repository" ).create( VERSION_2_REPO ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription(
|
||||
"Update all snapshots regardless of repository policies" ).create( UPDATE_SNAPSHOTS ) );
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public void run( String[] args )
|
||||
online = false;
|
||||
}
|
||||
|
||||
Repository localRepository = new Repository( mavenRepoLocal, Repository.LAYOUT_LEGACY );
|
||||
Repository localRepository = new Repository( mavenRepoLocal, Repository.LAYOUT_DEFAULT );
|
||||
|
||||
ModelReader reader = new ModelReader( localRepository );
|
||||
|
||||
|
@ -114,8 +114,7 @@ private void setRemoteRepos( List repositories )
|
||||
if ( repositories.isEmpty() )
|
||||
{
|
||||
// TODO: use super POM?
|
||||
Repository repository = new Repository();
|
||||
repository.setBasedir( "http://repo1.maven.org" );
|
||||
Repository repository = new Repository( "http://repo1.maven.org", Repository.LAYOUT_LEGACY );
|
||||
remoteRepos.add( repository );
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class Repository
|
||||
|
||||
private String basedir;
|
||||
|
||||
private String layout = LAYOUT_LEGACY;
|
||||
private String layout;
|
||||
|
||||
public Repository()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user