protected void doExecute()

in src/main/java/org/apache/maven/artifact/ant/InstallTask.java [40:95]


    protected void doExecute()
    {
        if ( file == null && ( attachedArtifacts.size() == 0 ) )
        {
            throw new BuildException( "You must specify a file and/or an attached artifact "
                + "to install to the local repository." );
        }

        ArtifactRepository localRepo = createLocalArtifactRepository();

        Pom pom = initializePom( localRepo );

        if ( pom == null )
        {
            throw new BuildException( "A POM element is required to install to the local repository" );
        }

        Artifact artifact = pom.getArtifact();

        boolean isPomArtifact = "pom".equals( pom.getPackaging() );
        if ( !isPomArtifact )
        {
            ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() );
            artifact.addMetadata( metadata );
        }

        ArtifactInstaller installer = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE );
        try
        {
            if ( file != null )
            {
                if ( !isPomArtifact )
                {
                    installer.install( file, artifact, localRepo );
                }
                else
                {
                    installer.install( pom.getFile(), artifact, localRepo );
                }
            }

            // Install any attached artifacts
            if ( attachedArtifacts != null )
            {
                for ( Artifact attachedArtifact : pom.getAttachedArtifacts() )
                {
                    installer.install( attachedArtifact.getFile(), attachedArtifact, localRepo );
                }
            }
        }
        catch ( ArtifactInstallationException e )
        {
            throw new BuildException(
                "Error installing artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
        }
    }