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

org.codehaus.mojo.tools.project.extras.DerivedArtifact Maven / Gradle / Ivy

package org.codehaus.mojo.tools.project.extras;

/*
 * 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 org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;

/**
 * If you have an artifact of package type like pom or jar, DerivedArtifact can derive
 * an artifact of another packaging type like rpm or classifier like patches.
 *
 */
public class DerivedArtifact extends DefaultArtifact
{

    /**
     * If you have an artifact of package type like pom or jar, DerivedArtifact can derive
     * an artifact of another packaging type like rpm or classifier like patches.
     * 
     * @param parentArtifact This is the artifact which will be used to derive another artifact
     * @param classifier The desired classifier for the derived artifact like patches or 
     *        osx5.i386.
     * @param type The derived packaging type for the derived artifact like rpm or jar
     * @param handler The ArtifactHandler for the derived artifact
     */
    public DerivedArtifact( Artifact parentArtifact, String classifier, String type, ArtifactHandler handler )
    {
        super( parentArtifact.getGroupId(), parentArtifact.getArtifactId(),
            parentArtifact.getVersionRange(),
            parentArtifact.getScope(), type, classifier, handler, false );
        
        setAvailableVersions( parentArtifact.getAvailableVersions() );
        setBaseVersion( parentArtifact.getBaseVersion() );
        setDependencyFilter( parentArtifact.getDependencyFilter() );
        setDependencyTrail( parentArtifact.getDependencyTrail() );
        setRelease( parentArtifact.isRelease() );
        setRepository( parentArtifact.getRepository() );
        
        if ( parentArtifact.isResolved() )
        {
            setResolvedVersion( parentArtifact.getVersion() );
        }
    }

    /**
     * If you have an artifact of package type like pom or jar, DerivedArtifact can derive
     * an artifact of another packaging type like rpm or classifier like patches.
     * 
     * @param parentArtifact This is the artifact which will be used to derive another artifact
     * @param version The version of the parent and derived artifact
     * @param classifier The desired classifier for the derived artifact like patches or 
     *        osx5.i386.
     * @param type The derived packaging type for the derived artifact like rpm or jar
     * @param handler The ArtifactHandler for the derived artifact
     */
    public DerivedArtifact( Artifact parentArtifact, String version,
        String classifier, String type, ArtifactHandler handler )
    {
        super( parentArtifact.getGroupId(), parentArtifact.getArtifactId(),
               VersionRange.createFromVersion( version ),
               parentArtifact.getScope(), type, classifier, handler, false );
        
        setAvailableVersions( parentArtifact.getAvailableVersions() );
        setBaseVersion( parentArtifact.getBaseVersion() );
        setDependencyFilter( parentArtifact.getDependencyFilter() );
        setDependencyTrail( parentArtifact.getDependencyTrail() );
        setRelease( parentArtifact.isRelease() );
        setRepository( parentArtifact.getRepository() );
        
        if ( parentArtifact.isResolved() )
        {
            setResolvedVersion( parentArtifact.getVersion() );
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy