001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.geronimo.genesis.plugins.tools;
021
022 import org.codehaus.mojo.pluginsupport.MojoSupport;
023
024 import org.apache.maven.project.MavenProject;
025 import org.apache.maven.artifact.Artifact;
026
027 import java.io.File;
028
029 /**
030 * Helper to install a specific file (or the projects pom) as the projects artifact file.
031 *
032 * <p>
033 * Custom packaging will need to define a artifact handler plexus component to map desired file extention.
034 * </p>
035 *
036 * @goal set-artifact-file
037 * @phase package
038 *
039 * @version $Rev: 512096 $ $Date: 2007-02-27 01:58:04 +0100 (Tue, 27 Feb 2007) $
040 */
041 public class SetProjectFileMojo
042 extends MojoSupport
043 {
044 /**
045 * The maven project.
046 *
047 * @parameter expression="${project}"
048 * @required
049 * @readonly
050 */
051 protected MavenProject project;
052
053 /**
054 * The target file to set as the project's artifact.
055 *
056 * @parameter expression="${project.file}"
057 * @required
058 */
059 private File targetFile;
060
061 protected void doExecute() throws Exception {
062 log.info("Setting artifact file: " + targetFile);
063
064 Artifact artifact = project.getArtifact();
065 artifact.setFile(targetFile);
066 }
067 }