All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.felix.obrplugin.AbstractFileMojo Maven / Gradle / Ivy

Go to download

Provides a maven plugin that supports creating an OSGi bundle from the contents of the compilation classpath along with its resources and dependencies. Plus a zillion other features. The plugin uses the Bnd tool (http://www.aqute.biz/Code/Bnd)

There is a newer version: 5.1.9
Show newest version
/*
 * 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.
 */
package org.apache.felix.obrplugin;


import java.io.File;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;


/**
 * Base class for the command-line install-file and deploy-file goals.
 * 
 * @author Felix Project Team
 */
public abstract class AbstractFileMojo extends AbstractMojo
{
    /**
     * GroupId of the bundle. Retrieved from POM file if specified.
     */
    @Parameter( property = "groupId" )
    private String groupId;

    /**
     * ArtifactId of the bundle. Retrieved from POM file if specified.
     */
    @Parameter( property = "artifactId" )
    private String artifactId;

    /**
     * Version of the bundle. Retrieved from POM file if specified.
     */
    @Parameter( property = "version" )
    private String version;

    /**
     * Packaging type of the bundle. Retrieved from POM file if specified.
     */
    @Parameter( property = "packaging" )
    private String packaging;

    /**
     * Classifier type of the bundle. Defaults to none.
     */
    @Parameter( property = "classifier" )
    private String classifier;

    /**
     * Location of an existing POM file.
     */
    @Parameter( property = "pomFile" )
    private File pomFile;

    /**
     * Bundle file, defaults to the artifact in the local Maven repository.
     */
    @Parameter( property = "file" )
    protected File file;

    /**
     * Optional XML file describing additional requirements and capabilities.
     */
    @Parameter( property = "obrXml" )
    protected String obrXml;

    /**
     * Component factory for Maven artifacts
     */
    @Component
    private ArtifactFactory m_factory;


    /**
     * @return project based on command-line settings, with bundle attached
     * @throws MojoExecutionException
     */
    public MavenProject getProject() throws MojoExecutionException
    {
        final MavenProject project;
        if ( pomFile != null && pomFile.exists() )
        {
            project = PomHelper.readPom( pomFile );

            groupId = project.getGroupId();
            artifactId = project.getArtifactId();
            version = project.getVersion();
            packaging = project.getPackaging();
        }
        else
        {
            project = PomHelper.buildPom( groupId, artifactId, version, packaging );
        }

        if ( groupId == null || artifactId == null || version == null || packaging == null )
        {
            throw new MojoExecutionException( "Missing group, artifact, version, or packaging information" );
        }

        Artifact bundle = m_factory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );
        project.setArtifact( bundle );

        return project;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy