in maven-artifact-transfer-api/src/main/java/org/apache/maven/shared/transfer/project/install/internal/DefaultProjectInstaller.java [74:140]
public void install( ProjectBuildingRequest buildingRequest, ProjectInstallerRequest installerRequest )
throws IOException, ArtifactInstallerException, NoFileAssignedException, IllegalArgumentException
{
validateParameters( buildingRequest, installerRequest );
MavenProject project = installerRequest.getProject();
Artifact artifact = project.getArtifact();
String packaging = project.getPackaging();
File pomFile = project.getFile();
List<Artifact> attachedArtifacts = project.getAttachedArtifacts();
// TODO: push into transformation
boolean isPomArtifact = "pom".equals( packaging );
ProjectArtifactMetadata metadata;
Collection<File> metadataFiles = new LinkedHashSet<>();
if ( isPomArtifact )
{
if ( pomFile != null )
{
installer.install( buildingRequest,
Collections.<Artifact>singletonList( new ProjectArtifact( project ) ) );
addMetaDataFilesForArtifact( buildingRequest, artifact, metadataFiles );
}
}
else
{
if ( pomFile != null )
{
metadata = new ProjectArtifactMetadata( artifact, pomFile );
artifact.addMetadata( metadata );
}
File file = artifact.getFile();
// Here, we have a temporary solution to MINSTALL-3 (isDirectory() is true if it went through compile
// but not package). We are designing in a proper solution for Maven 2.1
if ( file != null && file.isFile() )
{
installer.install( buildingRequest, Collections.singletonList( artifact ) );
addMetaDataFilesForArtifact( buildingRequest, artifact, metadataFiles );
}
else if ( !attachedArtifacts.isEmpty() )
{
throw new NoFileAssignedException( "The packaging plugin for this project did not assign "
+ "a main file to the project but it has attachments. Change packaging to 'pom'." );
}
else
{
// CHECKSTYLE_OFF: LineLength
throw new NoFileAssignedException( "The packaging for this project did not assign a file to the build artifact" );
// CHECKSTYLE_ON: LineLength
}
}
for ( Artifact attached : attachedArtifacts )
{
logger.debug( "Installing artifact: {}", attached.getId() );
installer.install( buildingRequest, Collections.singletonList( attached ) );
addMetaDataFilesForArtifact( buildingRequest, attached, metadataFiles );
}
}