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

org.apache.maven.plugin.eclipse.writers.EclipseWriterConfig Maven / Gradle / Ivy

Go to download

The Eclipse Plugin is used to generate Eclipse IDE files (.project, .classpath and the .settings folder) from a POM.

There is a newer version: 2.10
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.maven.plugin.eclipse.writers;

import java.io.File;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.eclipse.EclipsePlugin;
import org.apache.maven.plugin.eclipse.EclipseSourceDir;
import org.apache.maven.plugin.eclipse.WorkspaceConfiguration;
import org.apache.maven.plugin.ide.IdeDependency;
import org.apache.maven.project.MavenProject;

/**
 * @author Fabrizio Giustina
 * @version $Id: EclipseWriterConfig.java 691404 2008-09-02 21:57:19Z aheritier $
 */
public class EclipseWriterConfig
{
    /**
     * The maven project.
     */
    private MavenProject project;

    /**
     * The maven project packaging.
     */
    private String packaging;

    /**
     * Eclipse project dir.
     */
    private File eclipseProjectDirectory;

    /**
     * The name of the project in eclipse.
     */
    private String eclipseProjectName;

    /**
     * Base project dir.
     */
    private File projectBaseDir;

    /**
     * List of IDE dependencies.
     */
    private IdeDependency[] deps = new IdeDependency[0];

    /**
     * List of IDE dependencies ordered.
     */
    private IdeDependency[] orderedDeps = new IdeDependency[0];

    /**
     * Source directories.
     */
    private EclipseSourceDir[] sourceDirs;

    /**
     * Local maven repo.
     */
    private ArtifactRepository localRepository;

    /**
     * Build output directory for eclipse.
     */
    private File buildOutputDirectory;

    /**
     * Manifest file.
     */
    private File osgiManifestFile;

    /**
     * PDE mode.
     */
    private boolean pde;

    /**
     * Project natures.
     */
    private List projectnatures;

    /**
     * Project facets.
     */
    private Map projectFacets;

    /**
     * Build commands. List<BuildCommand>
     */
    private List buildCommands;

    /**
     * Classpath containers.
     */
    private List classpathContainers;

    /**
     * Appends the version number to the project name if true.
     * 
     * @deprecated use {@link #projectNameTemplate}
     */
    private boolean addVersionToProjectName;

    /**
     * @see EclipsePlugin#getProjectNameTemplate()
     */
    private String projectNameTemplate;

    /**
     * @see EclipsePlugin#deployName()
     */

    private String contextName;

    /**
     * @see EclipsePlugin#wtpapplicationxml()
     */
    private boolean wtpapplicationxml;

    /**
     * @see EclipsePlugin#getWtpversion()
     */
    private float wtpVersion;

    private float ajdtVersion;

    private WorkspaceConfiguration workspaceConfiguration;

    public WorkspaceConfiguration getWorkspaceConfiguration()
    {
        return workspaceConfiguration;
    }

    public void setWorkspaceConfiguration( WorkspaceConfiguration workspaceConfiguration )
    {
        this.workspaceConfiguration = workspaceConfiguration;
    }

    /**
     * Getter for deps.
     * 
     * @return Returns the deps.
     */
    public IdeDependency[] getDeps()
    {
        return deps;
    }

    /**
     * Setter for deps.
     * 
     * @param deps The deps to set.
     */
    public void setDeps( IdeDependency[] deps )
    {
        this.deps = deps;
        if ( deps != null )
        {
            // TODO get the right comparator depending on orderDependencies={name,nearness..};
            // if none specified it could use a NullComparator to reduce the number of
            // conditions that have to be checked
            Comparator depsByArtifactId = new Comparator()
            {
                public int compare( Object o1, Object o2 )
                {
                    int result =
                        ( (IdeDependency) o1 ).getArtifactId().compareToIgnoreCase(
                                                                                    ( (IdeDependency) o2 ).getArtifactId() );
                    if ( result != 0 )
                    {
                        return result;
                    }
                    if ( ( (IdeDependency) o1 ).getClassifier() != null
                        && ( (IdeDependency) o2 ).getClassifier() != null )
                    {
                        result =
                            ( (IdeDependency) o1 ).getClassifier().compareToIgnoreCase(
                                                                                        ( (IdeDependency) o2 ).getClassifier() );
                        if ( result != 0 )
                        {
                            return result;
                        }
                    }
                    result = ( (IdeDependency) o1 ).getType().compareToIgnoreCase( ( (IdeDependency) o2 ).getType() );
                    if ( result != 0 )
                    {
                        return result;
                    }
                    result =
                        ( (IdeDependency) o1 ).getGroupId().compareToIgnoreCase( ( (IdeDependency) o2 ).getGroupId() );
                    return result;
                }
            };

            orderedDeps = new IdeDependency[deps.length];
            System.arraycopy( deps, 0, orderedDeps, 0, deps.length );
            Arrays.sort( orderedDeps, depsByArtifactId );
        }
    }

    /**
     * Getter for eclipseProjectDir.
     * 
     * @return Returns the eclipseProjectDir.
     */
    public File getEclipseProjectDirectory()
    {
        return eclipseProjectDirectory;
    }

    /**
     * Setter for eclipseProjectDir.
     * 
     * @param eclipseProjectDir The eclipseProjectDir to set.
     */
    public void setEclipseProjectDirectory( File eclipseProjectDir )
    {
        eclipseProjectDirectory = eclipseProjectDir;
    }

    /**
     * Getter for eclipseProjectName.
     * 
     * @return Returns the project name used in eclipse.
     */
    public String getEclipseProjectName()
    {
        return eclipseProjectName;
    }

    /**
     * Setter for eclipseProjectName.
     * 
     * @param eclipseProjectName the project name used in eclipse.
     */
    public void setEclipseProjectName( String eclipseProjectName )
    {
        this.eclipseProjectName = eclipseProjectName;
    }

    /**
     * Getter for project.
     * 
     * @return Returns the project.
     */
    public MavenProject getProject()
    {
        return project;
    }

    /**
     * Setter for project.
     * 
     * @param project The project to set.
     */
    public void setProject( MavenProject project )
    {
        this.project = project;
    }

    /**
     * Getter for sourceDirs.
     * 
     * @return Returns the sourceDirs.
     */
    public EclipseSourceDir[] getSourceDirs()
    {
        return sourceDirs;
    }

    /**
     * Setter for sourceDirs.
     * 
     * @param sourceDirs The sourceDirs to set.
     */
    public void setSourceDirs( EclipseSourceDir[] sourceDirs )
    {
        this.sourceDirs = sourceDirs;
    }

    /**
     * Getter for buildOutputDirectory.
     * 
     * @return Returns the buildOutputDirectory.
     */
    public File getBuildOutputDirectory()
    {
        return buildOutputDirectory;
    }

    /**
     * Setter for buildOutputDirectory.
     * 
     * @param buildOutputDirectory The buildOutputDirectory to set.
     */
    public void setBuildOutputDirectory( File buildOutputDirectory )
    {
        this.buildOutputDirectory = buildOutputDirectory;
    }

    /**
     * Getter for localRepository.
     * 
     * @return Returns the localRepository.
     */
    public ArtifactRepository getLocalRepository()
    {
        return localRepository;
    }

    /**
     * Setter for localRepository.
     * 
     * @param localRepository The localRepository to set.
     */
    public void setLocalRepository( ArtifactRepository localRepository )
    {
        this.localRepository = localRepository;
    }

    /**
     * Getter for manifestFile.
     * 
     * @return Returns the manifestFile.
     */
    public File getOSGIManifestFile()
    {
        return osgiManifestFile;
    }

    /**
     * Setter for manifestFile.
     * 
     * @param manifestFile The manifestFile to set.
     */
    public void setOSGIManifestFile( File manifestFile )
    {
        this.osgiManifestFile = manifestFile;
    }

    /**
     * Getter for classpathContainers.
     * 
     * @return Returns the classpathContainers.
     */
    public List getClasspathContainers()
    {
        return classpathContainers;
    }

    /**
     * Setter for classpathContainers.
     * 
     * @param classpathContainers The classpathContainers to set.
     */
    public void setClasspathContainers( List classpathContainers )
    {
        this.classpathContainers = classpathContainers;
    }

    /**
     * Getter for pde.
     * 
     * @return Returns the pde.
     */
    public boolean isPde()
    {
        return pde;
    }

    /**
     * Setter for pde.
     * 
     * @param pde The pde to set.
     */
    public void setPde( boolean pde )
    {
        this.pde = pde;
    }

    /**
     * Getter for buildCommands.
     * 
     * @return Returns the buildCommands.
     */
    public List getBuildCommands()
    {
        return buildCommands;
    }

    /**
     * Setter for buildCommands.
     * 
     * @param buildCommands The buildCommands to set.
     */
    public void setBuildCommands( List buildCommands )
    {
        this.buildCommands = buildCommands;
    }

    /**
     * Getter for projectnatures.
     * 
     * @return Returns the projectnatures.
     */
    public List getProjectnatures()
    {
        return projectnatures;
    }

    /**
     * Setter for projectnatures.
     * 
     * @param projectnatures The projectnatures to set.
     */
    public void setProjectnatures( List projectnatures )
    {
        this.projectnatures = projectnatures;
    }

    /**
     * Getter for projectFacets.
     * 
     * @return Returns the projectFacets
     */
    public Map getProjectFacets()
    {
        return projectFacets;
    }

    /**
     * Setter for projectFacets
     * 
     * @param projectFacets The projectFacets to set.
     */
    public void setProjectFacets( Map projectFacets )
    {
        this.projectFacets = projectFacets;
    }

    /**
     * Getter for projectBaseDir.
     * 
     * @return Returns the projectBaseDir.
     */
    public File getProjectBaseDir()
    {
        return projectBaseDir;
    }

    /**
     * Setter for projectBaseDir.
     * 
     * @param projectBaseDir The projectBaseDir to set.
     */
    public void setProjectBaseDir( File projectBaseDir )
    {
        this.projectBaseDir = projectBaseDir;
    }

    /**
     * Getter for addVersionToProjectName.
     * 
     * @deprecated use {@link #getProjectNameTemplate()}
     */
    public boolean isAddVersionToProjectName()
    {
        return addVersionToProjectName;
    }

    /**
     * Setter for addVersionToProjectName.
     * 
     * @deprecated use {@link #setProjectNameTemplate(String)}
     */
    public void setAddVersionToProjectName( boolean addVersionToProjectName )
    {
        this.addVersionToProjectName = addVersionToProjectName;
    }

    public void setProjectNameTemplate( String projectNameTemplate )
    {
        this.projectNameTemplate = projectNameTemplate;
    }

    public String getProjectNameTemplate()
    {
        return projectNameTemplate;
    }

    public String getContextName()
    {
        return contextName;
    }

    public void setContextName( String deployName )
    {
        contextName = deployName;
    }

    /**
     * @return the packaging
     */
    public String getPackaging()
    {
        return packaging;
    }

    /**
     * @param packaging the packaging to set
     */
    public void setPackaging( String packaging )
    {
        this.packaging = packaging;
    }

    /**
     * Getter for wtpapplicationxml.
     * 
     * @return Returns the wtpapplicationxml.
     */
    public boolean getWtpapplicationxml()
    {
        return wtpapplicationxml;
    }

    /**
     * Setter for buildCommands.
     * 
     * @param buildCommands The buildCommands to set.
     */
    public void setWtpapplicationxml( boolean wtpapplicationxml )
    {
        this.wtpapplicationxml = wtpapplicationxml;
    }

    /**
     * Getter for wtpVersion.
     * 
     * @return Returns the wtpVersion.
     */
    public float getWtpVersion()
    {
        return wtpVersion;
    }

    /**
     * Setter for wtpVersion.
     * 
     * @param wtpVersion The wtpVersion to set.
     */
    public void setWtpVersion( float wtpVersion )
    {
        this.wtpVersion = wtpVersion;
    }

    /**
     * @return an ordered list of dependencies
     */
    public IdeDependency[] getDepsOrdered()
    {
        return orderedDeps;
    }

    /**
     * Returns the ajdtVersion.
     * 
     * @return the ajdtVersion.
     */
    public float getAjdtVersion()
    {
        return ajdtVersion;
    }

    /**
     * Sets the ajdtVersion.
     * 
     * @param ajdtVersion the ajdtVersion.
     */
    public void setAjdtVersion( float ajdtVersion )
    {
        this.ajdtVersion = ajdtVersion;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy