localRepository = new File( System.getProperty( "user.home" ), ".m2/repository" );
}
String profile = System.getProperty( "dependencyProfile" );
RepositoryRegistry repositoryRegistry;
try
{
repositoryRegistry = npandayRegistry.createRepositoryRegistry();
}
catch ( IOException e )
{
throw new MojoExecutionException(
"NPANDAY-1600-000: Failed to create the repository registry for this plugin", e );
}
catch( NPandayRepositoryException e )
{
throw new MojoExecutionException(
"NPANDAY-1600-007: Failed to create the repository registry for this plugin", e );
}
if ( netDependencies == null )
{
netDependencies = new NetDependency[0];
}
List<Dependency> dependencies = new ArrayList<Dependency>();
for ( NetDependency netDependency : netDependencies )
{
Dependency dependency = new Dependency();
dependency.setGroupId( netDependency.getGroupId() );
dependency.setArtifactId( netDependency.getArtifactId() );
dependency.setVersion( netDependency.getVersion() );
dependency.setScope( Artifact.SCOPE_RUNTIME );
dependency.setType( netDependency.getType() );
dependencies.add( dependency );
}
artifactContext.init( project, project.getRemoteArtifactRepositories(), localRepository );
if ( !new File( localRepository, "npanday.artifacts.resolved" ).exists() ) //performance optimization
{
try
{
artifactContext.getArtifactInstaller().resolveAndInstallNetDependenciesForProfile( profile,
dependencies, null );
}
catch ( NPandayArtifactResolutionException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
new File( localRepository, "npanday.artifacts.resolved" ).mkdir();
}
//Do GAC Install, if needed
//TODO: Add in the dependencies from the MOJO config
if ( isGacInstall )
{
NetDependenciesRepository repository =
(NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" );
getLog().info( "NPANDAY-1600-001: Found net dependencies: Number = " + dependencies.size() );
List<NetDependencyMatchPolicy> gacInstallPolicies = new ArrayList<NetDependencyMatchPolicy>();
gacInstallPolicies.add( new GacMatchPolicy( true ) );
List<Dependency> gacInstallDependencies = repository.getDependenciesFor( gacInstallPolicies );