mirror of https://github.com/apache/maven.git
parent
36b8a6d562
commit
7f206ef1cc
|
@ -19,15 +19,14 @@ package org.apache.maven.settings;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the global settings.xml shipped with the distribution is in good state.
|
* Tests that the global settings.xml shipped with the distribution is in good state.
|
||||||
*
|
*
|
||||||
|
@ -45,7 +44,7 @@ public class GlobalSettingsTest
|
||||||
File globalSettingsFile = new File( basedir, "src/conf/settings.xml" );
|
File globalSettingsFile = new File( basedir, "src/conf/settings.xml" );
|
||||||
assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() );
|
assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() );
|
||||||
|
|
||||||
try (Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ))
|
try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ) )
|
||||||
{
|
{
|
||||||
new SettingsXpp3Reader().read( reader );
|
new SettingsXpp3Reader().read( reader );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,9 @@ package org.apache.maven.repository.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.WriterFactory;
|
import org.codehaus.plexus.util.WriterFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
@ -37,6 +29,13 @@ import org.eclipse.aether.RepositoryException;
|
||||||
import org.eclipse.aether.metadata.AbstractMetadata;
|
import org.eclipse.aether.metadata.AbstractMetadata;
|
||||||
import org.eclipse.aether.metadata.MergeableMetadata;
|
import org.eclipse.aether.metadata.MergeableMetadata;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
*/
|
*/
|
||||||
|
@ -96,10 +95,8 @@ abstract class MavenMetadata
|
||||||
return new Metadata();
|
return new Metadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader reader = null;
|
try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
reader = ReaderFactory.newXmlReader( metadataFile );
|
|
||||||
return new MetadataXpp3Reader().read( reader, false );
|
return new MetadataXpp3Reader().read( reader, false );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
|
@ -110,30 +107,20 @@ abstract class MavenMetadata
|
||||||
{
|
{
|
||||||
throw new RepositoryException( "Could not parse metadata " + metadataFile + ": " + e.getMessage(), e );
|
throw new RepositoryException( "Could not parse metadata " + metadataFile + ": " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( reader );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write( File metadataFile, Metadata metadata )
|
private void write( File metadataFile, Metadata metadata )
|
||||||
throws RepositoryException
|
throws RepositoryException
|
||||||
{
|
{
|
||||||
Writer writer = null;
|
metadataFile.getParentFile().mkdirs();
|
||||||
try
|
try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) )
|
||||||
{
|
{
|
||||||
metadataFile.getParentFile().mkdirs();
|
|
||||||
writer = WriterFactory.newXmlWriter( metadataFile );
|
|
||||||
new MetadataXpp3Writer().write( writer, metadata );
|
new MetadataXpp3Writer().write( writer, metadata );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new RepositoryException( "Could not write metadata " + metadataFile + ": " + e.getMessage(), e );
|
throw new RepositoryException( "Could not write metadata " + metadataFile + ": " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( writer );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getProperties()
|
public Map<String, String> getProperties()
|
||||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.building;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class FileSourceTest
|
public class FileSourceTest
|
||||||
{
|
{
|
||||||
|
@ -52,26 +52,12 @@ public class FileSourceTest
|
||||||
File txtFile = new File( "target/test-classes/source.txt" );
|
File txtFile = new File( "target/test-classes/source.txt" );
|
||||||
FileSource source = new FileSource( txtFile );
|
FileSource source = new FileSource( txtFile );
|
||||||
|
|
||||||
Scanner scanner = null;
|
try ( InputStream is = source.getInputStream();
|
||||||
InputStream is = null;
|
Scanner scanner = new Scanner( is ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
is = source.getInputStream();
|
|
||||||
|
|
||||||
scanner = new Scanner( is );
|
|
||||||
assertEquals( "Hello World!", scanner.nextLine() );
|
assertEquals( "Hello World!", scanner.nextLine() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( scanner != null )
|
|
||||||
{
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
if ( is != null )
|
|
||||||
{
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,12 +19,12 @@ package org.apache.maven.building;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class StringSourceTest
|
public class StringSourceTest
|
||||||
{
|
{
|
||||||
|
@ -34,26 +34,11 @@ public class StringSourceTest
|
||||||
{
|
{
|
||||||
StringSource source = new StringSource( "Hello World!" );
|
StringSource source = new StringSource( "Hello World!" );
|
||||||
|
|
||||||
Scanner scanner = null;
|
try ( InputStream is = source.getInputStream();
|
||||||
InputStream is = null;
|
Scanner scanner = new Scanner( is ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
is = source.getInputStream();
|
|
||||||
|
|
||||||
scanner = new Scanner( is );
|
|
||||||
assertEquals( "Hello World!", scanner.nextLine() );
|
assertEquals( "Hello World!", scanner.nextLine() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( scanner != null )
|
|
||||||
{
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
if ( is != null )
|
|
||||||
{
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,15 +19,15 @@ package org.apache.maven.building;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class UrlSourceTest
|
public class UrlSourceTest
|
||||||
{
|
{
|
||||||
|
@ -52,27 +52,11 @@ public class UrlSourceTest
|
||||||
{
|
{
|
||||||
URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL();
|
URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL();
|
||||||
UrlSource source = new UrlSource( txtFile );
|
UrlSource source = new UrlSource( txtFile );
|
||||||
|
try ( InputStream is = source.getInputStream();
|
||||||
Scanner scanner = null;
|
Scanner scanner = new Scanner( is ) )
|
||||||
InputStream is = null;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
is = source.getInputStream();
|
|
||||||
|
|
||||||
scanner = new Scanner( is );
|
|
||||||
assertEquals( "Hello World!", scanner.nextLine() );
|
assertEquals( "Hello World!", scanner.nextLine() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( scanner != null )
|
|
||||||
{
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
if ( is != null )
|
|
||||||
{
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,16 +19,6 @@ package org.apache.maven.artifact.repository.metadata;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
|
@ -43,11 +33,20 @@ import org.apache.maven.wagon.TransferFailedException;
|
||||||
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.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.WriterFactory;
|
import org.codehaus.plexus.util.WriterFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
*/
|
*/
|
||||||
|
@ -100,8 +99,7 @@ public class DefaultRepositoryMetadataManager
|
||||||
|
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( getLogger().isDebugEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug( "Skipping update check for " + metadata.getKey() + " (" + file
|
||||||
"Skipping update check for " + metadata.getKey() + " (" + file
|
|
||||||
+ ") from disabled repository " + repository.getId() + " ("
|
+ ") from disabled repository " + repository.getId() + " ("
|
||||||
+ repository.getUrl() + ")" );
|
+ repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
|
@ -117,9 +115,8 @@ public class DefaultRepositoryMetadataManager
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( getLogger().isDebugEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"Skipping update check for " + metadata.getKey() + " (" + file
|
"Skipping update check for " + metadata.getKey() + " (" + file + ") from repository "
|
||||||
+ ") from repository " + repository.getId() + " (" + repository.getUrl()
|
+ repository.getId() + " (" + repository.getUrl() + ") in favor of local copy" );
|
||||||
+ ") in favor of local copy" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -183,8 +180,8 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
catch ( RepositoryMetadataStoreException e )
|
catch ( RepositoryMetadataStoreException e )
|
||||||
{
|
{
|
||||||
throw new RepositoryMetadataResolutionException( "Unable to store local copy of metadata: "
|
throw new RepositoryMetadataResolutionException(
|
||||||
+ e.getMessage(), e );
|
"Unable to store local copy of metadata: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,14 +264,13 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository,
|
private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository,
|
||||||
ArtifactRepository localRepository, Map<ArtifactRepository,
|
ArtifactRepository localRepository,
|
||||||
Metadata> previousMetadata )
|
Map<ArtifactRepository, Metadata> previousMetadata )
|
||||||
{
|
{
|
||||||
boolean setRepository = false;
|
boolean setRepository = false;
|
||||||
|
|
||||||
File metadataFile =
|
File metadataFile = new File( localRepository.getBasedir(),
|
||||||
new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata,
|
localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) );
|
||||||
remoteRepository ) );
|
|
||||||
|
|
||||||
if ( metadataFile.exists() )
|
if ( metadataFile.exists() )
|
||||||
{
|
{
|
||||||
|
@ -315,17 +311,16 @@ public class DefaultRepositoryMetadataManager
|
||||||
return setRepository;
|
return setRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @todo share with DefaultPluginMappingManager. */
|
/**
|
||||||
|
* @todo share with DefaultPluginMappingManager.
|
||||||
|
*/
|
||||||
protected Metadata readMetadata( File mappingFile )
|
protected Metadata readMetadata( File mappingFile )
|
||||||
throws RepositoryMetadataReadException
|
throws RepositoryMetadataReadException
|
||||||
{
|
{
|
||||||
Metadata result;
|
Metadata result;
|
||||||
|
|
||||||
Reader reader = null;
|
try ( Reader reader = ReaderFactory.newXmlReader( mappingFile ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
reader = ReaderFactory.newXmlReader( mappingFile );
|
|
||||||
|
|
||||||
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
||||||
|
|
||||||
result = mappingReader.read( reader, false );
|
result = mappingReader.read( reader, false );
|
||||||
|
@ -336,14 +331,9 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
catch ( IOException | XmlPullParserException e )
|
catch ( IOException | XmlPullParserException e )
|
||||||
{
|
{
|
||||||
throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
|
throw new RepositoryMetadataReadException(
|
||||||
+ e.getMessage(), e );
|
"Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( reader );
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,10 +356,9 @@ public class DefaultRepositoryMetadataManager
|
||||||
if ( lastUpdated != null && now != null && now.compareTo( lastUpdated ) < 0 )
|
if ( lastUpdated != null && now != null && now.compareTo( lastUpdated ) < 0 )
|
||||||
{
|
{
|
||||||
getLogger().warn(
|
getLogger().warn(
|
||||||
"The last updated timestamp in " + metadataFile + " refers to the future (now = "
|
"The last updated timestamp in " + metadataFile + " refers to the future (now = " + now
|
||||||
+ now + ", lastUpdated = " + lastUpdated
|
+ ", lastUpdated = " + lastUpdated + "). Please verify that the clocks of all"
|
||||||
+ "). Please verify that the clocks of all"
|
+ " deploying machines are reasonably synchronized." );
|
||||||
+ " deploying machines are reasonably synchronized." );
|
|
||||||
versioning.setLastUpdated( now );
|
versioning.setLastUpdated( now );
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -380,10 +369,8 @@ public class DefaultRepositoryMetadataManager
|
||||||
{
|
{
|
||||||
getLogger().debug( "Repairing metadata in " + metadataFile );
|
getLogger().debug( "Repairing metadata in " + metadataFile );
|
||||||
|
|
||||||
Writer writer = null;
|
try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
writer = WriterFactory.newXmlWriter( metadataFile );
|
|
||||||
new MetadataXpp3Writer().write( writer, metadata );
|
new MetadataXpp3Writer().write( writer, metadata );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
|
@ -398,10 +385,6 @@ public class DefaultRepositoryMetadataManager
|
||||||
getLogger().warn( msg );
|
getLogger().warn( msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( writer );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,8 +399,9 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
catch ( TransferFailedException e )
|
catch ( TransferFailedException e )
|
||||||
{
|
{
|
||||||
throw new RepositoryMetadataResolutionException( metadata + " could not be retrieved from repository: "
|
throw new RepositoryMetadataResolutionException(
|
||||||
+ remoteRepository.getId() + " due to an error: " + e.getMessage(), e );
|
metadata + " could not be retrieved from repository: " + remoteRepository.getId() + " due to an error: "
|
||||||
|
+ e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -434,8 +418,7 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata,
|
private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository localRepo,
|
||||||
ArtifactRepository localRepo,
|
|
||||||
ArtifactRepository remoteRepository )
|
ArtifactRepository remoteRepository )
|
||||||
throws TransferFailedException
|
throws TransferFailedException
|
||||||
{
|
{
|
||||||
|
@ -449,8 +432,8 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
catch ( ResourceDoesNotExistException e )
|
catch ( ResourceDoesNotExistException e )
|
||||||
{
|
{
|
||||||
getLogger().info( metadata + " could not be found on repository: " + remoteRepository.getId()
|
getLogger().info(
|
||||||
+ ", so will be created" );
|
metadata + " could not be found on repository: " + remoteRepository.getId() + ", so will be created" );
|
||||||
|
|
||||||
// delete the local copy so the old details aren't used.
|
// delete the local copy so the old details aren't used.
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
|
@ -494,8 +477,9 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
catch ( TransferFailedException e )
|
catch ( TransferFailedException e )
|
||||||
{
|
{
|
||||||
throw new RepositoryMetadataDeploymentException( metadata + " could not be retrieved from repository: "
|
throw new RepositoryMetadataDeploymentException(
|
||||||
+ deploymentRepository.getId() + " due to an error: " + e.getMessage(), e );
|
metadata + " could not be retrieved from repository: " + deploymentRepository.getId()
|
||||||
|
+ " due to an error: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( file.isFile() )
|
if ( file.isFile() )
|
||||||
|
@ -513,9 +497,8 @@ public class DefaultRepositoryMetadataManager
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// It's a POM - we don't need to retrieve it first
|
// It's a POM - we don't need to retrieve it first
|
||||||
file =
|
file = new File( localRepository.getBasedir(),
|
||||||
new File( localRepository.getBasedir(),
|
localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
|
||||||
localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -52,13 +52,9 @@ public class DefaultMavenProfilesBuilder
|
||||||
if ( profilesXml.exists() )
|
if ( profilesXml.exists() )
|
||||||
{
|
{
|
||||||
ProfilesXpp3Reader reader = new ProfilesXpp3Reader();
|
ProfilesXpp3Reader reader = new ProfilesXpp3Reader();
|
||||||
Reader profileReader = null;
|
try ( Reader profileReader = ReaderFactory.newXmlReader( profilesXml );
|
||||||
try
|
StringWriter sWriter = new StringWriter() )
|
||||||
{
|
{
|
||||||
profileReader = ReaderFactory.newXmlReader( profilesXml );
|
|
||||||
|
|
||||||
StringWriter sWriter = new StringWriter();
|
|
||||||
|
|
||||||
IOUtil.copy( profileReader, sWriter );
|
IOUtil.copy( profileReader, sWriter );
|
||||||
|
|
||||||
String rawInput = sWriter.toString();
|
String rawInput = sWriter.toString();
|
||||||
|
@ -72,8 +68,9 @@ public class DefaultMavenProfilesBuilder
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
getLogger().warn( "Failed to initialize environment variable resolver. Skipping environment "
|
getLogger().warn(
|
||||||
+ "substitution in " + PROFILES_XML_FILE + "." );
|
"Failed to initialize environment variable resolver. Skipping environment " + "substitution in "
|
||||||
|
+ PROFILES_XML_FILE + "." );
|
||||||
getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e );
|
getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +78,7 @@ public class DefaultMavenProfilesBuilder
|
||||||
|
|
||||||
profilesRoot = reader.read( sReader );
|
profilesRoot = reader.read( sReader );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( profileReader );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return profilesRoot;
|
return profilesRoot;
|
||||||
|
|
|
@ -19,6 +19,17 @@ package org.apache.maven.repository.legacy;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
|
import org.apache.maven.artifact.repository.Authentication;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||||
|
import org.apache.maven.repository.Proxy;
|
||||||
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -31,17 +42,6 @@ import java.nio.channels.FileLock;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
|
||||||
import org.apache.maven.artifact.repository.Authentication;
|
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
|
||||||
import org.apache.maven.repository.Proxy;
|
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|
||||||
import org.codehaus.plexus.logging.Logger;
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
|
|
||||||
@Component( role = UpdateCheckManager.class )
|
@Component( role = UpdateCheckManager.class )
|
||||||
public class DefaultUpdateCheckManager
|
public class DefaultUpdateCheckManager
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
|
@ -75,8 +75,8 @@ public class DefaultUpdateCheckManager
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( getLogger().isDebugEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"Skipping update check for " + artifact + " (" + file + ") from "
|
"Skipping update check for " + artifact + " (" + file + ") from " + repository.getId() + " ("
|
||||||
+ repository.getId() + " (" + repository.getUrl() + ")" );
|
+ repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -85,8 +85,8 @@ public class DefaultUpdateCheckManager
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( getLogger().isDebugEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"Determining update check for " + artifact + " (" + file + ") from "
|
"Determining update check for " + artifact + " (" + file + ") from " + repository.getId() + " ("
|
||||||
+ repository.getId() + " (" + repository.getUrl() + ")" );
|
+ repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( file == null )
|
if ( file == null )
|
||||||
|
@ -99,7 +99,7 @@ public class DefaultUpdateCheckManager
|
||||||
|
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
{
|
{
|
||||||
lastCheckDate = new Date ( file.lastModified() );
|
lastCheckDate = new Date( file.lastModified() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -125,8 +125,8 @@ public class DefaultUpdateCheckManager
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( getLogger().isDebugEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"Skipping update check for " + metadata.getKey() + " (" + file + ") from "
|
"Skipping update check for " + metadata.getKey() + " (" + file + ") from " + repository.getId()
|
||||||
+ repository.getId() + " (" + repository.getUrl() + ")" );
|
+ " (" + repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -135,8 +135,8 @@ public class DefaultUpdateCheckManager
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( getLogger().isDebugEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"Determining update check for " + metadata.getKey() + " (" + file + ") from "
|
"Determining update check for " + metadata.getKey() + " (" + file + ") from " + repository.getId()
|
||||||
+ repository.getId() + " (" + repository.getUrl() + ")" );
|
+ " (" + repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( file == null )
|
if ( file == null )
|
||||||
|
@ -282,8 +282,9 @@ public class DefaultUpdateCheckManager
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Failed to record lastUpdated information for resolution.\nFile: "
|
getLogger().debug(
|
||||||
+ touchfile.toString() + "; key: " + key, e );
|
"Failed to record lastUpdated information for resolution.\nFile: " + touchfile.toString()
|
||||||
|
+ "; key: " + key, e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -295,8 +296,8 @@ public class DefaultUpdateCheckManager
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Error releasing exclusive lock for resolution tracking file: "
|
getLogger().debug( "Error releasing exclusive lock for resolution tracking file: " + touchfile,
|
||||||
+ touchfile, e );
|
e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,8 +309,7 @@ public class DefaultUpdateCheckManager
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Error closing FileChannel for resolution tracking file: "
|
getLogger().debug( "Error closing FileChannel for resolution tracking file: " + touchfile, e );
|
||||||
+ touchfile, e );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.maven.usability.plugin;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader;
|
import org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -56,12 +55,9 @@ public class ExpressionDocumenter
|
||||||
|
|
||||||
for ( String EXPRESSION_ROOT : EXPRESSION_ROOTS )
|
for ( String EXPRESSION_ROOT : EXPRESSION_ROOTS )
|
||||||
{
|
{
|
||||||
InputStream docStream = null;
|
try ( InputStream docStream = docLoader.getResourceAsStream(
|
||||||
try
|
EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOT + ".paramdoc.xml" ) )
|
||||||
{
|
{
|
||||||
docStream =
|
|
||||||
docLoader.getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOT + ".paramdoc.xml" );
|
|
||||||
|
|
||||||
if ( docStream != null )
|
if ( docStream != null )
|
||||||
{
|
{
|
||||||
Map<String, Expression> doco = parseExpressionDocumentation( docStream );
|
Map<String, Expression> doco = parseExpressionDocumentation( docStream );
|
||||||
|
@ -79,10 +75,7 @@ public class ExpressionDocumenter
|
||||||
throw new ExpressionDocumentationException(
|
throw new ExpressionDocumentationException(
|
||||||
"Failed to parse documentation for expression root: " + EXPRESSION_ROOT, e );
|
"Failed to parse documentation for expression root: " + EXPRESSION_ROOT, e );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( docStream );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,26 +84,27 @@ public class ExpressionDocumenter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <expressions>
|
* <expressions>
|
||||||
* <expression>
|
* <expression>
|
||||||
* <syntax>project.distributionManagementArtifactRepository</syntax>
|
* <syntax>project.distributionManagementArtifactRepository</syntax>
|
||||||
* <origin><![CDATA[
|
* <origin><![CDATA[
|
||||||
* <distributionManagement>
|
* <distributionManagement>
|
||||||
* <repository>
|
* <repository>
|
||||||
* <id>some-repo</id>
|
* <id>some-repo</id>
|
||||||
* <url>scp://host/path</url>
|
* <url>scp://host/path</url>
|
||||||
* </repository>
|
* </repository>
|
||||||
* <snapshotRepository>
|
* <snapshotRepository>
|
||||||
* <id>some-snap-repo</id>
|
* <id>some-snap-repo</id>
|
||||||
* <url>scp://host/snapshot-path</url>
|
* <url>scp://host/snapshot-path</url>
|
||||||
* </snapshotRepository>
|
* </snapshotRepository>
|
||||||
* </distributionManagement>
|
* </distributionManagement>
|
||||||
* ]]></origin>
|
* ]]></origin>
|
||||||
* <usage><![CDATA[
|
* <usage><![CDATA[
|
||||||
* The repositories onto which artifacts should be deployed.
|
* The repositories onto which artifacts should be deployed.
|
||||||
* One is for releases, the other for snapshots.
|
* One is for releases, the other for snapshots.
|
||||||
* ]]></usage>
|
* ]]></usage>
|
||||||
* </expression>
|
* </expression>
|
||||||
* <expressions>
|
* <expressions>
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws XmlPullParserException
|
* @throws XmlPullParserException
|
||||||
*/
|
*/
|
||||||
|
@ -165,11 +159,11 @@ public class ExpressionDocumenter
|
||||||
}
|
}
|
||||||
catch ( MalformedURLException e )
|
catch ( MalformedURLException e )
|
||||||
{
|
{
|
||||||
throw new ExpressionDocumentationException( "Cannot construct expression documentation classpath"
|
throw new ExpressionDocumentationException(
|
||||||
+ " resource base.", e );
|
"Cannot construct expression documentation classpath" + " resource base.", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URLClassLoader( new URL[] { docResource } );
|
return new URLClassLoader( new URL[]{ docResource } );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,23 +19,15 @@ package org.apache.maven.artifact;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.plugin.LegacySupport;
|
|
||||||
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionResult;
|
import org.apache.maven.execution.DefaultMavenExecutionResult;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
|
import org.apache.maven.plugin.LegacySupport;
|
||||||
|
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
|
||||||
import org.codehaus.plexus.ContainerConfiguration;
|
import org.codehaus.plexus.ContainerConfiguration;
|
||||||
import org.codehaus.plexus.PlexusConstants;
|
import org.codehaus.plexus.PlexusConstants;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
@ -54,14 +46,22 @@ import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
|
||||||
import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
|
import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
|
||||||
import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
|
import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
|
||||||
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
|
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
|
||||||
|
import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
|
||||||
import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
|
import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
|
||||||
import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
|
import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
|
||||||
import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
|
|
||||||
import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
|
import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
|
||||||
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
|
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
|
||||||
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
|
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
|
||||||
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
|
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
*/
|
*/
|
||||||
|
@ -85,15 +85,14 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
artifactFactory = lookup( ArtifactFactory.class);
|
artifactFactory = lookup( ArtifactFactory.class );
|
||||||
artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class );
|
artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class );
|
||||||
|
|
||||||
RepositorySystemSession repoSession = initRepoSession();
|
RepositorySystemSession repoSession = initRepoSession();
|
||||||
MavenSession session =
|
MavenSession session = new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(),
|
||||||
new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(),
|
new DefaultMavenExecutionResult() );
|
||||||
new DefaultMavenExecutionResult() );
|
|
||||||
|
|
||||||
LegacySupport legacySupport = lookup(LegacySupport.class);
|
LegacySupport legacySupport = lookup( LegacySupport.class );
|
||||||
legacySupport.setSession( session );
|
legacySupport.setSession( session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +124,8 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout =
|
ArtifactRepositoryLayout repoLayout =
|
||||||
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||||
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, null, null );
|
return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, null,
|
||||||
|
null );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRepositoryLayout()
|
protected String getRepositoryLayout()
|
||||||
|
@ -143,7 +143,8 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout =
|
ArtifactRepositoryLayout repoLayout =
|
||||||
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||||
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + f.getPath(), repoLayout, null, null );
|
return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + f.getPath(), repoLayout, null,
|
||||||
|
null );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository remoteRepository()
|
protected ArtifactRepository remoteRepository()
|
||||||
|
@ -157,7 +158,8 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||||
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
|
return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
|
||||||
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
|
new ArtifactRepositoryPolicy(),
|
||||||
|
new ArtifactRepositoryPolicy() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository badRemoteRepository()
|
protected ArtifactRepository badRemoteRepository()
|
||||||
|
@ -166,7 +168,8 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout =
|
ArtifactRepositoryLayout repoLayout =
|
||||||
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||||
|
|
||||||
return artifactRepositoryFactory.createArtifactRepository( "test", "http://foo.bar/repository", repoLayout, null, null );
|
return artifactRepositoryFactory.createArtifactRepository( "test", "http://foo.bar/repository", repoLayout,
|
||||||
|
null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertRemoteArtifactPresent( Artifact artifact )
|
protected void assertRemoteArtifactPresent( Artifact artifact )
|
||||||
|
@ -290,12 +293,10 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
{
|
{
|
||||||
artifactFile.getParentFile().mkdirs();
|
artifactFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), "ISO-8859-1" ) )
|
||||||
Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), "ISO-8859-1" );
|
{
|
||||||
|
writer.write( artifact.getId() );
|
||||||
writer.write( artifact.getId() );
|
}
|
||||||
|
|
||||||
writer.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Artifact createArtifact( String artifactId, String version )
|
protected Artifact createArtifact( String artifactId, String version )
|
||||||
|
@ -351,9 +352,9 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
DependencyManager depManager = new ClassicDependencyManager();
|
DependencyManager depManager = new ClassicDependencyManager();
|
||||||
session.setDependencyManager( depManager );
|
session.setDependencyManager( depManager );
|
||||||
|
|
||||||
DependencySelector depFilter =
|
DependencySelector depFilter = new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
|
||||||
new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
|
new OptionalDependencySelector(),
|
||||||
new OptionalDependencySelector(), new ExclusionDependencySelector() );
|
new ExclusionDependencySelector() );
|
||||||
session.setDependencySelector( depFilter );
|
session.setDependencySelector( depFilter );
|
||||||
|
|
||||||
DependencyGraphTransformer transformer =
|
DependencyGraphTransformer transformer =
|
||||||
|
@ -363,7 +364,8 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
session.setDependencyGraphTransformer( transformer );
|
session.setDependencyGraphTransformer( transformer );
|
||||||
|
|
||||||
LocalRepository localRepo = new LocalRepository( localRepository().getBasedir() );
|
LocalRepository localRepo = new LocalRepository( localRepository().getBasedir() );
|
||||||
session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) );
|
session.setLocalRepositoryManager(
|
||||||
|
new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) );
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,22 +19,21 @@ package org.apache.maven.artifact.repository.metadata;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.Writer;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.WriterFactory;
|
import org.codehaus.plexus.util.WriterFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared methods of the repository metadata handling.
|
* Shared methods of the repository metadata handling.
|
||||||
*
|
*
|
||||||
|
@ -60,8 +59,7 @@ public abstract class AbstractRepositoryMetadata
|
||||||
return "maven-metadata-" + repository.getKey() + ".xml";
|
return "maven-metadata-" + repository.getKey() + ".xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeInLocalRepository( ArtifactRepository localRepository,
|
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||||
ArtifactRepository remoteRepository )
|
|
||||||
throws RepositoryMetadataStoreException
|
throws RepositoryMetadataStoreException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -74,8 +72,7 @@ public abstract class AbstractRepositoryMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateRepositoryMetadata( ArtifactRepository localRepository,
|
protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||||
ArtifactRepository remoteRepository )
|
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
||||||
|
@ -83,7 +80,7 @@ public abstract class AbstractRepositoryMetadata
|
||||||
Metadata metadata = null;
|
Metadata metadata = null;
|
||||||
|
|
||||||
File metadataFile = new File( localRepository.getBasedir(),
|
File metadataFile = new File( localRepository.getBasedir(),
|
||||||
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
|
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
|
||||||
|
|
||||||
if ( metadataFile.length() == 0 )
|
if ( metadataFile.length() == 0 )
|
||||||
{
|
{
|
||||||
|
@ -99,23 +96,15 @@ public abstract class AbstractRepositoryMetadata
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
metadataFile.delete(); // if this fails, forget about it, we'll try to overwrite it anyway so no need
|
metadataFile.delete(); // if this fails, forget about it, we'll try to overwrite it anyway so no need
|
||||||
// to delete on exit
|
// to delete on exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( metadataFile.exists() )
|
else if ( metadataFile.exists() )
|
||||||
{
|
{
|
||||||
Reader reader = null;
|
try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
reader = ReaderFactory.newXmlReader( metadataFile );
|
|
||||||
|
|
||||||
metadata = mappingReader.read( reader, false );
|
metadata = mappingReader.read( reader, false );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( reader );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean changed;
|
boolean changed;
|
||||||
|
@ -143,20 +132,13 @@ public abstract class AbstractRepositoryMetadata
|
||||||
|
|
||||||
if ( changed || !metadataFile.exists() )
|
if ( changed || !metadataFile.exists() )
|
||||||
{
|
{
|
||||||
Writer writer = null;
|
metadataFile.getParentFile().mkdirs();
|
||||||
try
|
try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) )
|
||||||
{
|
{
|
||||||
metadataFile.getParentFile().mkdirs();
|
|
||||||
writer = WriterFactory.newXmlWriter( metadataFile );
|
|
||||||
|
|
||||||
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
|
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
|
||||||
|
|
||||||
mappingWriter.write( writer, metadata );
|
mappingWriter.write( writer, metadata );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( writer );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -169,8 +151,7 @@ public abstract class AbstractRepositoryMetadata
|
||||||
return "repository metadata for: \'" + getKey() + "\'";
|
return "repository metadata for: \'" + getKey() + "\'";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Metadata createMetadata( Artifact artifact,
|
protected static Metadata createMetadata( Artifact artifact, Versioning versioning )
|
||||||
Versioning versioning )
|
|
||||||
{
|
{
|
||||||
Metadata metadata = new Metadata();
|
Metadata metadata = new Metadata();
|
||||||
metadata.setGroupId( artifact.getGroupId() );
|
metadata.setGroupId( artifact.getGroupId() );
|
||||||
|
@ -200,14 +181,16 @@ public abstract class AbstractRepositoryMetadata
|
||||||
|
|
||||||
public void merge( org.apache.maven.repository.legacy.metadata.ArtifactMetadata metadata )
|
public void merge( org.apache.maven.repository.legacy.metadata.ArtifactMetadata metadata )
|
||||||
{
|
{
|
||||||
// TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact replaces?
|
// TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact
|
||||||
|
// replaces?
|
||||||
AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata;
|
AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata;
|
||||||
this.metadata.merge( repoMetadata.getMetadata() );
|
this.metadata.merge( repoMetadata.getMetadata() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void merge( ArtifactMetadata metadata )
|
public void merge( ArtifactMetadata metadata )
|
||||||
{
|
{
|
||||||
// TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact replaces?
|
// TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact
|
||||||
|
// replaces?
|
||||||
AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata;
|
AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata;
|
||||||
this.metadata.merge( repoMetadata.getMetadata() );
|
this.metadata.merge( repoMetadata.getMetadata() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,11 @@ package org.apache.maven.extension.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.apache.maven.project.ExtensionDescriptor;
|
||||||
|
import org.apache.maven.project.ExtensionDescriptorBuilder;
|
||||||
|
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -28,17 +33,10 @@ import java.util.Enumeration;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.project.ExtensionDescriptor;
|
|
||||||
import org.apache.maven.project.ExtensionDescriptorBuilder;
|
|
||||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by
|
* Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by
|
||||||
* Maven core itself or a Maven core extension.
|
* Maven core itself or a Maven core extension.
|
||||||
*
|
*
|
||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
*/
|
*/
|
||||||
public class CoreExtensionEntry
|
public class CoreExtensionEntry
|
||||||
|
@ -92,17 +90,13 @@ public class CoreExtensionEntry
|
||||||
Enumeration<URL> urls = loader.getResources( builder.getExtensionDescriptorLocation() );
|
Enumeration<URL> urls = loader.getResources( builder.getExtensionDescriptorLocation() );
|
||||||
while ( urls.hasMoreElements() )
|
while ( urls.hasMoreElements() )
|
||||||
{
|
{
|
||||||
InputStream is = urls.nextElement().openStream();
|
|
||||||
try
|
try ( InputStream is = urls.nextElement().openStream() )
|
||||||
{
|
{
|
||||||
ExtensionDescriptor descriptor = builder.build( is );
|
ExtensionDescriptor descriptor = builder.build( is );
|
||||||
artifacts.addAll( descriptor.getExportedArtifacts() );
|
artifacts.addAll( descriptor.getExportedArtifacts() );
|
||||||
packages.addAll( descriptor.getExportedPackages() );
|
packages.addAll( descriptor.getExportedPackages() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException ignored )
|
catch ( IOException ignored )
|
||||||
|
|
|
@ -19,15 +19,6 @@ package org.apache.maven.internal.aether;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import org.apache.maven.RepositoryUtils;
|
import org.apache.maven.RepositoryUtils;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
import org.apache.maven.bridge.MavenRepositorySystem;
|
import org.apache.maven.bridge.MavenRepositorySystem;
|
||||||
|
@ -43,7 +34,6 @@ import org.apache.maven.settings.crypto.SettingsDecrypter;
|
||||||
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
|
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
|
||||||
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
import org.eclipse.aether.ConfigurationProperties;
|
import org.eclipse.aether.ConfigurationProperties;
|
||||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||||
|
@ -61,6 +51,14 @@ import org.eclipse.aether.util.repository.DefaultProxySelector;
|
||||||
import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy;
|
import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy;
|
||||||
import org.eclipse.sisu.Nullable;
|
import org.eclipse.sisu.Nullable;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +92,7 @@ public class DefaultRepositorySystemSessionFactory
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MavenRepositorySystem mavenRepositorySystem;
|
MavenRepositorySystem mavenRepositorySystem;
|
||||||
|
|
||||||
public DefaultRepositorySystemSession newRepositorySession( MavenExecutionRequest request )
|
public DefaultRepositorySystemSession newRepositorySession( MavenExecutionRequest request )
|
||||||
{
|
{
|
||||||
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
||||||
|
@ -125,8 +123,8 @@ public class DefaultRepositorySystemSessionFactory
|
||||||
int errorPolicy = 0;
|
int errorPolicy = 0;
|
||||||
errorPolicy |= request.isCacheNotFound() ? ResolutionErrorPolicy.CACHE_NOT_FOUND : 0;
|
errorPolicy |= request.isCacheNotFound() ? ResolutionErrorPolicy.CACHE_NOT_FOUND : 0;
|
||||||
errorPolicy |= request.isCacheTransferError() ? ResolutionErrorPolicy.CACHE_TRANSFER_ERROR : 0;
|
errorPolicy |= request.isCacheTransferError() ? ResolutionErrorPolicy.CACHE_TRANSFER_ERROR : 0;
|
||||||
session.setResolutionErrorPolicy( new SimpleResolutionErrorPolicy( errorPolicy, errorPolicy
|
session.setResolutionErrorPolicy(
|
||||||
| ResolutionErrorPolicy.CACHE_NOT_FOUND ) );
|
new SimpleResolutionErrorPolicy( errorPolicy, errorPolicy | ResolutionErrorPolicy.CACHE_NOT_FOUND ) );
|
||||||
|
|
||||||
session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) );
|
session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) );
|
||||||
|
|
||||||
|
@ -135,7 +133,7 @@ public class DefaultRepositorySystemSessionFactory
|
||||||
if ( request.isUseLegacyLocalRepository() )
|
if ( request.isUseLegacyLocalRepository() )
|
||||||
{
|
{
|
||||||
logger.warn( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
|
logger.warn( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
|
||||||
+ " build reproducibility." );
|
+ " build reproducibility." );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
session.setLocalRepositoryManager( simpleLocalRepoMgrFactory.newInstance( session, localRepo ) );
|
session.setLocalRepositoryManager( simpleLocalRepoMgrFactory.newInstance( session, localRepo ) );
|
||||||
|
@ -187,9 +185,9 @@ public class DefaultRepositorySystemSessionFactory
|
||||||
{
|
{
|
||||||
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
|
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
|
||||||
authBuilder.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() );
|
authBuilder.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() );
|
||||||
proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(),
|
proxySelector.add(
|
||||||
proxy.getPort(), authBuilder.build() ),
|
new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(),
|
||||||
proxy.getNonProxyHosts() );
|
authBuilder.build() ), proxy.getNonProxyHosts() );
|
||||||
}
|
}
|
||||||
session.setProxySelector( proxySelector );
|
session.setProxySelector( proxySelector );
|
||||||
|
|
||||||
|
@ -234,7 +232,7 @@ public class DefaultRepositorySystemSessionFactory
|
||||||
mavenRepositorySystem.injectProxy( session, request.getRemoteRepositories() );
|
mavenRepositorySystem.injectProxy( session, request.getRemoteRepositories() );
|
||||||
mavenRepositorySystem.injectAuthentication( session, request.getRemoteRepositories() );
|
mavenRepositorySystem.injectAuthentication( session, request.getRemoteRepositories() );
|
||||||
|
|
||||||
mavenRepositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors() );
|
mavenRepositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors() );
|
||||||
mavenRepositorySystem.injectProxy( session, request.getPluginArtifactRepositories() );
|
mavenRepositorySystem.injectProxy( session, request.getPluginArtifactRepositories() );
|
||||||
mavenRepositorySystem.injectAuthentication( session, request.getPluginArtifactRepositories() );
|
mavenRepositorySystem.injectAuthentication( session, request.getPluginArtifactRepositories() );
|
||||||
|
|
||||||
|
@ -251,18 +249,17 @@ public class DefaultRepositorySystemSessionFactory
|
||||||
{
|
{
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
||||||
InputStream is = getClass().getResourceAsStream( "/META-INF/maven/org.apache.maven/maven-core/pom.properties" );
|
try ( InputStream is = getClass().getResourceAsStream(
|
||||||
if ( is != null )
|
"/META-INF/maven/org.apache.maven/maven-core/pom.properties" ) )
|
||||||
{
|
{
|
||||||
try
|
if ( is != null )
|
||||||
{
|
{
|
||||||
props.load( is );
|
props.load( is );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
}
|
||||||
{
|
catch ( IOException e )
|
||||||
logger.debug( "Failed to read Maven version", e );
|
{
|
||||||
}
|
logger.debug( "Failed to read Maven version", e );
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.getProperty( "version", "unknown-version" );
|
return props.getProperty( "version", "unknown-version" );
|
||||||
|
|
|
@ -19,24 +19,6 @@ package org.apache.maven.plugin.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
|
|
||||||
import org.apache.maven.RepositoryUtils;
|
import org.apache.maven.RepositoryUtils;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.classrealm.ClassRealmManager;
|
import org.apache.maven.classrealm.ClassRealmManager;
|
||||||
|
@ -96,7 +78,6 @@ import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
||||||
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.logging.LoggerManager;
|
import org.codehaus.plexus.logging.LoggerManager;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
@ -107,13 +88,31 @@ import org.eclipse.aether.repository.RemoteRepository;
|
||||||
import org.eclipse.aether.util.filter.AndDependencyFilter;
|
import org.eclipse.aether.util.filter.AndDependencyFilter;
|
||||||
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
|
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such
|
* Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such
|
||||||
* that the plugins/mojos can be used in arbitrary contexts. In particular, the mojos can be used for ordinary build
|
* that the plugins/mojos can be used in arbitrary contexts. In particular, the mojos can be used for ordinary build
|
||||||
* plugins as well as special purpose plugins like reports.
|
* plugins as well as special purpose plugins like reports.
|
||||||
*
|
*
|
||||||
* @since 3.0
|
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Component( role = MavenPluginManager.class )
|
@Component( role = MavenPluginManager.class )
|
||||||
public class DefaultMavenPluginManager
|
public class DefaultMavenPluginManager
|
||||||
|
@ -123,7 +122,7 @@ public class DefaultMavenPluginManager
|
||||||
/**
|
/**
|
||||||
* PluginId=>ExtensionRealmCache.CacheRecord map MavenProject context value key. The map is used to ensure the same
|
* PluginId=>ExtensionRealmCache.CacheRecord map MavenProject context value key. The map is used to ensure the same
|
||||||
* class realm is used to load build extensions and load mojos for extensions=true plugins.
|
* class realm is used to load build extensions and load mojos for extensions=true plugins.
|
||||||
*
|
*
|
||||||
* @noreference this is part of internal implementation and may be changed or removed without notice
|
* @noreference this is part of internal implementation and may be changed or removed without notice
|
||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
*/
|
*/
|
||||||
|
@ -227,15 +226,10 @@ public class DefaultMavenPluginManager
|
||||||
|
|
||||||
if ( pluginXml.isFile() )
|
if ( pluginXml.isFile() )
|
||||||
{
|
{
|
||||||
InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) );
|
try ( InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
pluginDescriptor = parsePluginDescriptor( is, plugin, pluginXml.getAbsolutePath() );
|
pluginDescriptor = parsePluginDescriptor( is, plugin, pluginXml.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +249,8 @@ public class DefaultMavenPluginManager
|
||||||
|
|
||||||
if ( validator.hasErrors() )
|
if ( validator.hasErrors() )
|
||||||
{
|
{
|
||||||
throw new InvalidPluginDescriptorException( "Invalid plugin descriptor for " + plugin.getId() + " ("
|
throw new InvalidPluginDescriptorException(
|
||||||
+ pluginFile + ")", validator.getErrors() );
|
"Invalid plugin descriptor for " + plugin.getId() + " (" + pluginFile + ")", validator.getErrors() );
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
pluginDescriptor.setPluginArtifact( pluginArtifact );
|
||||||
|
@ -317,8 +311,9 @@ public class DefaultMavenPluginManager
|
||||||
{
|
{
|
||||||
if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) )
|
if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) )
|
||||||
{
|
{
|
||||||
throw new PluginIncompatibleException( pluginDescriptor.getPlugin(), "The plugin "
|
throw new PluginIncompatibleException( pluginDescriptor.getPlugin(),
|
||||||
+ pluginDescriptor.getId() + " requires Maven version " + requiredMavenVersion );
|
"The plugin " + pluginDescriptor.getId()
|
||||||
|
+ " requires Maven version " + requiredMavenVersion );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( RuntimeException e )
|
catch ( RuntimeException e )
|
||||||
|
@ -365,9 +360,9 @@ public class DefaultMavenPluginManager
|
||||||
{
|
{
|
||||||
Map<String, ClassLoader> foreignImports = calcImports( project, parent, imports );
|
Map<String, ClassLoader> foreignImports = calcImports( project, parent, imports );
|
||||||
|
|
||||||
PluginRealmCache.Key cacheKey =
|
PluginRealmCache.Key cacheKey = pluginRealmCache.createKey( plugin, parent, foreignImports, filter,
|
||||||
pluginRealmCache.createKey( plugin, parent, foreignImports, filter,
|
project.getRemotePluginRepositories(),
|
||||||
project.getRemotePluginRepositories(), session.getRepositorySession() );
|
session.getRepositorySession() );
|
||||||
|
|
||||||
PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey );
|
PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey );
|
||||||
|
|
||||||
|
@ -420,18 +415,16 @@ public class DefaultMavenPluginManager
|
||||||
dependencyFilter = AndDependencyFilter.newInstance( dependencyFilter, filter );
|
dependencyFilter = AndDependencyFilter.newInstance( dependencyFilter, filter );
|
||||||
|
|
||||||
DependencyNode root =
|
DependencyNode root =
|
||||||
pluginDependenciesResolver.resolve( plugin, RepositoryUtils.toArtifact( pluginArtifact ),
|
pluginDependenciesResolver.resolve( plugin, RepositoryUtils.toArtifact( pluginArtifact ), dependencyFilter,
|
||||||
dependencyFilter, project.getRemotePluginRepositories(),
|
project.getRemotePluginRepositories(), repositorySession );
|
||||||
repositorySession );
|
|
||||||
|
|
||||||
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
|
PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
|
||||||
root.accept( nlg );
|
root.accept( nlg );
|
||||||
|
|
||||||
pluginArtifacts = toMavenArtifacts( root, nlg );
|
pluginArtifacts = toMavenArtifacts( root, nlg );
|
||||||
|
|
||||||
pluginRealm =
|
pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null, foreignImports,
|
||||||
classRealmManager.createPluginRealm( plugin, parent, null, foreignImports,
|
toAetherArtifacts( pluginArtifacts ) );
|
||||||
toAetherArtifacts( pluginArtifacts ) );
|
|
||||||
|
|
||||||
discoverPluginComponents( pluginRealm, plugin, pluginDescriptor );
|
discoverPluginComponents( pluginRealm, plugin, pluginDescriptor );
|
||||||
|
|
||||||
|
@ -454,19 +447,20 @@ public class DefaultMavenPluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
( (DefaultPlexusContainer) container ).discoverComponents( pluginRealm,
|
( (DefaultPlexusContainer) container ).discoverComponents( pluginRealm, new SessionScopeModule( container ),
|
||||||
new SessionScopeModule( container ),
|
|
||||||
new MojoExecutionScopeModule( container ) );
|
new MojoExecutionScopeModule( container ) );
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
throw new PluginContainerException( plugin, pluginRealm, "Error in component graph of plugin "
|
throw new PluginContainerException( plugin, pluginRealm,
|
||||||
+ plugin.getId() + ": " + e.getMessage(), e );
|
"Error in component graph of plugin " + plugin.getId() + ": "
|
||||||
|
+ e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( CycleDetectedInComponentGraphException e )
|
catch ( CycleDetectedInComponentGraphException e )
|
||||||
{
|
{
|
||||||
throw new PluginContainerException( plugin, pluginRealm, "Error in component graph of plugin "
|
throw new PluginContainerException( plugin, pluginRealm,
|
||||||
+ plugin.getId() + ": " + e.getMessage(), e );
|
"Error in component graph of plugin " + plugin.getId() + ": "
|
||||||
|
+ e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +553,8 @@ public class DefaultMavenPluginManager
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
||||||
PrintStream ps = new PrintStream( os );
|
PrintStream ps = new PrintStream( os );
|
||||||
ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '"
|
ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '"
|
||||||
+ pluginDescriptor.getId() + "'. A required class is missing: " + cause.getMessage() );
|
+ pluginDescriptor.getId() + "'. A required class is missing: "
|
||||||
|
+ cause.getMessage() );
|
||||||
pluginRealm.display( ps );
|
pluginRealm.display( ps );
|
||||||
|
|
||||||
throw new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), cause );
|
throw new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), cause );
|
||||||
|
@ -569,16 +564,17 @@ public class DefaultMavenPluginManager
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
||||||
PrintStream ps = new PrintStream( os );
|
PrintStream ps = new PrintStream( os );
|
||||||
ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '"
|
ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '"
|
||||||
+ pluginDescriptor.getId() + "' due to an API incompatibility: " + e.getClass().getName()
|
+ pluginDescriptor.getId() + "' due to an API incompatibility: "
|
||||||
+ ": " + cause.getMessage() );
|
+ e.getClass().getName() + ": " + cause.getMessage() );
|
||||||
pluginRealm.display( ps );
|
pluginRealm.display( ps );
|
||||||
|
|
||||||
throw new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), cause );
|
throw new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), cause );
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PluginContainerException( mojoDescriptor, pluginRealm, "Unable to load the mojo '"
|
throw new PluginContainerException( mojoDescriptor, pluginRealm,
|
||||||
+ mojoDescriptor.getGoal() + "' (or one of its required components) from the plugin '"
|
"Unable to load the mojo '" + mojoDescriptor.getGoal()
|
||||||
+ pluginDescriptor.getId() + "'", e );
|
+ "' (or one of its required components) from the plugin '"
|
||||||
|
+ pluginDescriptor.getId() + "'", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mojo instanceof ContextEnabled )
|
if ( mojo instanceof ContextEnabled )
|
||||||
|
@ -653,8 +649,8 @@ public class DefaultMavenPluginManager
|
||||||
ValidatingConfigurationListener validator =
|
ValidatingConfigurationListener validator =
|
||||||
new ValidatingConfigurationListener( mojo, mojoDescriptor, listener );
|
new ValidatingConfigurationListener( mojo, mojoDescriptor, listener );
|
||||||
|
|
||||||
logger.debug( "Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId
|
logger.debug(
|
||||||
+ " configurator -->" );
|
"Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" );
|
||||||
|
|
||||||
configurator.configureComponent( mojo, configuration, expressionEvaluator, pluginRealm, validator );
|
configurator.configureComponent( mojo, configuration, expressionEvaluator, pluginRealm, validator );
|
||||||
|
|
||||||
|
@ -699,7 +695,7 @@ public class DefaultMavenPluginManager
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
||||||
PrintStream ps = new PrintStream( os );
|
PrintStream ps = new PrintStream( os );
|
||||||
ps.println( "A required class was missing during configuration of mojo " + mojoDescriptor.getId() + ": "
|
ps.println( "A required class was missing during configuration of mojo " + mojoDescriptor.getId() + ": "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
pluginRealm.display( ps );
|
pluginRealm.display( ps );
|
||||||
|
|
||||||
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e );
|
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e );
|
||||||
|
@ -708,8 +704,9 @@ public class DefaultMavenPluginManager
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 );
|
||||||
PrintStream ps = new PrintStream( os );
|
PrintStream ps = new PrintStream( os );
|
||||||
ps.println( "An API incompatibility was encountered during configuration of mojo " + mojoDescriptor.getId()
|
ps.println(
|
||||||
+ ": " + e.getClass().getName() + ": " + e.getMessage() );
|
"An API incompatibility was encountered during configuration of mojo " + mojoDescriptor.getId() + ": "
|
||||||
|
+ e.getClass().getName() + ": " + e.getMessage() );
|
||||||
pluginRealm.display( ps );
|
pluginRealm.display( ps );
|
||||||
|
|
||||||
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e );
|
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e );
|
||||||
|
@ -766,9 +763,8 @@ public class DefaultMavenPluginManager
|
||||||
}
|
}
|
||||||
catch ( ExpressionEvaluationException e )
|
catch ( ExpressionEvaluationException e )
|
||||||
{
|
{
|
||||||
String msg =
|
String msg = "Error evaluating the expression '" + expression + "' for configuration value '"
|
||||||
"Error evaluating the expression '" + expression + "' for configuration value '"
|
+ configuration.getName() + "'";
|
||||||
+ configuration.getName() + "'";
|
|
||||||
throw new ComponentConfigurationException( configuration, msg, e );
|
throw new ComponentConfigurationException( configuration, msg, e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -811,8 +807,7 @@ public class DefaultMavenPluginManager
|
||||||
RepositorySystemSession session )
|
RepositorySystemSession session )
|
||||||
throws PluginManagerException
|
throws PluginManagerException
|
||||||
{
|
{
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" ) Map<String, ExtensionRealmCache.CacheRecord> pluginRealms =
|
||||||
Map<String, ExtensionRealmCache.CacheRecord> pluginRealms =
|
|
||||||
(Map<String, ExtensionRealmCache.CacheRecord>) project.getContextValue( KEY_EXTENSIONS_REALMS );
|
(Map<String, ExtensionRealmCache.CacheRecord>) project.getContextValue( KEY_EXTENSIONS_REALMS );
|
||||||
if ( pluginRealms == null )
|
if ( pluginRealms == null )
|
||||||
{
|
{
|
||||||
|
@ -881,8 +876,8 @@ public class DefaultMavenPluginManager
|
||||||
extensionRecord = extensionRealmCache.get( extensionKey );
|
extensionRecord = extensionRealmCache.get( extensionKey );
|
||||||
if ( extensionRecord == null )
|
if ( extensionRecord == null )
|
||||||
{
|
{
|
||||||
ClassRealm extensionRealm = classRealmManager.createExtensionRealm( plugin,
|
ClassRealm extensionRealm =
|
||||||
toAetherArtifacts( artifacts ) );
|
classRealmManager.createExtensionRealm( plugin, toAetherArtifacts( artifacts ) );
|
||||||
|
|
||||||
// TODO figure out how to use the same PluginDescriptor when running mojos
|
// TODO figure out how to use the same PluginDescriptor when running mojos
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.project;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||||
|
@ -71,16 +70,10 @@ public class ExtensionDescriptorBuilder
|
||||||
|
|
||||||
if ( pluginDescriptorEntry != null )
|
if ( pluginDescriptorEntry != null )
|
||||||
{
|
{
|
||||||
InputStream is = pluginJar.getInputStream( pluginDescriptorEntry );
|
try ( InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ) )
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
extensionDescriptor = build( is );
|
extensionDescriptor = build( is );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,15 +83,10 @@ public class ExtensionDescriptorBuilder
|
||||||
|
|
||||||
if ( pluginXml.canRead() )
|
if ( pluginXml.canRead() )
|
||||||
{
|
{
|
||||||
InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) );
|
try ( InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
extensionDescriptor = build( is );
|
extensionDescriptor = build( is );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.project;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.model.building.ModelProblem;
|
||||||
|
import org.apache.maven.model.building.ModelProblemUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.model.building.ModelProblem;
|
|
||||||
import org.apache.maven.model.building.ModelProblemUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
*/
|
*/
|
||||||
|
@ -122,23 +122,28 @@ public class ProjectBuildingException
|
||||||
private static String createMessage( List<ProjectBuildingResult> results )
|
private static String createMessage( List<ProjectBuildingResult> results )
|
||||||
{
|
{
|
||||||
StringWriter buffer = new StringWriter( 1024 );
|
StringWriter buffer = new StringWriter( 1024 );
|
||||||
|
|
||||||
PrintWriter writer = new PrintWriter( buffer );
|
PrintWriter writer = new PrintWriter( buffer );
|
||||||
writer.println( "Some problems were encountered while processing the POMs:" );
|
writer.println( "Some problems were encountered while processing the POMs:" );
|
||||||
for ( ProjectBuildingResult result : results )
|
try
|
||||||
{
|
{
|
||||||
for ( ModelProblem problem : result.getProblems() )
|
|
||||||
|
for ( ProjectBuildingResult result : results )
|
||||||
{
|
{
|
||||||
writer.print( "[" );
|
for ( ModelProblem problem : result.getProblems() )
|
||||||
writer.print( problem.getSeverity() );
|
{
|
||||||
writer.print( "] " );
|
writer.print( "[" );
|
||||||
writer.print( problem.getMessage() );
|
writer.print( problem.getSeverity() );
|
||||||
writer.print( " @ " );
|
writer.print( "] " );
|
||||||
writer.println( ModelProblemUtils.formatLocation( problem, result.getProjectId() ) );
|
writer.print( problem.getMessage() );
|
||||||
|
writer.print( " @ " );
|
||||||
|
writer.println( ModelProblemUtils.formatLocation( problem, result.getProjectId() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.close();
|
finally
|
||||||
|
{
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,10 @@ package org.apache.maven.rtinfo.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.apache.maven.rtinfo.RuntimeInformation;
|
import org.apache.maven.rtinfo.RuntimeInformation;
|
||||||
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.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.eclipse.aether.util.version.GenericVersionScheme;
|
import org.eclipse.aether.util.version.GenericVersionScheme;
|
||||||
import org.eclipse.aether.version.InvalidVersionSpecificationException;
|
import org.eclipse.aether.version.InvalidVersionSpecificationException;
|
||||||
|
@ -35,6 +30,10 @@ import org.eclipse.aether.version.Version;
|
||||||
import org.eclipse.aether.version.VersionConstraint;
|
import org.eclipse.aether.version.VersionConstraint;
|
||||||
import org.eclipse.aether.version.VersionScheme;
|
import org.eclipse.aether.version.VersionScheme;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information about the current Maven runtime.
|
* Provides information about the current Maven runtime.
|
||||||
*/
|
*/
|
||||||
|
@ -56,34 +55,29 @@ public class DefaultRuntimeInformation
|
||||||
|
|
||||||
String resource = "META-INF/maven/org.apache.maven/maven-core/pom.properties";
|
String resource = "META-INF/maven/org.apache.maven/maven-core/pom.properties";
|
||||||
|
|
||||||
InputStream is = DefaultRuntimeInformation.class.getResourceAsStream( "/" + resource );
|
try ( InputStream is = DefaultRuntimeInformation.class.getResourceAsStream( "/" + resource ) )
|
||||||
if ( is != null )
|
|
||||||
{
|
{
|
||||||
try
|
if ( is != null )
|
||||||
{
|
{
|
||||||
props.load( is );
|
props.load( is );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
else
|
||||||
{
|
{
|
||||||
String msg = "Could not parse " + resource + ", Maven runtime information not available";
|
logger.warn(
|
||||||
if ( logger.isDebugEnabled() )
|
"Could not locate " + resource + " on classpath, Maven runtime information not available" );
|
||||||
{
|
|
||||||
logger.warn( msg, e );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn( msg );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
logger.warn( "Could not locate " + resource
|
String msg = "Could not parse " + resource + ", Maven runtime information not available";
|
||||||
+ " on classpath, Maven runtime information not available" );
|
if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.warn( msg, e );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.warn( msg );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String version = props.getProperty( "version", "" ).trim();
|
String version = props.getProperty( "version", "" ).trim();
|
||||||
|
|
|
@ -19,20 +19,18 @@ package org.apache.maven.toolchain;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
import org.apache.maven.toolchain.model.PersistedToolchains;
|
import org.apache.maven.toolchain.model.PersistedToolchains;
|
||||||
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
|
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
|
||||||
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.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
*
|
|
||||||
* @deprecated instead use {@link org.apache.maven.toolchain.building.DefaultToolchainsBuilder}
|
* @deprecated instead use {@link org.apache.maven.toolchain.building.DefaultToolchainsBuilder}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -51,21 +49,16 @@ public class DefaultToolchainsBuilder
|
||||||
|
|
||||||
if ( userToolchainsFile != null && userToolchainsFile.isFile() )
|
if ( userToolchainsFile != null && userToolchainsFile.isFile() )
|
||||||
{
|
{
|
||||||
Reader in = null;
|
try ( Reader in = ReaderFactory.newXmlReader( userToolchainsFile ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
in = ReaderFactory.newXmlReader( userToolchainsFile );
|
|
||||||
toolchains = new MavenToolchainsXpp3Reader().read( in );
|
toolchains = new MavenToolchainsXpp3Reader().read( in );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
throw new MisconfiguredToolchainException( "Cannot read toolchains file at "
|
throw new MisconfiguredToolchainException(
|
||||||
+ userToolchainsFile.getAbsolutePath(), e );
|
"Cannot read toolchains file at " + userToolchainsFile.getAbsolutePath(), e );
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( in );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ( userToolchainsFile != null )
|
else if ( userToolchainsFile != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,10 +19,6 @@ package org.apache.maven.settings;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.project.DefaultProjectBuilder;
|
import org.apache.maven.project.DefaultProjectBuilder;
|
||||||
|
@ -36,13 +32,16 @@ import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||||
import org.codehaus.plexus.ContainerConfiguration;
|
import org.codehaus.plexus.ContainerConfiguration;
|
||||||
import org.codehaus.plexus.PlexusConstants;
|
import org.codehaus.plexus.PlexusConstants;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||||
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
|
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
|
||||||
import org.eclipse.aether.repository.LocalRepository;
|
import org.eclipse.aether.repository.LocalRepository;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
public class PomConstructionWithSettingsTest
|
public class PomConstructionWithSettingsTest
|
||||||
extends PlexusTestCase
|
extends PlexusTestCase
|
||||||
{
|
{
|
||||||
|
@ -81,14 +80,18 @@ public class PomConstructionWithSettingsTest
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSettingsNoPom() throws Exception
|
public void testSettingsNoPom()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
PomTestWrapper pom = buildPom( "settings-no-pom" );
|
PomTestWrapper pom = buildPom( "settings-no-pom" );
|
||||||
assertEquals( "local-profile-prop-value", pom.getValue( "properties/local-profile-prop" ) );
|
assertEquals( "local-profile-prop-value", pom.getValue( "properties/local-profile-prop" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**MNG-4107 */
|
/**
|
||||||
public void testPomAndSettingsInterpolation() throws Exception
|
* MNG-4107
|
||||||
|
*/
|
||||||
|
public void testPomAndSettingsInterpolation()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
PomTestWrapper pom = buildPom( "test-pom-and-settings-interpolation" );
|
PomTestWrapper pom = buildPom( "test-pom-and-settings-interpolation" );
|
||||||
assertEquals( "applied", pom.getValue( "properties/settingsProfile" ) );
|
assertEquals( "applied", pom.getValue( "properties/settingsProfile" ) );
|
||||||
|
@ -97,8 +100,11 @@ public class PomConstructionWithSettingsTest
|
||||||
assertEquals( "settings", pom.getValue( "properties/pomVsSettingsInterpolated" ) );
|
assertEquals( "settings", pom.getValue( "properties/pomVsSettingsInterpolated" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**MNG-4107 */
|
/**
|
||||||
public void testRepositories() throws Exception
|
* MNG-4107
|
||||||
|
*/
|
||||||
|
public void testRepositories()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
PomTestWrapper pom = buildPom( "repositories" );
|
PomTestWrapper pom = buildPom( "repositories" );
|
||||||
assertEquals( "maven-core-it-0", pom.getValue( "repositories[1]/id" ) );
|
assertEquals( "maven-core-it-0", pom.getValue( "repositories[1]/id" ) );
|
||||||
|
@ -122,13 +128,15 @@ public class PomConstructionWithSettingsTest
|
||||||
String localRepoUrl =
|
String localRepoUrl =
|
||||||
System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
||||||
localRepoUrl = "file://" + localRepoUrl;
|
localRepoUrl = "file://" + localRepoUrl;
|
||||||
config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl,
|
config.setLocalRepository(
|
||||||
new DefaultRepositoryLayout(), null, null ) );
|
repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null,
|
||||||
|
null ) );
|
||||||
config.setActiveProfileIds( settings.getActiveProfiles() );
|
config.setActiveProfileIds( settings.getActiveProfiles() );
|
||||||
|
|
||||||
DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
|
DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
|
||||||
LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() );
|
LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() );
|
||||||
repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) );
|
repoSession.setLocalRepositoryManager(
|
||||||
|
new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) );
|
||||||
config.setRepositorySession( repoSession );
|
config.setRepositorySession( repoSession );
|
||||||
|
|
||||||
return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() );
|
return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() );
|
||||||
|
@ -139,21 +147,12 @@ public class PomConstructionWithSettingsTest
|
||||||
{
|
{
|
||||||
Settings settings = null;
|
Settings settings = null;
|
||||||
|
|
||||||
Reader reader = null;
|
try ( Reader reader = ReaderFactory.newXmlReader( settingsFile ) )
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
reader = ReaderFactory.newXmlReader( settingsFile );
|
|
||||||
|
|
||||||
SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
|
SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
|
||||||
|
|
||||||
settings = modelReader.read( reader );
|
settings = modelReader.read( reader );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( reader );
|
|
||||||
}
|
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,38 +19,38 @@ package org.apache.maven.toolchain;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
|
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
|
||||||
import org.apache.maven.toolchain.model.PersistedToolchains;
|
import org.apache.maven.toolchain.model.PersistedToolchains;
|
||||||
import org.apache.maven.toolchain.model.ToolchainModel;
|
import org.apache.maven.toolchain.model.ToolchainModel;
|
||||||
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
|
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
public class DefaultToolchainTest
|
public class DefaultToolchainTest
|
||||||
{
|
{
|
||||||
@Mock
|
@Mock
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader();
|
private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
MockitoAnnotations.initMocks( this );
|
MockitoAnnotations.initMocks( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefaultToolchain newDefaultToolchain( ToolchainModel model )
|
private DefaultToolchain newDefaultToolchain( ToolchainModel model )
|
||||||
{
|
{
|
||||||
return new DefaultToolchain( model, logger )
|
return new DefaultToolchain( model, logger )
|
||||||
|
@ -102,14 +102,14 @@ public class DefaultToolchainTest
|
||||||
DefaultToolchain toolchain = newDefaultToolchain( model );
|
DefaultToolchain toolchain = newDefaultToolchain( model );
|
||||||
assertEquals( logger, toolchain.getLog() );
|
assertEquals( logger, toolchain.getLog() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMissingRequirementProperty()
|
public void testMissingRequirementProperty()
|
||||||
{
|
{
|
||||||
ToolchainModel model = new ToolchainModel();
|
ToolchainModel model = new ToolchainModel();
|
||||||
model.setType( "TYPE" );
|
model.setType( "TYPE" );
|
||||||
DefaultToolchain toolchain = newDefaultToolchain( model );
|
DefaultToolchain toolchain = newDefaultToolchain( model );
|
||||||
|
|
||||||
assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) );
|
assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) );
|
||||||
verify( logger ).debug( "Toolchain type:TYPE{} is missing required property: name" );
|
verify( logger ).debug( "Toolchain type:TYPE{} is missing required property: name" );
|
||||||
}
|
}
|
||||||
|
@ -122,22 +122,19 @@ public class DefaultToolchainTest
|
||||||
model.setType( "TYPE" );
|
model.setType( "TYPE" );
|
||||||
DefaultToolchain toolchain = newDefaultToolchain( model );
|
DefaultToolchain toolchain = newDefaultToolchain( model );
|
||||||
toolchain.addProvideToken( "name", RequirementMatcherFactory.createExactMatcher( "Jane Doe" ) );
|
toolchain.addProvideToken( "name", RequirementMatcherFactory.createExactMatcher( "Jane Doe" ) );
|
||||||
|
|
||||||
assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) );
|
assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) );
|
||||||
verify( logger ).debug( "Toolchain type:TYPE{name = Jane Doe} doesn't match required property: name" );
|
verify( logger ).debug( "Toolchain type:TYPE{name = Jane Doe} doesn't match required property: name" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() throws Exception
|
public void testEquals()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
InputStream jdksIS = null;
|
try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
||||||
InputStream jdksExtraIS = null;
|
InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" );
|
|
||||||
|
|
||||||
PersistedToolchains jdks = reader.read( jdksIS );
|
PersistedToolchains jdks = reader.read( jdksIS );
|
||||||
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
|
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
|
||||||
|
|
||||||
|
@ -149,10 +146,5 @@ public class DefaultToolchainTest
|
||||||
assertFalse( tc2.equals( tc1 ) );
|
assertFalse( tc2.equals( tc1 ) );
|
||||||
assertTrue( tc2.equals( tc2 ) );
|
assertTrue( tc2.equals( tc2 ) );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( jdksIS );
|
|
||||||
IOUtil.close( jdksExtraIS );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,18 +19,17 @@ package org.apache.maven.toolchain.merge;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import org.apache.maven.toolchain.model.PersistedToolchains;
|
import org.apache.maven.toolchain.model.PersistedToolchains;
|
||||||
import org.apache.maven.toolchain.model.ToolchainModel;
|
import org.apache.maven.toolchain.model.ToolchainModel;
|
||||||
import org.apache.maven.toolchain.model.TrackableBase;
|
import org.apache.maven.toolchain.model.TrackableBase;
|
||||||
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
|
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class MavenToolchainMergerTest
|
public class MavenToolchainMergerTest
|
||||||
{
|
{
|
||||||
private MavenToolchainMerger merger = new MavenToolchainMerger();
|
private MavenToolchainMerger merger = new MavenToolchainMerger();
|
||||||
|
@ -41,97 +40,71 @@ public class MavenToolchainMergerTest
|
||||||
public void testMergeNulls()
|
public void testMergeNulls()
|
||||||
{
|
{
|
||||||
merger.merge( null, null, null );
|
merger.merge( null, null, null );
|
||||||
|
|
||||||
PersistedToolchains pt = new PersistedToolchains();
|
PersistedToolchains pt = new PersistedToolchains();
|
||||||
merger.merge( pt, null, null );
|
merger.merge( pt, null, null );
|
||||||
merger.merge( null, pt, null );
|
merger.merge( null, pt, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeJdk() throws Exception
|
public void testMergeJdk()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
InputStream isDominant = null;
|
try ( InputStream isDominant = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
||||||
InputStream isRecessive = null;
|
InputStream isRecessive = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
isDominant = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
isRecessive = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
|
|
||||||
PersistedToolchains dominant = reader.read( isDominant );
|
PersistedToolchains dominant = reader.read( isDominant );
|
||||||
PersistedToolchains recessive = reader.read( isRecessive );
|
PersistedToolchains recessive = reader.read( isRecessive );
|
||||||
assertEquals( 2, dominant.getToolchains().size() );
|
assertEquals( 2, dominant.getToolchains().size() );
|
||||||
|
|
||||||
merger.merge( dominant, recessive, TrackableBase.USER_LEVEL );
|
merger.merge( dominant, recessive, TrackableBase.USER_LEVEL );
|
||||||
assertEquals( 2, dominant.getToolchains().size() );
|
assertEquals( 2, dominant.getToolchains().size() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( isDominant );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeJdkExtra() throws Exception
|
public void testMergeJdkExtra()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
InputStream jdksIS = null;
|
try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
||||||
InputStream jdksExtraIS = null;
|
InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" );
|
|
||||||
|
|
||||||
PersistedToolchains jdks = reader.read( jdksIS );
|
PersistedToolchains jdks = reader.read( jdksIS );
|
||||||
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
|
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
|
|
||||||
merger.merge( jdks, jdksExtra, TrackableBase.USER_LEVEL );
|
merger.merge( jdks, jdksExtra, TrackableBase.USER_LEVEL );
|
||||||
assertEquals( 4, jdks.getToolchains().size() );
|
assertEquals( 4, jdks.getToolchains().size() );
|
||||||
assertEquals( 2, jdksExtra.getToolchains().size() );
|
assertEquals( 2, jdksExtra.getToolchains().size() );
|
||||||
}
|
}
|
||||||
finally
|
try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
||||||
|
InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) )
|
||||||
{
|
{
|
||||||
IOUtil.close( jdksIS );
|
|
||||||
IOUtil.close( jdksExtraIS );
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" );
|
|
||||||
|
|
||||||
PersistedToolchains jdks = reader.read( jdksIS );
|
PersistedToolchains jdks = reader.read( jdksIS );
|
||||||
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
|
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
|
|
||||||
// switch dominant with reccessive
|
// switch dominant with reccessive
|
||||||
merger.merge( jdksExtra, jdks, TrackableBase.USER_LEVEL );
|
merger.merge( jdksExtra, jdks, TrackableBase.USER_LEVEL );
|
||||||
assertEquals( 4, jdksExtra.getToolchains().size() );
|
assertEquals( 4, jdksExtra.getToolchains().size() );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( jdksIS );
|
|
||||||
IOUtil.close( jdksExtraIS );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeJdkExtend() throws Exception
|
public void testMergeJdkExtend()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
InputStream jdksIS = null;
|
try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
||||||
InputStream jdksExtendIS = null;
|
InputStream jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" );
|
|
||||||
|
|
||||||
PersistedToolchains jdks = reader.read( jdksIS );
|
PersistedToolchains jdks = reader.read( jdksIS );
|
||||||
PersistedToolchains jdksExtend = reader.read( jdksExtendIS );
|
PersistedToolchains jdksExtend = reader.read( jdksExtendIS );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
|
|
||||||
merger.merge( jdks, jdksExtend, TrackableBase.USER_LEVEL );
|
merger.merge( jdks, jdksExtend, TrackableBase.USER_LEVEL );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
Xpp3Dom config0 = (Xpp3Dom) jdks.getToolchains().get( 0 ).getConfiguration();
|
Xpp3Dom config0 = (Xpp3Dom) jdks.getToolchains().get( 0 ).getConfiguration();
|
||||||
assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() );
|
assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() );
|
||||||
assertEquals( 2, config0.getChildCount() );
|
assertEquals( 2, config0.getChildCount() );
|
||||||
Xpp3Dom config1 = (Xpp3Dom) jdks.getToolchains().get( 1 ).getConfiguration();
|
Xpp3Dom config1 = (Xpp3Dom) jdks.getToolchains().get( 1 ).getConfiguration();
|
||||||
|
@ -139,25 +112,17 @@ public class MavenToolchainMergerTest
|
||||||
assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() );
|
assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() );
|
||||||
assertEquals( 2, jdksExtend.getToolchains().size() );
|
assertEquals( 2, jdksExtend.getToolchains().size() );
|
||||||
}
|
}
|
||||||
finally
|
try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
||||||
|
InputStream jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" ) )
|
||||||
{
|
{
|
||||||
IOUtil.close( jdksIS );
|
|
||||||
IOUtil.close( jdksExtendIS );
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
|
|
||||||
jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" );
|
|
||||||
|
|
||||||
PersistedToolchains jdks = reader.read( jdksIS );
|
PersistedToolchains jdks = reader.read( jdksIS );
|
||||||
PersistedToolchains jdksExtend = reader.read( jdksExtendIS );
|
PersistedToolchains jdksExtend = reader.read( jdksExtendIS );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
|
|
||||||
// switch dominant with reccessive
|
// switch dominant with reccessive
|
||||||
merger.merge( jdksExtend, jdks, TrackableBase.USER_LEVEL );
|
merger.merge( jdksExtend, jdks, TrackableBase.USER_LEVEL );
|
||||||
assertEquals( 2, jdksExtend.getToolchains().size() );
|
assertEquals( 2, jdksExtend.getToolchains().size() );
|
||||||
Xpp3Dom config0 = (Xpp3Dom) jdksExtend.getToolchains().get( 0 ).getConfiguration();
|
Xpp3Dom config0 = (Xpp3Dom) jdksExtend.getToolchains().get( 0 ).getConfiguration();
|
||||||
assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() );
|
assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() );
|
||||||
assertEquals( 2, config0.getChildCount() );
|
assertEquals( 2, config0.getChildCount() );
|
||||||
Xpp3Dom config1 = (Xpp3Dom) jdksExtend.getToolchains().get( 1 ).getConfiguration();
|
Xpp3Dom config1 = (Xpp3Dom) jdksExtend.getToolchains().get( 1 ).getConfiguration();
|
||||||
|
@ -165,12 +130,6 @@ public class MavenToolchainMergerTest
|
||||||
assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() );
|
assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() );
|
||||||
assertEquals( 2, jdks.getToolchains().size() );
|
assertEquals( 2, jdks.getToolchains().size() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( jdksIS );
|
|
||||||
IOUtil.close( jdksExtendIS );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.maven.cli;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.codehaus.plexus.util.Os;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -26,15 +29,10 @@ import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.Os;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class used to report errors, statistics, application version info, etc.
|
* Utility class used to report errors, statistics, application version info, etc.
|
||||||
*
|
*
|
||||||
* @author jdcasey
|
* @author jdcasey
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class CLIReportingUtils
|
public final class CLIReportingUtils
|
||||||
{
|
{
|
||||||
|
@ -42,8 +40,11 @@ public final class CLIReportingUtils
|
||||||
public static final long MB = 1024 * 1024;
|
public static final long MB = 1024 * 1024;
|
||||||
|
|
||||||
private static final long ONE_SECOND = 1000L;
|
private static final long ONE_SECOND = 1000L;
|
||||||
|
|
||||||
private static final long ONE_MINUTE = 60 * ONE_SECOND;
|
private static final long ONE_MINUTE = 60 * ONE_SECOND;
|
||||||
|
|
||||||
private static final long ONE_HOUR = 60 * ONE_MINUTE;
|
private static final long ONE_HOUR = 60 * ONE_MINUTE;
|
||||||
|
|
||||||
private static final long ONE_DAY = 24 * ONE_HOUR;
|
private static final long ONE_DAY = 24 * ONE_HOUR;
|
||||||
// CHECKSTYLE_ON: MagicNumber
|
// CHECKSTYLE_ON: MagicNumber
|
||||||
|
|
||||||
|
@ -55,8 +56,12 @@ public final class CLIReportingUtils
|
||||||
Properties properties = getBuildProperties();
|
Properties properties = getBuildProperties();
|
||||||
StringBuilder version = new StringBuilder();
|
StringBuilder version = new StringBuilder();
|
||||||
version.append( createMavenVersionString( properties ) ).append( ls );
|
version.append( createMavenVersionString( properties ) ).append( ls );
|
||||||
version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: "
|
version.append( reduce(
|
||||||
+ System.getProperty( "maven.home", "<unknown maven home>" ) ) ).append( ls );
|
properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home",
|
||||||
|
"<unknown maven "
|
||||||
|
+ "home>" ) ) )
|
||||||
|
.append(
|
||||||
|
ls );
|
||||||
version.append( "Java version: " ).append(
|
version.append( "Java version: " ).append(
|
||||||
System.getProperty( "java.version", "<unknown java version>" ) ).append( ", vendor: " ).append(
|
System.getProperty( "java.version", "<unknown java version>" ) ).append( ", vendor: " ).append(
|
||||||
System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( ls );
|
System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( ls );
|
||||||
|
@ -105,10 +110,10 @@ public final class CLIReportingUtils
|
||||||
static Properties getBuildProperties()
|
static Properties getBuildProperties()
|
||||||
{
|
{
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
InputStream resourceAsStream = null;
|
|
||||||
try
|
try ( InputStream resourceAsStream = MavenCli.class.getResourceAsStream(
|
||||||
|
"/org/apache/maven/messages/build.properties" ) )
|
||||||
{
|
{
|
||||||
resourceAsStream = MavenCli.class.getResourceAsStream( "/org/apache/maven/messages/build.properties" );
|
|
||||||
|
|
||||||
if ( resourceAsStream != null )
|
if ( resourceAsStream != null )
|
||||||
{
|
{
|
||||||
|
@ -119,10 +124,6 @@ public final class CLIReportingUtils
|
||||||
{
|
{
|
||||||
System.err.println( "Unable determine version from JAR file: " + e.getMessage() );
|
System.err.println( "Unable determine version from JAR file: " + e.getMessage() );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( resourceAsStream );
|
|
||||||
}
|
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,27 +19,9 @@ package org.apache.maven.cli;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import com.google.common.base.Charsets;
|
||||||
import java.io.Console;
|
import com.google.common.io.Files;
|
||||||
import java.io.File;
|
import com.google.inject.AbstractModule;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.UnrecognizedOptionException;
|
import org.apache.commons.cli.UnrecognizedOptionException;
|
||||||
|
@ -93,7 +75,6 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||||
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
|
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||||
import org.codehaus.plexus.logging.LoggerManager;
|
import org.codehaus.plexus.logging.LoggerManager;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import org.eclipse.aether.transfer.TransferListener;
|
import org.eclipse.aether.transfer.TransferListener;
|
||||||
|
@ -106,15 +87,32 @@ import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
|
||||||
import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
|
import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
|
||||||
import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
|
import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import java.io.BufferedInputStream;
|
||||||
import com.google.common.io.Files;
|
import java.io.Console;
|
||||||
import com.google.inject.AbstractModule;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
// TODO: push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs
|
// TODO: push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
* @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE
|
* @noinspection UseOfSystemOutOrSystemErr, ACCESS_STATIC_VIA_INSTANCE
|
||||||
*/
|
*/
|
||||||
public class MavenCli
|
public class MavenCli
|
||||||
{
|
{
|
||||||
|
@ -143,8 +141,8 @@ public class MavenCli
|
||||||
|
|
||||||
public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" );
|
public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" );
|
||||||
|
|
||||||
public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE =
|
public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE =
|
||||||
new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/toolchains.xml" );
|
new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/toolchains.xml" );
|
||||||
|
|
||||||
private static final String EXT_CLASS_PATH = "maven.ext.class.path";
|
private static final String EXT_CLASS_PATH = "maven.ext.class.path";
|
||||||
|
|
||||||
|
@ -171,7 +169,7 @@ public class MavenCli
|
||||||
private DefaultSecDispatcher dispatcher;
|
private DefaultSecDispatcher dispatcher;
|
||||||
|
|
||||||
private Map<String, ConfigurationProcessor> configurationProcessors;
|
private Map<String, ConfigurationProcessor> configurationProcessors;
|
||||||
|
|
||||||
public MavenCli()
|
public MavenCli()
|
||||||
{
|
{
|
||||||
this( null );
|
this( null );
|
||||||
|
@ -190,7 +188,9 @@ public class MavenCli
|
||||||
System.exit( result );
|
System.exit( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @noinspection ConfusingMainMethod */
|
/**
|
||||||
|
* @noinspection ConfusingMainMethod
|
||||||
|
*/
|
||||||
public static int main( String[] args, ClassWorld classWorld )
|
public static int main( String[] args, ClassWorld classWorld )
|
||||||
{
|
{
|
||||||
MavenCli cli = new MavenCli();
|
MavenCli cli = new MavenCli();
|
||||||
|
@ -328,8 +328,9 @@ public class MavenCli
|
||||||
String basedirProperty = System.getProperty( MULTIMODULE_PROJECT_DIRECTORY );
|
String basedirProperty = System.getProperty( MULTIMODULE_PROJECT_DIRECTORY );
|
||||||
if ( basedirProperty == null )
|
if ( basedirProperty == null )
|
||||||
{
|
{
|
||||||
System.err.format( "-D%s system property is not set."
|
System.err.format(
|
||||||
+ " Check $M2_HOME environment variable and mvn script match.", MULTIMODULE_PROJECT_DIRECTORY );
|
"-D%s system property is not set." + " Check $M2_HOME environment variable and mvn script match.",
|
||||||
|
MULTIMODULE_PROJECT_DIRECTORY );
|
||||||
throw new ExitException( 1 );
|
throw new ExitException( 1 );
|
||||||
}
|
}
|
||||||
File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" );
|
File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" );
|
||||||
|
@ -522,12 +523,9 @@ public class MavenCli
|
||||||
|
|
||||||
ClassRealm containerRealm = setupContainerRealm( cliRequest.classWorld, coreRealm, extClassPath, extensions );
|
ClassRealm containerRealm = setupContainerRealm( cliRequest.classWorld, coreRealm, extClassPath, extensions );
|
||||||
|
|
||||||
ContainerConfiguration cc = new DefaultContainerConfiguration()
|
ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld( cliRequest.classWorld ).setRealm(
|
||||||
.setClassWorld( cliRequest.classWorld )
|
containerRealm ).setClassPathScanning( PlexusConstants.SCANNING_INDEX ).setAutoWiring( true ).setName(
|
||||||
.setRealm( containerRealm )
|
"maven" );
|
||||||
.setClassPathScanning( PlexusConstants.SCANNING_INDEX )
|
|
||||||
.setAutoWiring( true )
|
|
||||||
.setName( "maven" );
|
|
||||||
|
|
||||||
Set<String> exportedArtifacts = new HashSet<>( coreEntry.getExportedArtifacts() );
|
Set<String> exportedArtifacts = new HashSet<>( coreEntry.getExportedArtifacts() );
|
||||||
Set<String> exportedPackages = new HashSet<>( coreEntry.getExportedPackages() );
|
Set<String> exportedPackages = new HashSet<>( coreEntry.getExportedPackages() );
|
||||||
|
@ -586,7 +584,7 @@ public class MavenCli
|
||||||
modelProcessor = createModelProcessor( container );
|
modelProcessor = createModelProcessor( container );
|
||||||
|
|
||||||
configurationProcessors = container.lookupMap( ConfigurationProcessor.class );
|
configurationProcessors = container.lookupMap( ConfigurationProcessor.class );
|
||||||
|
|
||||||
toolchainsBuilder = container.lookup( ToolchainsBuilder.class );
|
toolchainsBuilder = container.lookup( ToolchainsBuilder.class );
|
||||||
|
|
||||||
dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" );
|
dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" );
|
||||||
|
@ -643,19 +641,19 @@ public class MavenCli
|
||||||
Thread.currentThread().setContextClassLoader( container.getContainerRealm() );
|
Thread.currentThread().setContextClassLoader( container.getContainerRealm() );
|
||||||
|
|
||||||
executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class );
|
executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class );
|
||||||
|
|
||||||
configurationProcessors = container.lookupMap( ConfigurationProcessor.class );
|
configurationProcessors = container.lookupMap( ConfigurationProcessor.class );
|
||||||
|
|
||||||
configure( cliRequest );
|
configure( cliRequest );
|
||||||
|
|
||||||
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request );
|
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request );
|
||||||
|
|
||||||
request = populateRequest( cliRequest, request );
|
request = populateRequest( cliRequest, request );
|
||||||
|
|
||||||
request = executionRequestPopulator.populateDefaults( request );
|
request = executionRequestPopulator.populateDefaults( request );
|
||||||
|
|
||||||
BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class );
|
BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class );
|
||||||
|
|
||||||
return resolver.loadCoreExtensions( request, providedArtifacts, extensions );
|
return resolver.loadCoreExtensions( request, providedArtifacts, extensions );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -680,16 +678,13 @@ public class MavenCli
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader();
|
CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader();
|
||||||
InputStream is = null;
|
|
||||||
try
|
try ( InputStream is = new BufferedInputStream( new FileInputStream( extensionsFile ) ) )
|
||||||
{
|
{
|
||||||
is = new BufferedInputStream( new FileInputStream( extensionsFile ) );
|
|
||||||
return parser.read( is ).getExtensions();
|
return parser.read( is ).getExtensions();
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( is );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassRealm setupContainerRealm( ClassWorld classWorld, ClassRealm coreRealm, List<File> extClassPath,
|
private ClassRealm setupContainerRealm( ClassWorld classWorld, ClassRealm coreRealm, List<File> extClassPath,
|
||||||
|
@ -790,8 +785,8 @@ public class MavenCli
|
||||||
|
|
||||||
DefaultPlexusCipher cipher = new DefaultPlexusCipher();
|
DefaultPlexusCipher cipher = new DefaultPlexusCipher();
|
||||||
|
|
||||||
System.out.println( cipher.encryptAndDecorate( passwd,
|
System.out.println(
|
||||||
DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) );
|
cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) );
|
||||||
|
|
||||||
throw new ExitException( 0 );
|
throw new ExitException( 0 );
|
||||||
}
|
}
|
||||||
|
@ -846,17 +841,18 @@ public class MavenCli
|
||||||
private void repository( CliRequest cliRequest )
|
private void repository( CliRequest cliRequest )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if ( cliRequest.commandLine.hasOption( CLIManager.LEGACY_LOCAL_REPOSITORY )
|
if ( cliRequest.commandLine.hasOption( CLIManager.LEGACY_LOCAL_REPOSITORY ) || Boolean.getBoolean(
|
||||||
|| Boolean.getBoolean( "maven.legacyLocalRepo" ) )
|
"maven.legacyLocalRepo" ) )
|
||||||
{
|
{
|
||||||
cliRequest.request.setUseLegacyLocalRepository( true );
|
cliRequest.request.setUseLegacyLocalRepository( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int execute( CliRequest cliRequest ) throws MavenExecutionRequestPopulationException
|
private int execute( CliRequest cliRequest )
|
||||||
|
throws MavenExecutionRequestPopulationException
|
||||||
{
|
{
|
||||||
MavenExecutionRequest request = executionRequestPopulator.populateDefaults( cliRequest.request );
|
MavenExecutionRequest request = executionRequestPopulator.populateDefaults( cliRequest.request );
|
||||||
|
|
||||||
eventSpyDispatcher.onEvent( request );
|
eventSpyDispatcher.onEvent( request );
|
||||||
|
|
||||||
MavenExecutionResult result = maven.execute( request );
|
MavenExecutionResult result = maven.execute( request );
|
||||||
|
@ -900,7 +896,7 @@ public class MavenCli
|
||||||
{
|
{
|
||||||
slf4jLogger.error( "" );
|
slf4jLogger.error( "" );
|
||||||
slf4jLogger.error( "For more information about the errors and possible solutions"
|
slf4jLogger.error( "For more information about the errors and possible solutions"
|
||||||
+ ", please read the following articles:" );
|
+ ", please read the following articles:" );
|
||||||
|
|
||||||
for ( Map.Entry<String, String> entry : references.entrySet() )
|
for ( Map.Entry<String, String> entry : references.entrySet() )
|
||||||
{
|
{
|
||||||
|
@ -967,8 +963,8 @@ public class MavenCli
|
||||||
{
|
{
|
||||||
String line = indent + lines[i].trim();
|
String line = indent + lines[i].trim();
|
||||||
|
|
||||||
if ( ( i == lines.length - 1 )
|
if ( ( i == lines.length - 1 ) && ( showErrors
|
||||||
&& ( showErrors || ( summary.getException() instanceof InternalErrorException ) ) )
|
|| ( summary.getException() instanceof InternalErrorException ) ) )
|
||||||
{
|
{
|
||||||
slf4jLogger.error( line, summary.getException() );
|
slf4jLogger.error( line, summary.getException() );
|
||||||
}
|
}
|
||||||
|
@ -997,7 +993,7 @@ public class MavenCli
|
||||||
// it can be accessed by configuration processors.
|
// it can be accessed by configuration processors.
|
||||||
//
|
//
|
||||||
cliRequest.request.setEventSpyDispatcher( eventSpyDispatcher );
|
cliRequest.request.setEventSpyDispatcher( eventSpyDispatcher );
|
||||||
|
|
||||||
//
|
//
|
||||||
// We expect at most 2 implementations to be available. The SettingsXmlConfigurationProcessor implementation
|
// We expect at most 2 implementations to be available. The SettingsXmlConfigurationProcessor implementation
|
||||||
// is always available in the core and likely always will be, but we may have another ConfigurationProcessor
|
// is always available in the core and likely always will be, but we may have another ConfigurationProcessor
|
||||||
|
@ -1006,15 +1002,15 @@ public class MavenCli
|
||||||
// the default SettingsXmlConfigurationProcessor.
|
// the default SettingsXmlConfigurationProcessor.
|
||||||
//
|
//
|
||||||
int userSuppliedConfigurationProcessorCount = configurationProcessors.size() - 1;
|
int userSuppliedConfigurationProcessorCount = configurationProcessors.size() - 1;
|
||||||
|
|
||||||
if ( userSuppliedConfigurationProcessorCount == 0 )
|
if ( userSuppliedConfigurationProcessorCount == 0 )
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Our settings.xml source is historically how we have configured Maven from the CLI so we are going to
|
// Our settings.xml source is historically how we have configured Maven from the CLI so we are going to
|
||||||
// have to honour its existence forever. So let's run it.
|
// have to honour its existence forever. So let's run it.
|
||||||
//
|
//
|
||||||
configurationProcessors.get( SettingsXmlConfigurationProcessor.HINT ).process( cliRequest );
|
configurationProcessors.get( SettingsXmlConfigurationProcessor.HINT ).process( cliRequest );
|
||||||
}
|
}
|
||||||
else if ( userSuppliedConfigurationProcessorCount == 1 )
|
else if ( userSuppliedConfigurationProcessorCount == 1 )
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -1028,7 +1024,7 @@ public class MavenCli
|
||||||
ConfigurationProcessor configurationProcessor = entry.getValue();
|
ConfigurationProcessor configurationProcessor = entry.getValue();
|
||||||
configurationProcessor.process( cliRequest );
|
configurationProcessor.process( cliRequest );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( userSuppliedConfigurationProcessorCount > 1 )
|
else if ( userSuppliedConfigurationProcessorCount > 1 )
|
||||||
{
|
{
|
||||||
|
@ -1036,7 +1032,7 @@ public class MavenCli
|
||||||
// There are too many ConfigurationProcessors so we don't know which one to run so report the error.
|
// There are too many ConfigurationProcessors so we don't know which one to run so report the error.
|
||||||
//
|
//
|
||||||
StringBuilder sb = new StringBuilder(
|
StringBuilder sb = new StringBuilder(
|
||||||
String.format( "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n",
|
String.format( "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n",
|
||||||
userSuppliedConfigurationProcessorCount ) );
|
userSuppliedConfigurationProcessorCount ) );
|
||||||
for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() )
|
for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() )
|
||||||
{
|
{
|
||||||
|
@ -1049,9 +1045,9 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
sb.append( String.format( "\n" ) );
|
sb.append( String.format( "\n" ) );
|
||||||
throw new Exception( sb.toString() );
|
throw new Exception( sb.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "checkstyle:methodlength" )
|
@SuppressWarnings( "checkstyle:methodlength" )
|
||||||
private void toolchains( CliRequest cliRequest )
|
private void toolchains( CliRequest cliRequest )
|
||||||
throws Exception
|
throws Exception
|
||||||
|
@ -1066,8 +1062,8 @@ public class MavenCli
|
||||||
|
|
||||||
if ( !userToolchainsFile.isFile() )
|
if ( !userToolchainsFile.isFile() )
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException( "The specified user toolchains file does not exist: "
|
throw new FileNotFoundException(
|
||||||
+ userToolchainsFile );
|
"The specified user toolchains file does not exist: " + userToolchainsFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1085,8 +1081,8 @@ public class MavenCli
|
||||||
|
|
||||||
if ( !globalToolchainsFile.isFile() )
|
if ( !globalToolchainsFile.isFile() )
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException( "The specified global toolchains file does not exist: "
|
throw new FileNotFoundException(
|
||||||
+ globalToolchainsFile );
|
"The specified global toolchains file does not exist: " + globalToolchainsFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1109,10 +1105,11 @@ public class MavenCli
|
||||||
|
|
||||||
eventSpyDispatcher.onEvent( toolchainsRequest );
|
eventSpyDispatcher.onEvent( toolchainsRequest );
|
||||||
|
|
||||||
slf4jLogger.debug( "Reading global toolchains from "
|
slf4jLogger.debug(
|
||||||
+ getLocation( toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile ) );
|
"Reading global toolchains from " + getLocation( toolchainsRequest.getGlobalToolchainsSource(),
|
||||||
slf4jLogger.debug( "Reading user toolchains from "
|
globalToolchainsFile ) );
|
||||||
+ getLocation( toolchainsRequest.getUserToolchainsSource(), userToolchainsFile ) );
|
slf4jLogger.debug( "Reading user toolchains from " + getLocation( toolchainsRequest.getUserToolchainsSource(),
|
||||||
|
userToolchainsFile ) );
|
||||||
|
|
||||||
ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
|
ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
|
||||||
|
|
||||||
|
@ -1162,7 +1159,7 @@ public class MavenCli
|
||||||
if ( commandLine.hasOption( deprecatedOption ) )
|
if ( commandLine.hasOption( deprecatedOption ) )
|
||||||
{
|
{
|
||||||
slf4jLogger.warn( "Command line option -" + deprecatedOption
|
slf4jLogger.warn( "Command line option -" + deprecatedOption
|
||||||
+ " is deprecated and will be removed in future Maven versions." );
|
+ " is deprecated and will be removed in future Maven versions." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1186,8 +1183,7 @@ public class MavenCli
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" ) List<String> goals = commandLine.getArgList();
|
||||||
List<String> goals = commandLine.getArgList();
|
|
||||||
|
|
||||||
boolean recursive = true;
|
boolean recursive = true;
|
||||||
|
|
||||||
|
@ -1317,16 +1313,15 @@ public class MavenCli
|
||||||
userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE;
|
userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.setBaseDirectory( baseDirectory ).setGoals( goals )
|
request.setBaseDirectory( baseDirectory ).setGoals( goals ).setSystemProperties(
|
||||||
.setSystemProperties( cliRequest.systemProperties )
|
cliRequest.systemProperties ).setUserProperties( cliRequest.userProperties ).setReactorFailureBehavior(
|
||||||
.setUserProperties( cliRequest.userProperties )
|
reactorFailureBehaviour ) // default: fail fast
|
||||||
.setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast
|
|
||||||
.setRecursive( recursive ) // default: true
|
.setRecursive( recursive ) // default: true
|
||||||
.setShowErrors( showErrors ) // default: false
|
.setShowErrors( showErrors ) // default: false
|
||||||
.addActiveProfiles( activeProfiles ) // optional
|
.addActiveProfiles( activeProfiles ) // optional
|
||||||
.addInactiveProfiles( inactiveProfiles ) // optional
|
.addInactiveProfiles( inactiveProfiles ) // optional
|
||||||
.setExecutionListener( executionListener )
|
.setExecutionListener( executionListener ).setTransferListener(
|
||||||
.setTransferListener( transferListener ) // default: batch mode which goes along with interactive
|
transferListener ) // default: batch mode which goes along with interactive
|
||||||
.setUpdateSnapshots( updateSnapshots ) // default: false
|
.setUpdateSnapshots( updateSnapshots ) // default: false
|
||||||
.setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
|
.setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
|
||||||
.setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
|
.setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
|
||||||
|
@ -1399,18 +1394,18 @@ public class MavenCli
|
||||||
request.setExcludedProjects( exclProjects );
|
request.setExcludedProjects( exclProjects );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
|
if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && !commandLine.hasOption(
|
||||||
&& !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
|
CLIManager.ALSO_MAKE_DEPENDENTS ) )
|
||||||
{
|
{
|
||||||
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM );
|
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM );
|
||||||
}
|
}
|
||||||
else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE )
|
else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption(
|
||||||
&& commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
|
CLIManager.ALSO_MAKE_DEPENDENTS ) )
|
||||||
{
|
{
|
||||||
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM );
|
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM );
|
||||||
}
|
}
|
||||||
else if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
|
else if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption(
|
||||||
&& commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
|
CLIManager.ALSO_MAKE_DEPENDENTS ) )
|
||||||
{
|
{
|
||||||
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_BOTH );
|
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_BOTH );
|
||||||
}
|
}
|
||||||
|
@ -1420,8 +1415,8 @@ public class MavenCli
|
||||||
if ( localRepoProperty == null )
|
if ( localRepoProperty == null )
|
||||||
{
|
{
|
||||||
localRepoProperty = request.getSystemProperties().getProperty( MavenCli.LOCAL_REPO_PROPERTY );
|
localRepoProperty = request.getSystemProperties().getProperty( MavenCli.LOCAL_REPO_PROPERTY );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( localRepoProperty != null )
|
if ( localRepoProperty != null )
|
||||||
{
|
{
|
||||||
request.setLocalRepositoryPath( localRepoProperty );
|
request.setLocalRepositoryPath( localRepoProperty );
|
||||||
|
|
|
@ -19,22 +19,21 @@ package org.apache.maven.model.inheritance;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.building.SimpleProblemCollector;
|
import org.apache.maven.model.building.SimpleProblemCollector;
|
||||||
import org.apache.maven.model.io.ModelParseException;
|
import org.apache.maven.model.io.ModelParseException;
|
||||||
import org.apache.maven.model.io.ModelReader;
|
import org.apache.maven.model.io.ModelReader;
|
||||||
import org.apache.maven.model.io.ModelWriter;
|
import org.apache.maven.model.io.ModelWriter;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.custommonkey.xmlunit.XMLAssert;
|
import org.custommonkey.xmlunit.XMLAssert;
|
||||||
import org.custommonkey.xmlunit.XMLUnit;
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hervé Boutemy
|
* @author Hervé Boutemy
|
||||||
*/
|
*/
|
||||||
|
@ -85,24 +84,16 @@ public class DefaultInheritanceAssemblerTest
|
||||||
writer.write( actual, null, child );
|
writer.write( actual, null, child );
|
||||||
|
|
||||||
// check with getPom( "plugin-configuration-effective" )
|
// check with getPom( "plugin-configuration-effective" )
|
||||||
Reader control = null;
|
File expected = getPom( "plugin-configuration-expected" );
|
||||||
Reader test = null;
|
try ( Reader control = new InputStreamReader( new FileInputStream( expected ), "UTF-8" );
|
||||||
try
|
Reader test = new InputStreamReader( new FileInputStream( actual ), "UTF-8" ) )
|
||||||
{
|
{
|
||||||
File expected = getPom( "plugin-configuration-expected" );
|
|
||||||
control = new InputStreamReader( new FileInputStream( expected ), "UTF-8" );
|
|
||||||
|
|
||||||
test = new InputStreamReader( new FileInputStream( actual ), "UTF-8" );
|
|
||||||
|
|
||||||
XMLUnit.setIgnoreComments( true );
|
XMLUnit.setIgnoreComments( true );
|
||||||
XMLUnit.setIgnoreWhitespace( true );
|
XMLUnit.setIgnoreWhitespace( true );
|
||||||
XMLAssert.assertXMLEqual( control, test );
|
XMLAssert.assertXMLEqual( control, test );
|
||||||
}
|
}
|
||||||
catch ( IOException ioe )
|
|
||||||
{
|
|
||||||
IOUtil.close( control );
|
|
||||||
IOUtil.close( test );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,17 @@ package org.apache.maven.plugin.descriptor;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.ArtifactUtils;
|
||||||
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.plugin.lifecycle.Lifecycle;
|
||||||
|
import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
|
||||||
|
import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
|
||||||
|
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||||
|
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
|
||||||
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -32,18 +43,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.ArtifactUtils;
|
|
||||||
import org.apache.maven.model.Plugin;
|
|
||||||
import org.apache.maven.plugin.lifecycle.Lifecycle;
|
|
||||||
import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
|
|
||||||
import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
|
|
||||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
|
||||||
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
*/
|
*/
|
||||||
|
@ -115,8 +114,9 @@ public class PluginDescriptor
|
||||||
|
|
||||||
if ( existing != null )
|
if ( existing != null )
|
||||||
{
|
{
|
||||||
throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing
|
throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(),
|
||||||
.getImplementation(), mojoDescriptor.getImplementation() );
|
existing.getImplementation(),
|
||||||
|
mojoDescriptor.getImplementation() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -272,7 +272,7 @@ public class PluginDescriptor
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return object instanceof PluginDescriptor && getId().equals( ( (PluginDescriptor) object ).getId() );
|
return object instanceof PluginDescriptor && getId().equals( ( (PluginDescriptor) object ).getId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
|
@ -316,8 +316,9 @@ public class PluginDescriptor
|
||||||
|
|
||||||
public Set<Artifact> getIntroducedDependencyArtifacts()
|
public Set<Artifact> getIntroducedDependencyArtifacts()
|
||||||
{
|
{
|
||||||
return ( introducedDependencyArtifacts != null ) ? introducedDependencyArtifacts
|
return ( introducedDependencyArtifacts != null )
|
||||||
: Collections.<Artifact>emptySet();
|
? introducedDependencyArtifacts
|
||||||
|
: Collections.<Artifact>emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName( String name )
|
public void setName( String name )
|
||||||
|
@ -377,17 +378,10 @@ public class PluginDescriptor
|
||||||
{
|
{
|
||||||
LifecycleConfiguration lifecycleConfiguration;
|
LifecycleConfiguration lifecycleConfiguration;
|
||||||
|
|
||||||
Reader reader = null;
|
try ( Reader reader = ReaderFactory.newXmlReader( getDescriptorStream( LIFECYCLE_DESCRIPTOR ) ) )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
reader = ReaderFactory.newXmlReader( getDescriptorStream( LIFECYCLE_DESCRIPTOR ) );
|
|
||||||
|
|
||||||
lifecycleConfiguration = new LifecycleMappingsXpp3Reader().read( reader );
|
lifecycleConfiguration = new LifecycleMappingsXpp3Reader().read( reader );
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( reader );
|
|
||||||
}
|
|
||||||
|
|
||||||
lifecycleMappings = new HashMap<>();
|
lifecycleMappings = new HashMap<>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue