blob: fdec6ffcd7ea0a6b8d760eda6e29708943e1684c [file] [log] [blame]
package org.apache.maven.plugins.install;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.Metadata;
import org.apache.maven.api.Session;
import org.apache.maven.api.plugin.annotations.Component;
import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.api.services.LocalRepositoryManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Common fields for installation mojos.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public abstract class AbstractInstallMojo
implements org.apache.maven.api.plugin.Mojo
{
protected Logger logger = LoggerFactory.getLogger( getClass() );
@Component
protected LocalRepositoryManager repositoryManager;
@Parameter( defaultValue = "${session}", required = true, readonly = true )
protected Session session;
/**
* Gets the path of the specified artifact within the local repository. Note that the returned path need not exist
* (yet).
*
* @param artifact The artifact whose local repo path should be determined, must not be <code>null</code>.
* @return The absolute path to the artifact when installed, never <code>null</code>.
*/
protected File getLocalRepoFile( Artifact artifact )
{
return session.getPathForLocalArtifact( artifact ).toFile();
}
/**
* Gets the path of the specified artifact metadata within the local repository. Note that the returned path need
* not exist (yet).
*
* @param metadata The artifact metadata whose local repo path should be determined, must not be <code>null</code>.
* @return The absolute path to the artifact metadata when installed, never <code>null</code>.
*/
protected File getLocalRepoFile( Metadata metadata )
{
return session.getPathForLocalMetadata( metadata ).toFile();
}
}