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

org.apache.maven.project.DefaultProjectBuildingRequest Maven / Gradle / Ivy

The newest version!
package org.apache.maven.project;

/*
 * 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.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.eclipse.aether.RepositorySystemSession;

public class DefaultProjectBuildingRequest
    implements ProjectBuildingRequest
{

    private RepositorySystemSession repositorySession;

    private ArtifactRepository localRepository;

    private List remoteRepositories;

    private List pluginArtifactRepositories;

    private MavenProject project;

    private int validationLevel = ModelBuildingRequest.VALIDATION_LEVEL_STRICT;

    private boolean processPlugins;

    private List profiles;

    private List activeProfileIds;

    private List inactiveProfileIds;

    private Properties systemProperties;

    private Properties userProperties;

    private Date buildStartTime;

    private boolean resolveDependencies;

    private RepositoryMerging repositoryMerging = RepositoryMerging.POM_DOMINANT;

    public DefaultProjectBuildingRequest()
    {
        processPlugins = true;
        profiles = new ArrayList();
        activeProfileIds = new ArrayList();
        inactiveProfileIds = new ArrayList();
        systemProperties = new Properties();
        userProperties = new Properties();
        remoteRepositories = new ArrayList();
        pluginArtifactRepositories = new ArrayList();
    }

    public DefaultProjectBuildingRequest( ProjectBuildingRequest request )
    {
        this();
        setProcessPlugins( request.isProcessPlugins() );
        setProfiles( request.getProfiles() );
        setActiveProfileIds( request.getActiveProfileIds() );
        setInactiveProfileIds( request.getInactiveProfileIds() );
        setSystemProperties( request.getSystemProperties() );
        setUserProperties( request.getUserProperties() );
        setRemoteRepositories( request.getRemoteRepositories() );
        setPluginArtifactRepositories( request.getPluginArtifactRepositories() );
        setRepositorySession( request.getRepositorySession() );
        setLocalRepository( request.getLocalRepository() );
        setBuildStartTime( request.getBuildStartTime() );
        setProject( request.getProject() );
        setResolveDependencies( request.isResolveDependencies() );
        setValidationLevel( request.getValidationLevel() );
    }

    public MavenProject getProject()
    {
        return project;
    }

    public void setProject( MavenProject mavenProject )
    {
        this.project = mavenProject;
    }

    public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository )
    {
        this.localRepository = localRepository;
        return this;
    }

    public ArtifactRepository getLocalRepository()
    {
        return localRepository;
    }

    public List getRemoteRepositories()
    {
        return remoteRepositories;
    }

    public ProjectBuildingRequest setRemoteRepositories( List remoteRepositories )
    {
        if ( remoteRepositories != null )
        {
            this.remoteRepositories = new ArrayList( remoteRepositories );
        }
        else
        {
            this.remoteRepositories.clear();
        }

        return this;
    }

    public List getPluginArtifactRepositories()
    {
        return pluginArtifactRepositories;
    }

    public ProjectBuildingRequest setPluginArtifactRepositories( List pluginArtifactRepositories )
    {
        if ( pluginArtifactRepositories != null )
        {
            this.pluginArtifactRepositories = new ArrayList( pluginArtifactRepositories );
        }
        else
        {
            this.pluginArtifactRepositories.clear();
        }

        return this;
    }

    public Properties getSystemProperties()
    {
        return systemProperties;
    }

    public ProjectBuildingRequest setSystemProperties( Properties systemProperties )
    {
        if ( systemProperties != null )
        {
            this.systemProperties = new Properties();
            this.systemProperties.putAll( systemProperties );
        }
        else
        {
            this.systemProperties.clear();
        }

        return this;
    }

    public Properties getUserProperties()
    {
        return userProperties;
    }

    public ProjectBuildingRequest setUserProperties( Properties userProperties )
    {
        if ( userProperties != null )
        {
            this.userProperties = new Properties();
            this.userProperties.putAll( userProperties );
        }
        else
        {
            this.userProperties.clear();
        }

        return this;
    }

    public boolean isProcessPlugins()
    {
        return processPlugins;
    }

    public ProjectBuildingRequest setProcessPlugins( boolean processPlugins )
    {
        this.processPlugins = processPlugins;
        return this;
    }
    
    public ProjectBuildingRequest setResolveDependencies( boolean resolveDependencies )
    {
        this.resolveDependencies = resolveDependencies;
        return this;
    }

    public boolean isResolveDependencies()
    {
        return resolveDependencies;
    }

    public ProjectBuildingRequest setValidationLevel( int validationLevel )
    {
        this.validationLevel = validationLevel;
        return this;
    }

    public int getValidationLevel()
    {
        return validationLevel;
    }

    public List getActiveProfileIds()
    {
        return activeProfileIds;
    }

    public void setActiveProfileIds( List activeProfileIds )
    {
        if ( activeProfileIds != null )
        {
            this.activeProfileIds = new ArrayList( activeProfileIds );
        }
        else
        {
            this.activeProfileIds.clear();
        }
    }

    public List getInactiveProfileIds()
    {
        return inactiveProfileIds;
    }

    public void setInactiveProfileIds( List inactiveProfileIds )
    {
        if ( inactiveProfileIds != null )
        {
            this.inactiveProfileIds = new ArrayList( inactiveProfileIds );
        }
        else
        {
            this.inactiveProfileIds.clear();
        }
    }

    public void setProfiles( List profiles )
    {
        if ( profiles != null )
        {
            this.profiles = new ArrayList( profiles );
        }
        else
        {
            this.profiles.clear();
        }
    }

    public void addProfile( Profile profile )
    {
        profiles.add( profile );
    }

    public List getProfiles()
    {
        return profiles;
    }

    public Date getBuildStartTime()
    {
        return buildStartTime;
    }

    public void setBuildStartTime( Date buildStartTime )
    {
        this.buildStartTime = buildStartTime;
    }

    public RepositorySystemSession getRepositorySession()
    {
        return repositorySession;
    }

    public DefaultProjectBuildingRequest setRepositorySession( RepositorySystemSession repositorySession )
    {
        this.repositorySession = repositorySession;
        return this;
    }

    public DefaultProjectBuildingRequest setRepositoryMerging( RepositoryMerging repositoryMerging )
    {
        if ( repositoryMerging == null )
        {
            throw new IllegalArgumentException( "repository merge mode not specified" );
        }
        this.repositoryMerging = repositoryMerging;
        return this;
    }

    public RepositoryMerging getRepositoryMerging()
    {
        return repositoryMerging;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy