"jar",
gav.getVersion() );
jarArtifact = jarArtifact.setFile( jarFile );
//pom.xml Artifact
Artifact pomXMLArtifact = new SubArtifact( jarArtifact,
"",
"pom" );
pomXMLArtifact = pomXMLArtifact.setFile( pomXMLFile );
try {
//Install into local repository
final InstallRequest installRequest = new InstallRequest();
installRequest
.addArtifact( jarArtifact )
.addArtifact( pomXMLArtifact );
Aether.getAether().getSystem().install( Aether.getAether().getSession(),
installRequest );
} catch ( InstallationException e ) {
throw new RuntimeException( e );
}
//Deploy into Workbench's default remote repository
try {
final DeployRequest deployRequest = new DeployRequest();
deployRequest
.addArtifact( jarArtifact )
.addArtifact( pomXMLArtifact )
.setRepository( getGuvnorM2Repository() );
Aether.getAether().getSystem().deploy( Aether.getAether().getSession(),
deployRequest );
} catch ( DeploymentException e ) {
throw new RuntimeException( e );
}
//Only deploy to additional repositories if required. This flag is principally for Unit Tests
if ( !includeAdditionalRepositories ) {
return;
}
//Deploy into remote repository defined in <distributionManagement>
try {
final Model model = new MavenXpp3Reader().read( new StringReader( pomXML ) );
final DistributionManagement distributionManagement = model.getDistributionManagement();
if ( distributionManagement != null ) {
final boolean isSnapshot = pomXMLArtifact.isSnapshot();
DeploymentRepository remoteRepository = null;
if ( isSnapshot ) {
remoteRepository = distributionManagement.getSnapshotRepository();
} else {
remoteRepository = distributionManagement.getRepository();