Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

[MINSTALL-126] localRepositoryPath for install like for install-file #109

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* under the License.
*/

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -41,7 +42,7 @@
/**
* Installs the project's main artifact, and any other artifacts attached by other plugins in the lifecycle, to the
* local repository.
*
*
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
* @version $Id$
*/
Expand Down Expand Up @@ -71,7 +72,7 @@ public class InstallMojo
* Whether every project should be installed during its own install-phase or at the end of the multimodule build. If
* set to {@code true} and the build fails, none of the reactor projects is installed.
* <strong>(experimental)</strong>
*
*
* @since 2.5
*/
@Parameter( defaultValue = "false", property = "installAtEnd" )
Expand All @@ -80,18 +81,39 @@ public class InstallMojo
/**
* Set this to <code>true</code> to bypass artifact installation. Use this for artifacts that does not need to be
* installed in the local repository.
*
*
* @since 2.4
*/
@Parameter( property = "maven.install.skip", defaultValue = "false" )
private boolean skip;

/**
* The path for a specific local repository directory. If not specified the local repository path configured in the
* Maven settings will be used.
*
* @since 3.0.0
*/
@Parameter( property = "localRepositoryPath" )
private File localRepositoryPath;

@Component
private ProjectInstaller installer;

@Override
public void execute()
throws MojoExecutionException, MojoFailureException
{
ProjectBuildingRequest buildingRequest = session.getProjectBuildingRequest();
// ----------------------------------------------------------------------
// Override the default localRepository variable
// ----------------------------------------------------------------------
if ( localRepositoryPath != null )
{
buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest, localRepositoryPath );

getLog().debug( "localRepoPath: " + repositoryManager.getLocalRepositoryBasedir( buildingRequest ) );
}

boolean addedInstallRequest = false;
if ( skip )
{
Expand All @@ -106,7 +128,7 @@ public void execute()

if ( !installAtEnd )
{
installProject( session.getProjectBuildingRequest(), projectInstallerRequest );
installProject( buildingRequest, projectInstallerRequest );
}
else
{
Expand All @@ -122,7 +144,7 @@ public void execute()
{
while ( !INSTALLREQUESTS.isEmpty() )
{
installProject( session.getProjectBuildingRequest(), INSTALLREQUESTS.remove( 0 ) );
installProject( buildingRequest, INSTALLREQUESTS.remove( 0 ) );
}
}
}
Expand All @@ -138,7 +160,7 @@ private void installProject( ProjectBuildingRequest pbr, ProjectInstallerRequest
{
try
{
installer.install( session.getProjectBuildingRequest(), pir );
installer.install( pbr, pir );
}
catch ( IOException e )
{
Expand Down