mirror of https://github.com/apache/maven.git
PR: MNG-760
Submitted by: Fabrizio Giustina Reviewed by: Brett Porter m2 eclipse plugin improvements (source download and attachment, customization of natures/builders/conclasspath, flexible project dupport) and refactoring (applied with modifications) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40738a5a86
commit
fe3df1bd1d
|
@ -0,0 +1,240 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||
|
||||
/**
|
||||
* Writes eclipse .classpath file.
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseClasspathWriter
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
public EclipseClasspathWriter( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo the list of needed parameters is really long, maybe this should become a Plexus component
|
||||
*/
|
||||
protected void write( File projectBaseDir, File basedir, MavenProject project, List referencedReactorArtifacts,
|
||||
EclipseSourceDir[] sourceDirs, List classpathContainers, ArtifactRepository localRepository,
|
||||
ArtifactResolver artifactResolver, ArtifactFactory artifactFactory,
|
||||
List remoteArtifactRepositories )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
|
||||
FileWriter w;
|
||||
|
||||
try
|
||||
{
|
||||
w = new FileWriter( new File( basedir, ".classpath" ) ); //$NON-NLS-1$
|
||||
}
|
||||
catch ( IOException ex )
|
||||
{
|
||||
throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
|
||||
writer.startElement( "classpath" ); //$NON-NLS-1$
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Source roots and resources
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
for ( int j = 0; j < sourceDirs.length; j++ )
|
||||
{
|
||||
EclipseSourceDir dir = sourceDirs[j];
|
||||
|
||||
writer.startElement( "classpathentry" ); //$NON-NLS-1$
|
||||
|
||||
writer.addAttribute( "kind", "src" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "path", dir.getPath() ); //$NON-NLS-1$
|
||||
if ( dir.getOutput() != null )
|
||||
{
|
||||
writer.addAttribute( "output", dir.getOutput() ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The default output
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
writer.startElement( "classpathentry" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "kind", "output" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "path", EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, project.getBuild() //$NON-NLS-1$
|
||||
.getOutputDirectory(), false ) );
|
||||
writer.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The JRE reference
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
writer.startElement( "classpathentry" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "kind", "var" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "rootpath", "JRE_SRCROOT" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "path", "JRE_LIB" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "sourcepath", "JRE_SRC" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The dependencies
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Set artifacts = project.getArtifacts();
|
||||
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
addDependency( writer, artifact, referencedReactorArtifacts, localRepository, artifactResolver,
|
||||
artifactFactory, remoteArtifactRepositories );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Additional container classpath entries
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
for ( Iterator it = classpathContainers.iterator(); it.hasNext(); )
|
||||
{
|
||||
writer.startElement( "classpathentry" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "kind", "con" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "path", (String) it.next() ); //$NON-NLS-1$
|
||||
writer.endElement(); // name
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
|
||||
IOUtil.close( w );
|
||||
}
|
||||
|
||||
private void addDependency( XMLWriter writer, Artifact artifact, List referencedReactorArtifacts,
|
||||
ArtifactRepository localRepository, ArtifactResolver artifactResolver,
|
||||
ArtifactFactory artifactFactory, List remoteArtifactRepositories )
|
||||
{
|
||||
|
||||
String path;
|
||||
String kind;
|
||||
String sourcepath = null;
|
||||
|
||||
if ( referencedReactorArtifacts.contains( artifact ) )
|
||||
{
|
||||
path = "/" + artifact.getArtifactId(); //$NON-NLS-1$
|
||||
kind = "src"; //$NON-NLS-1$
|
||||
}
|
||||
else
|
||||
{
|
||||
File artifactPath = artifact.getFile();
|
||||
|
||||
if ( artifactPath == null )
|
||||
{
|
||||
log.error( Messages.getString( "EclipsePlugin.artifactpathisnull", artifact.getId() ) ); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
String fullPath = artifactPath.getPath();
|
||||
File localRepositoryFile = new File( localRepository.getBasedir() );
|
||||
|
||||
path = "M2_REPO/" //$NON-NLS-1$
|
||||
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, fullPath, false );
|
||||
|
||||
// source artifact: use the "sources" classifier added by the source plugin
|
||||
Artifact sourceArtifact = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact
|
||||
.getArtifactId(), artifact.getVersion(), "java-source", "sources" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
try
|
||||
{
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( Messages.getString( "EclipseClasspathWriter.lookingforsources", //$NON-NLS-1$
|
||||
sourceArtifact.getArtifactId() ) );
|
||||
}
|
||||
artifactResolver.resolve( sourceArtifact, remoteArtifactRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
// ignore, the jar has not been found
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
File sourceArtifactFile = sourceArtifact.getFile();
|
||||
|
||||
if ( !sourceArtifact.isResolved() )
|
||||
{
|
||||
log.info( Messages.getString( "EclipseClasspathWriter.sourcesnotavailable", //$NON-NLS-1$
|
||||
sourceArtifact.getArtifactId() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( Messages.getString( "EclipseClasspathWriter.sourcesavailable", //$NON-NLS-1$
|
||||
new Object[] {
|
||||
sourceArtifact.getArtifactId(),
|
||||
sourceArtifactFile.getPath() } ) );
|
||||
}
|
||||
sourcepath = "M2_REPO/" //$NON-NLS-1$
|
||||
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, sourceArtifactFile.getPath(), false );
|
||||
}
|
||||
|
||||
kind = "var"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
writer.startElement( "classpathentry" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "kind", kind ); //$NON-NLS-1$
|
||||
writer.addAttribute( "path", path ); //$NON-NLS-1$
|
||||
|
||||
if ( sourcepath != null )
|
||||
{
|
||||
writer.addAttribute( "sourcepath", sourcepath ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,13 +16,22 @@ package org.apache.maven.plugin.eclipse;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A Maven2 plugin which integrates the use of Maven2 with Eclipse.
|
||||
|
@ -37,22 +46,27 @@ import java.util.List;
|
|||
public class EclipsePlugin
|
||||
extends AbstractMojo
|
||||
{
|
||||
protected EclipseWriter eclipseWriter;
|
||||
|
||||
/**
|
||||
* Separator used for natures, builders, etc. (can't use space since conclasspath entries can contain spaces).
|
||||
*/
|
||||
private static final String LIST_SEPARATOR = ","; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The project whose project files to create.
|
||||
*
|
||||
* @parameter expression="${project}"
|
||||
* @required
|
||||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* The currently executed project (can be a reactor project).
|
||||
* @parameter expression="${executedProject}"
|
||||
*/
|
||||
private MavenProject executedProject;
|
||||
|
||||
/**
|
||||
* Local maven repository.
|
||||
* @parameter expression="${localRepository}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -60,6 +74,7 @@ public class EclipsePlugin
|
|||
private ArtifactRepository localRepository;
|
||||
|
||||
/**
|
||||
* If the executed project is a reactor project, this will contains the full list of projects in the reactor.
|
||||
* @parameter expression="${reactorProjects}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -67,42 +82,197 @@ public class EclipsePlugin
|
|||
private List reactorProjects;
|
||||
|
||||
/**
|
||||
* Artifact resolver, needed to download source jars for inclusion in classpath.
|
||||
* @parameter expression="${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
|
||||
* @required
|
||||
* @readonly
|
||||
* @todo waiting for the component tag
|
||||
*/
|
||||
private ArtifactResolver artifactResolver;
|
||||
|
||||
/**
|
||||
* Artifact factory, needed to download source jars for inclusion in classpath.
|
||||
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
|
||||
* @required
|
||||
* @readonly
|
||||
* @todo waiting for the component tag
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* Remote repositories which will be searched for source attachments.
|
||||
* @parameter expression="${project.remoteArtifactRepositories}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private List remoteArtifactRepositories;
|
||||
|
||||
/**
|
||||
* List of eclipse project natures. By default the <code>org.eclipse.jdt.core.javanature</code> nature is added.
|
||||
* Configuration example:
|
||||
* <pre>
|
||||
* <projectnatures>
|
||||
* <java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>
|
||||
* <java.lang.String>org.eclipse.wst.common.modulecore.ModuleCoreNature</java.lang.String>
|
||||
* </projectnatures>
|
||||
* </pre>
|
||||
* @parameter
|
||||
* @todo default-value="<java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>"
|
||||
*/
|
||||
private List projectnatures;
|
||||
|
||||
/**
|
||||
* List of eclipse build commands. By default the <code>org.eclipse.jdt.core.javabuilder</code> nature is added.
|
||||
* Configuration example:
|
||||
* <pre>
|
||||
* <buildcommands>
|
||||
* <java.lang.String>org.eclipse.wst.common.modulecore.ComponentStructuralBuilder</java.lang.String>
|
||||
* <java.lang.String>org.eclipse.jdt.core.javabuilder</java.lang.String>
|
||||
* <java.lang.String>org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver</java.lang.String>
|
||||
* </buildcommands>
|
||||
* </pre>
|
||||
* @parameter
|
||||
* @todo default-value="org.eclipse.jdt.core.javabuilder"
|
||||
*/
|
||||
private List buildcommands;
|
||||
|
||||
/**
|
||||
* List of container classpath entries. No classpath container is added by default.
|
||||
* Configuration example:
|
||||
* <pre>
|
||||
* <classpathContainers>
|
||||
* <java.lang.String>org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5</java.lang.String>
|
||||
* <java.lang.String>org.eclipse.jst.j2ee.internal.web.container/artifact</java.lang.String>
|
||||
* </classpathContainers>
|
||||
* </pre>
|
||||
* @parameter
|
||||
* @todo default-value=empty list
|
||||
*/
|
||||
private List classpathContainers;
|
||||
|
||||
/**
|
||||
* Eclipse workspace directory.
|
||||
* @parameter expression="${eclipse.workspace}"
|
||||
*/
|
||||
private File outputDir;
|
||||
|
||||
public EclipsePlugin()
|
||||
{
|
||||
eclipseWriter = new EclipseWriter();
|
||||
}
|
||||
|
||||
public void setProject( MavenProject project )
|
||||
/**
|
||||
* Setter for <code>project</code>. Needed for tests.
|
||||
* @param project The MavenProject to set.
|
||||
*/
|
||||
protected void setProject( MavenProject project )
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setLocalRepository( ArtifactRepository localRepository )
|
||||
/**
|
||||
* Setter for <code>localRepository</code>. Needed for tests.
|
||||
* @param localRepository The ArtifactRepository to set.
|
||||
*/
|
||||
protected void setLocalRepository( ArtifactRepository localRepository )
|
||||
{
|
||||
this.localRepository = localRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>artifactFactory</code>. Needed for tests.
|
||||
* @param artifactFactory The artifactFactory to set.
|
||||
*/
|
||||
protected void setArtifactFactory( ArtifactFactory artifactFactory )
|
||||
{
|
||||
this.artifactFactory = artifactFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>artifactResolver</code>. Needed for tests.
|
||||
* @param artifactResolver The artifactResolver to set.
|
||||
*/
|
||||
protected void setArtifactResolver( ArtifactResolver artifactResolver )
|
||||
{
|
||||
this.artifactResolver = artifactResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>remoteArtifactRepositories</code>. Needed for tests.
|
||||
* @param remoteArtifactRepositories The remoteArtifactRepositories to set.
|
||||
*/
|
||||
protected void setRemoteArtifactRepositories( List remoteArtifactRepositories )
|
||||
{
|
||||
this.remoteArtifactRepositories = remoteArtifactRepositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>buildcommands</code>. Needed for tests.
|
||||
* @param buildcommands The buildcommands to set.
|
||||
*/
|
||||
protected void setBuildcommands( List buildcommands )
|
||||
{
|
||||
this.buildcommands = buildcommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>classpathContainers</code>. Needed for tests.
|
||||
* @param classpathContainers The classpathContainers to set.
|
||||
*/
|
||||
protected void setClasspathContainers( List classpathContainers )
|
||||
{
|
||||
this.classpathContainers = classpathContainers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>projectnatures</code>. Needed for tests.
|
||||
* @param projectnatures The projectnatures to set.
|
||||
*/
|
||||
protected void setProjectnatures( List projectnatures )
|
||||
{
|
||||
this.projectnatures = projectnatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>outputDir</code>. Needed for tests.
|
||||
* @param outputDir The outputDir to set.
|
||||
*/
|
||||
public void setOutputDir( File outputDir )
|
||||
{
|
||||
this.outputDir = outputDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.plugin.Mojo#execute()
|
||||
*/
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
|
||||
assertNotEmpty( project.getGroupId(), "groupId" ); //$NON-NLS-1$
|
||||
assertNotEmpty( project.getArtifactId(), "artifactId" ); //$NON-NLS-1$
|
||||
|
||||
// defaults
|
||||
// @todo how set List values in @default-value??
|
||||
if ( projectnatures == null )
|
||||
{
|
||||
projectnatures = new ArrayList();
|
||||
projectnatures.add( "org.eclipse.jdt.core.javanature" );
|
||||
}
|
||||
if ( buildcommands == null )
|
||||
{
|
||||
buildcommands = new ArrayList();
|
||||
buildcommands.add( "org.eclipse.jdt.core.javabuilder" );
|
||||
}
|
||||
if ( classpathContainers == null )
|
||||
{
|
||||
classpathContainers = new ArrayList();
|
||||
}
|
||||
// end defaults
|
||||
|
||||
if ( project.getFile() == null || !project.getFile().exists() )
|
||||
{
|
||||
throw new MojoExecutionException( "There must be a POM in the current working directory for the Eclipse plugin to work." );
|
||||
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.missingpom" ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if ( "pom".equals( project.getPackaging() ) )
|
||||
if ( "pom".equals( project.getPackaging() ) ) //$NON-NLS-1$
|
||||
{
|
||||
getLog().info( "Don't generate Eclipse project for pom project" );
|
||||
|
||||
getLog().info( Messages.getString( "EclipsePlugin.pompackaging" ) ); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,34 +284,224 @@ public class EclipsePlugin
|
|||
{
|
||||
if ( !outputDir.isDirectory() )
|
||||
{
|
||||
throw new MojoExecutionException( "Not a directory: '" + outputDir + "'" );
|
||||
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.notadir", outputDir ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
outputDir = new File( outputDir, project.getArtifactId() );
|
||||
|
||||
if ( !outputDir.isDirectory() && !outputDir.mkdir() )
|
||||
{
|
||||
throw new MojoExecutionException( "Can't create directory '" + outputDir + "'" );
|
||||
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantcreatedir", outputDir ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
if ( executedProject == null )
|
||||
{
|
||||
eclipseWriter.setLocalRepositoryFile( new File ( localRepository.getBasedir() ) );
|
||||
|
||||
eclipseWriter.setLog( getLog() );
|
||||
|
||||
if ( executedProject == null )
|
||||
{
|
||||
// backwards compat with alpha-2 only
|
||||
executedProject = project;
|
||||
}
|
||||
|
||||
eclipseWriter.write( outputDir, project, executedProject, reactorProjects );
|
||||
// backwards compat with alpha-2 only
|
||||
executedProject = project;
|
||||
}
|
||||
catch ( EclipsePluginException e )
|
||||
|
||||
// ready to start
|
||||
write();
|
||||
|
||||
}
|
||||
|
||||
public void write()
|
||||
throws EclipsePluginException
|
||||
{
|
||||
|
||||
File projectBaseDir = project.getFile().getParentFile();
|
||||
|
||||
// build the list of referenced ARTIFACTS produced by reactor projects
|
||||
List reactorArtifacts = resolveReactorArtifacts();
|
||||
|
||||
// build a list of UNIQUE source dirs (both src and resources) to be used in classpath and wtpmodules
|
||||
EclipseSourceDir[] sourceDirs = buildDirectoryList( project, outputDir );
|
||||
|
||||
new EclipseClasspathWriter( getLog() ).write( projectBaseDir, outputDir, project, reactorArtifacts, sourceDirs,
|
||||
classpathContainers, localRepository, artifactResolver,
|
||||
artifactFactory, remoteArtifactRepositories );
|
||||
|
||||
new EclipseProjectWriter( getLog() ).write( projectBaseDir, outputDir, project, executedProject,
|
||||
reactorArtifacts, projectnatures, buildcommands );
|
||||
|
||||
new EclipseSettingsWriter( getLog() ).write( projectBaseDir, outputDir, project, executedProject );
|
||||
|
||||
new EclipseWtpmodulesWriter( getLog() ).write( outputDir, project, reactorArtifacts, sourceDirs,
|
||||
localRepository );
|
||||
|
||||
getLog().info( Messages.getString( "EclipsePlugin.wrote", //$NON-NLS-1$
|
||||
new Object[] { project.getArtifactId(), outputDir.getAbsolutePath() } ) );
|
||||
}
|
||||
|
||||
private void assertNotEmpty( String string, String elementName )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
if ( string == null )
|
||||
{
|
||||
throw new MojoExecutionException( "Error writing eclipse files.", e );
|
||||
throw new EclipsePluginException( Messages.getString( "EclipsePlugin.missingelement", elementName ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private EclipseSourceDir[] buildDirectoryList( MavenProject project, File basedir )
|
||||
{
|
||||
File projectBaseDir = project.getFile().getParentFile();
|
||||
|
||||
// avoid duplicated entries
|
||||
Set directories = new TreeSet();
|
||||
|
||||
extractSourceDirs( directories, executedProject.getCompileSourceRoots(), basedir, projectBaseDir, false, null );
|
||||
|
||||
extractResourceDirs( directories, project.getBuild().getResources(), project, basedir, projectBaseDir, false,
|
||||
null );
|
||||
|
||||
extractSourceDirs( directories, executedProject.getTestCompileSourceRoots(), basedir, projectBaseDir, true,
|
||||
EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, project.getBuild()
|
||||
.getTestOutputDirectory(), false ) );
|
||||
|
||||
extractResourceDirs( directories, project.getBuild().getTestResources(), project, basedir, projectBaseDir,
|
||||
true, EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, project.getBuild()
|
||||
.getTestOutputDirectory(), false ) );
|
||||
|
||||
return (EclipseSourceDir[]) directories.toArray( new EclipseSourceDir[directories.size()] );
|
||||
}
|
||||
|
||||
private void extractSourceDirs( Set directories, List sourceRoots, File basedir, File projectBaseDir, boolean test,
|
||||
String output )
|
||||
{
|
||||
for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
|
||||
{
|
||||
String sourceRoot = (String) it.next();
|
||||
|
||||
if ( new File( sourceRoot ).isDirectory() )
|
||||
{
|
||||
sourceRoot = EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, sourceRoot, !projectBaseDir
|
||||
.equals( basedir ) );
|
||||
|
||||
directories.add( new EclipseSourceDir( sourceRoot, output, test, null, null ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void extractResourceDirs( Set directories, List resources, MavenProject project, File basedir,
|
||||
File projectBaseDir, boolean test, String output )
|
||||
{
|
||||
for ( Iterator it = resources.iterator(); it.hasNext(); )
|
||||
{
|
||||
|
||||
Resource resource = (Resource) it.next();
|
||||
String includePattern = null;
|
||||
String excludePattern = null;
|
||||
|
||||
if ( resource.getIncludes().size() != 0 )
|
||||
{
|
||||
// @todo includePattern = ?
|
||||
getLog().warn( Messages.getString( "EclipsePlugin.includenotsupported" ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if ( resource.getExcludes().size() != 0 )
|
||||
{
|
||||
// @todo excludePattern = ?
|
||||
getLog().warn( Messages.getString( "EclipsePlugin.excludenotsupported" ) ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// Example of setting include/exclude patterns for future reference.
|
||||
//
|
||||
// TODO: figure out how to merge if the same dir is specified twice
|
||||
// with different in/exclude patterns. We can't write them now,
|
||||
// since only the the first one would be included.
|
||||
//
|
||||
// if ( resource.getIncludes().size() != 0 )
|
||||
// {
|
||||
// writer.addAttribute(
|
||||
// "including", StringUtils.join( resource.getIncludes().iterator(), "|" )
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// if ( resource.getExcludes().size() != 0 )
|
||||
// {
|
||||
// writer.addAttribute(
|
||||
// "excluding", StringUtils.join( resource.getExcludes().iterator(), "|" )
|
||||
// );
|
||||
// }
|
||||
|
||||
if ( !StringUtils.isEmpty( resource.getTargetPath() ) )
|
||||
{
|
||||
output = resource.getTargetPath();
|
||||
}
|
||||
|
||||
File resourceDirectory = new File( resource.getDirectory() );
|
||||
|
||||
if ( !resourceDirectory.exists() || !resourceDirectory.isDirectory() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String resourceDir = resource.getDirectory();
|
||||
resourceDir = EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, resourceDir, !projectBaseDir
|
||||
.equals( basedir ) );
|
||||
|
||||
if ( output != null )
|
||||
{
|
||||
output = EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, output, false );
|
||||
}
|
||||
|
||||
directories.add( new EclipseSourceDir( resourceDir, output, test, includePattern, excludePattern ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of referenced artifacts produced by reactor projects.
|
||||
* @return List of Artifacts
|
||||
*/
|
||||
private List resolveReactorArtifacts()
|
||||
{
|
||||
List referencedProjects = new ArrayList();
|
||||
|
||||
Set artifacts = project.getArtifacts();
|
||||
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
MavenProject refProject = findReactorProject( reactorProjects, artifact );
|
||||
|
||||
if ( refProject != null )
|
||||
{
|
||||
referencedProjects.add( artifact );
|
||||
}
|
||||
}
|
||||
|
||||
return referencedProjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that locates a project producing the given artifact.
|
||||
*
|
||||
* @param reactorProjects a list of projects to search.
|
||||
* @param artifact the artifact a project should produce.
|
||||
* @return null or the first project found producing the artifact.
|
||||
*/
|
||||
private static MavenProject findReactorProject( List reactorProjects, Artifact artifact )
|
||||
{
|
||||
if ( reactorProjects == null )
|
||||
{
|
||||
return null; // we're a single project
|
||||
}
|
||||
|
||||
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
{
|
||||
MavenProject project = (MavenProject) it.next();
|
||||
|
||||
if ( project.getGroupId().equals( artifact.getGroupId() )
|
||||
&& project.getArtifactId().equals( artifact.getArtifactId() )
|
||||
&& project.getVersion().equals( artifact.getVersion() ) )
|
||||
{
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,11 +16,14 @@ package org.apache.maven.plugin.eclipse;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipsePluginException extends Exception
|
||||
public class EclipsePluginException
|
||||
extends MojoExecutionException
|
||||
{
|
||||
public EclipsePluginException( String msg )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,222 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||
|
||||
/**
|
||||
* Writes eclipse .project file.
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseProjectWriter
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
public EclipseProjectWriter( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
protected void write( File projectBaseDir, File basedir, MavenProject project, MavenProject executedProject,
|
||||
List reactorArtifacts, List projectnatures, List buildCommands )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
FileWriter w;
|
||||
|
||||
try
|
||||
{
|
||||
w = new FileWriter( new File( basedir, ".project" ) ); //$NON-NLS-1$
|
||||
}
|
||||
catch ( IOException ex )
|
||||
{
|
||||
throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
|
||||
writer.startElement( "projectDescription" ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "name" ); //$NON-NLS-1$
|
||||
writer.writeText( project.getArtifactId() );
|
||||
writer.endElement();
|
||||
|
||||
// TODO: this entire element might be dropped if the comment is null.
|
||||
// but as the maven1 eclipse plugin does it, it's better to be safe than sorry
|
||||
// A eclipse developer might want to look at this.
|
||||
writer.startElement( "comment" ); //$NON-NLS-1$
|
||||
|
||||
if ( project.getDescription() != null )
|
||||
{
|
||||
writer.writeText( project.getDescription() );
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
|
||||
writer.startElement( "projects" ); //$NON-NLS-1$
|
||||
|
||||
for ( Iterator it = reactorArtifacts.iterator(); it.hasNext(); )
|
||||
{
|
||||
writer.startElement( "project" ); //$NON-NLS-1$
|
||||
writer.writeText( ( (Artifact) it.next() ).getArtifactId() );
|
||||
writer.endElement();
|
||||
}
|
||||
|
||||
writer.endElement(); // projects
|
||||
|
||||
writer.startElement( "buildSpec" ); //$NON-NLS-1$
|
||||
|
||||
for ( Iterator it = buildCommands.iterator(); it.hasNext(); )
|
||||
{
|
||||
writer.startElement( "buildCommand" ); //$NON-NLS-1$
|
||||
writer.startElement( "name" ); //$NON-NLS-1$
|
||||
writer.writeText( (String) it.next() );
|
||||
writer.endElement(); // name
|
||||
writer.startElement( "arguments" ); //$NON-NLS-1$
|
||||
writer.endElement(); // arguments
|
||||
writer.endElement(); // buildCommand
|
||||
}
|
||||
|
||||
writer.endElement(); // buildSpec
|
||||
|
||||
writer.startElement( "natures" ); //$NON-NLS-1$
|
||||
|
||||
for ( Iterator it = projectnatures.iterator(); it.hasNext(); )
|
||||
{
|
||||
writer.startElement( "nature" ); //$NON-NLS-1$
|
||||
writer.writeText( (String) it.next() );
|
||||
writer.endElement(); // name
|
||||
}
|
||||
|
||||
writer.endElement(); // natures
|
||||
|
||||
if ( !projectBaseDir.equals( basedir ) )
|
||||
{
|
||||
writer.startElement( "linkedResources" ); //$NON-NLS-1$
|
||||
|
||||
addFileLink( writer, projectBaseDir, basedir, project.getFile() );
|
||||
|
||||
addSourceLinks( writer, projectBaseDir, basedir, executedProject.getCompileSourceRoots() );
|
||||
addResourceLinks( writer, projectBaseDir, basedir, executedProject.getBuild().getResources() );
|
||||
|
||||
addSourceLinks( writer, projectBaseDir, basedir, executedProject.getTestCompileSourceRoots() );
|
||||
addResourceLinks( writer, projectBaseDir, basedir, executedProject.getBuild().getTestResources() );
|
||||
|
||||
writer.endElement(); // linedResources
|
||||
}
|
||||
|
||||
writer.endElement(); // projectDescription
|
||||
|
||||
IOUtil.close( w );
|
||||
}
|
||||
|
||||
private void addFileLink( XMLWriter writer, File projectBaseDir, File basedir, File file )
|
||||
{
|
||||
if ( file.isFile() )
|
||||
{
|
||||
writer.startElement( "link" ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "name" ); //$NON-NLS-1$
|
||||
writer.writeText( EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, file.toString(), true ) );
|
||||
writer.endElement(); // name
|
||||
|
||||
writer.startElement( "type" ); //$NON-NLS-1$
|
||||
writer.writeText( "1" ); //$NON-NLS-1$
|
||||
writer.endElement(); // type
|
||||
|
||||
writer.startElement( "location" ); //$NON-NLS-1$
|
||||
writer.writeText( file.toString().replaceAll( "\\\\", "/" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.endElement(); // location
|
||||
|
||||
writer.endElement(); // link
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn( Messages.getString( "EclipseProjectWriter.notafile", file ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private void addSourceLinks( XMLWriter writer, File projectBaseDir, File basedir, List sourceRoots )
|
||||
{
|
||||
for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
|
||||
{
|
||||
String sourceRoot = (String) it.next();
|
||||
|
||||
if ( new File( sourceRoot ).isDirectory() )
|
||||
{
|
||||
writer.startElement( "link" ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "name" ); //$NON-NLS-1$
|
||||
writer.writeText( EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, sourceRoot, true ) );
|
||||
writer.endElement(); // name
|
||||
|
||||
writer.startElement( "type" ); //$NON-NLS-1$
|
||||
writer.writeText( "2" ); //$NON-NLS-1$
|
||||
writer.endElement(); // type
|
||||
|
||||
writer.startElement( "location" ); //$NON-NLS-1$
|
||||
writer.writeText( sourceRoot.replaceAll( "\\\\", "/" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.endElement(); // location
|
||||
|
||||
writer.endElement(); // link
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addResourceLinks( XMLWriter writer, File projectBaseDir, File basedir, List sourceRoots )
|
||||
{
|
||||
for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
|
||||
{
|
||||
String resourceDir = ( (Resource) it.next() ).getDirectory();
|
||||
|
||||
if ( new File( resourceDir ).isDirectory() )
|
||||
{
|
||||
writer.startElement( "link" ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "name" ); //$NON-NLS-1$
|
||||
writer.writeText( EclipseUtils.toRelativeAndFixSeparator( projectBaseDir, resourceDir, true ) );
|
||||
writer.endElement(); // name
|
||||
|
||||
writer.startElement( "type" ); //$NON-NLS-1$
|
||||
writer.writeText( "2" ); //$NON-NLS-1$
|
||||
writer.endElement(); // type
|
||||
|
||||
writer.startElement( "location" ); //$NON-NLS-1$
|
||||
writer.writeText( resourceDir.replaceAll( "\\\\", "/" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.endElement(); // location
|
||||
|
||||
writer.endElement(); // link
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseSettingsWriter
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
public EclipseSettingsWriter( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
protected void write( File projectBaseDir, File outputDir, MavenProject project, MavenProject executedProject )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
|
||||
// check if it's necessary to create project specific settings
|
||||
Properties coreSettings = new Properties();
|
||||
|
||||
String source = EclipseUtils.getPluginSetting( project, "maven-compiler-plugin", "source", null ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String target = EclipseUtils.getPluginSetting( project, "maven-compiler-plugin", "target", null ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
if ( source != null && !source.equals( "1.3" ) ) //$NON-NLS-1$
|
||||
{
|
||||
coreSettings.put( "org.eclipse.jdt.core.compiler.source", source ); //$NON-NLS-1$
|
||||
coreSettings.put( "org.eclipse.jdt.core.compiler.compliance", source ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if ( target != null && !target.equals( "1.2" ) ) //$NON-NLS-1$
|
||||
{
|
||||
coreSettings.put( "org.eclipse.jdt.core.compiler.codegen.targetPlatform", target ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// write the settings, if needed
|
||||
if ( !coreSettings.isEmpty() )
|
||||
{
|
||||
File settingsDir = new File( outputDir, "/.settings" ); //$NON-NLS-1$
|
||||
|
||||
settingsDir.mkdirs();
|
||||
|
||||
coreSettings.put( "eclipse.preferences.version", "1" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
try
|
||||
{
|
||||
File coreSettingsFile = new File( settingsDir, "org.eclipse.jdt.core.prefs" ); //$NON-NLS-1$
|
||||
coreSettings.store( new FileOutputStream( coreSettingsFile ), null );
|
||||
|
||||
log.info( Messages.getString( "EclipseSettingsWriter.wrotesettings", //$NON-NLS-1$
|
||||
coreSettingsFile.getAbsolutePath() ) );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
throw new EclipsePluginException( Messages.getString( "EclipseSettingsWriter.cannotcreatesettings" ), e ); //$NON-NLS-1$
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new EclipsePluginException( Messages.getString( "EclipseSettingsWriter.errorwritingsettings" ), e ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info( Messages.getString( "EclipseSettingsWriter.usingdefaults" ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represent an eclipse source dir. Eclipse has no "main", "test" or "resource" concepts, so two source dirs with the
|
||||
* same path are equal.
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseSourceDir
|
||||
implements Comparable
|
||||
{
|
||||
|
||||
private String path;
|
||||
|
||||
private String output;
|
||||
|
||||
private String include;
|
||||
|
||||
private String exclude;
|
||||
|
||||
private boolean test;
|
||||
|
||||
public EclipseSourceDir( String path, String output, boolean test, String include, String exclude )
|
||||
{
|
||||
this.path = path;
|
||||
this.output = output;
|
||||
this.test = test;
|
||||
this.include = include;
|
||||
this.exclude = exclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>exclude</code>.
|
||||
* @return Returns the exclude.
|
||||
*/
|
||||
public String getExclude()
|
||||
{
|
||||
return this.exclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>exclude</code>.
|
||||
* @param exclude The exclude to set.
|
||||
*/
|
||||
public void setExclude( String exclude )
|
||||
{
|
||||
this.exclude = exclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>include</code>.
|
||||
* @return Returns the include.
|
||||
*/
|
||||
public String getInclude()
|
||||
{
|
||||
return this.include;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>include</code>.
|
||||
* @param include The include to set.
|
||||
*/
|
||||
public void setInclude( String include )
|
||||
{
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>output</code>.
|
||||
* @return Returns the output.
|
||||
*/
|
||||
public String getOutput()
|
||||
{
|
||||
return this.output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>output</code>.
|
||||
* @param output The output to set.
|
||||
*/
|
||||
public void setOutput( String output )
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>path</code>.
|
||||
* @return Returns the path.
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>path</code>.
|
||||
* @param path The path to set.
|
||||
*/
|
||||
public void setPath( String path )
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>test</code>.
|
||||
* @return Returns the test.
|
||||
*/
|
||||
public boolean isTest()
|
||||
{
|
||||
return this.test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>test</code>.
|
||||
* @param test The test to set.
|
||||
*/
|
||||
public void setTest( boolean test )
|
||||
{
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
return this.path.equals( ( (EclipseSourceDir) obj ).path );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return this.path.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
public int compareTo( Object obj )
|
||||
{
|
||||
return this.path.compareTo( ( (EclipseSourceDir) obj ).path );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseUtils
|
||||
{
|
||||
|
||||
private EclipseUtils()
|
||||
{
|
||||
// don't instantiate
|
||||
}
|
||||
|
||||
public static String toRelativeAndFixSeparator( File basedir, String absolutePath, boolean replaceSlashes )
|
||||
{
|
||||
String relative;
|
||||
|
||||
if ( absolutePath.equals( basedir.getAbsolutePath() ) )
|
||||
{
|
||||
relative = ".";
|
||||
}
|
||||
else if ( absolutePath.startsWith( basedir.getAbsolutePath() ) )
|
||||
{
|
||||
relative = absolutePath.substring( basedir.getAbsolutePath().length() + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
relative = absolutePath;
|
||||
}
|
||||
|
||||
relative = StringUtils.replace( relative, "\\", "/" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
if ( replaceSlashes )
|
||||
{
|
||||
relative = StringUtils.replace( relative, "/", "-" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
return relative;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo there should be a better way to do this
|
||||
*/
|
||||
public static String getPluginSetting( MavenProject project, String artifactId, String optionName,
|
||||
String defaultValue )
|
||||
{
|
||||
for ( Iterator it = project.getModel().getBuild().getPlugins().iterator(); it.hasNext(); )
|
||||
{
|
||||
Plugin plugin = (Plugin) it.next();
|
||||
|
||||
if ( plugin.getArtifactId().equals( artifactId ) )
|
||||
{
|
||||
Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
|
||||
|
||||
if ( o != null && o.getChild( optionName ) != null )
|
||||
{
|
||||
return o.getChild( optionName ).getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
|
@ -1,734 +0,0 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.model.Plugin;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseWriter
|
||||
{
|
||||
private Log log;
|
||||
|
||||
private File localRepository;
|
||||
|
||||
public void setLocalRepositoryFile( File localRepository )
|
||||
{
|
||||
this.localRepository = localRepository;
|
||||
}
|
||||
|
||||
public void setLog(Log log)
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public void write( File outputDir, MavenProject project, MavenProject executedProject, List reactorProjects )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
assertNotEmpty( project.getGroupId(), "groupId" );
|
||||
|
||||
assertNotEmpty( project.getArtifactId(), "artifactId" );
|
||||
|
||||
File projectBaseDir = project.getFile().getParentFile();
|
||||
|
||||
Map eclipseSourceRoots = new HashMap();
|
||||
|
||||
Collection referencedProjects = writeEclipseClasspath(
|
||||
projectBaseDir, outputDir, project, executedProject, reactorProjects, eclipseSourceRoots
|
||||
);
|
||||
|
||||
writeEclipseProject( projectBaseDir, outputDir, project, executedProject, referencedProjects, eclipseSourceRoots );
|
||||
|
||||
writeEclipseSettings( projectBaseDir, outputDir, project, executedProject);
|
||||
|
||||
log.info( "Wrote Eclipse project for " + project.getArtifactId() + " to " + outputDir.getAbsolutePath() );
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// .settings/
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private void writeEclipseSettings(
|
||||
File projectBaseDir, File outputDir, MavenProject project, MavenProject executedProject
|
||||
)
|
||||
throws EclipsePluginException
|
||||
{
|
||||
|
||||
// check if it's necessary to create project specific settings
|
||||
|
||||
Properties coreSettings = new Properties();
|
||||
|
||||
// FIXME: need a better way to do this
|
||||
|
||||
for ( Iterator it = project.getModel().getBuild().getPlugins().iterator(); it.hasNext(); )
|
||||
{
|
||||
Plugin plugin = (Plugin) it.next();
|
||||
|
||||
if ( plugin.getArtifactId().equals( "maven-compiler-plugin" ) )
|
||||
{
|
||||
handleCompilerPlugin( plugin, coreSettings );
|
||||
}
|
||||
}
|
||||
|
||||
// write the settings, if needed
|
||||
|
||||
if ( !coreSettings.isEmpty() )
|
||||
{
|
||||
File settingsDir = new File( outputDir, "/.settings" );
|
||||
|
||||
settingsDir.mkdirs();
|
||||
|
||||
coreSettings.put( "eclipse.preferences.version", "1" );
|
||||
|
||||
try
|
||||
{
|
||||
File coreSettingsFile = new File( settingsDir, "org.eclipse.jdt.core.prefs" );
|
||||
coreSettings.store( new FileOutputStream( coreSettingsFile ), null
|
||||
);
|
||||
|
||||
log.info( "Wrote settings to " + coreSettingsFile );
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new EclipsePluginException( "Cannot create settings file", e );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new EclipsePluginException( "Error writing settings file", e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info( "Not writing settings - defaults suffice" );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// .project
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected void writeEclipseProject( File projectBaseDir, File basedir, MavenProject project, MavenProject executedProject, Collection referencedProjects, Map eclipseSourceRoots )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
FileWriter w;
|
||||
|
||||
try
|
||||
{
|
||||
w = new FileWriter( new File( basedir, ".project" ) );
|
||||
}
|
||||
catch ( IOException ex )
|
||||
{
|
||||
throw new EclipsePluginException( "Exception while opening file.", ex );
|
||||
}
|
||||
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
|
||||
writer.startElement( "projectDescription" );
|
||||
|
||||
writer.startElement( "name" );
|
||||
|
||||
if ( project.getArtifactId() == null )
|
||||
{
|
||||
throw new EclipsePluginException( "Missing element from the POM: artifactId." );
|
||||
}
|
||||
|
||||
writer.writeText( project.getArtifactId() );
|
||||
|
||||
writer.endElement();
|
||||
|
||||
// TODO: this entire element might be dropped if the comment is null.
|
||||
// but as the maven1 eclipse plugin does it, it's better to be safe than sorry
|
||||
// A eclipse developer might want to look at this.
|
||||
writer.startElement( "comment" );
|
||||
|
||||
if ( project.getDescription() != null )
|
||||
{
|
||||
writer.writeText( project.getDescription() );
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
|
||||
writer.startElement( "projects" );
|
||||
|
||||
for ( Iterator it = referencedProjects.iterator(); it.hasNext(); )
|
||||
{
|
||||
writer.startElement( "project" );
|
||||
|
||||
writer.writeText( ( (MavenProject) it.next() ).getArtifactId() );
|
||||
|
||||
writer.endElement();
|
||||
}
|
||||
|
||||
writer.endElement(); // projects
|
||||
|
||||
writer.startElement( "buildSpec" );
|
||||
|
||||
writer.startElement( "buildCommand" );
|
||||
|
||||
writer.startElement( "name" );
|
||||
|
||||
writer.writeText( "org.eclipse.jdt.core.javabuilder" );
|
||||
|
||||
writer.endElement(); // name
|
||||
|
||||
writer.startElement( "arguments" );
|
||||
|
||||
writer.endElement(); // arguments
|
||||
|
||||
writer.endElement(); // buildCommand
|
||||
|
||||
writer.endElement(); // buildSpec
|
||||
|
||||
writer.startElement( "natures" );
|
||||
|
||||
writer.startElement( "nature" );
|
||||
|
||||
writer.writeText( "org.eclipse.jdt.core.javanature" );
|
||||
|
||||
writer.endElement(); // nature
|
||||
|
||||
writer.endElement(); // natures
|
||||
|
||||
|
||||
if ( ! projectBaseDir.equals( basedir ) )
|
||||
{
|
||||
writer.startElement( "linkedResources" );
|
||||
|
||||
addFileLink( writer, projectBaseDir, basedir, project.getFile() );
|
||||
|
||||
addSourceLinks( writer, projectBaseDir, basedir, eclipseSourceRoots );
|
||||
|
||||
writer.endElement(); // linkedResources
|
||||
}
|
||||
|
||||
writer.endElement(); // projectDescription
|
||||
|
||||
close( w );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// .classpath
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected Collection writeEclipseClasspath( File projectBaseDir, File basedir, MavenProject project, MavenProject executedProject, List reactorProjects, Map eclipseSourceRoots )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
FileWriter w;
|
||||
|
||||
try
|
||||
{
|
||||
w = new FileWriter( new File( basedir, ".classpath" ) );
|
||||
}
|
||||
catch ( IOException ex )
|
||||
{
|
||||
throw new EclipsePluginException( "Exception while opening file.", ex );
|
||||
}
|
||||
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
|
||||
writer.startElement( "classpath" );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The source roots
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
addSourceRoots( writer, projectBaseDir, basedir,
|
||||
executedProject.getCompileSourceRoots(),
|
||||
null, eclipseSourceRoots );
|
||||
|
||||
addResources( writer, projectBaseDir, basedir,
|
||||
project.getBuild().getResources(),
|
||||
null, eclipseSourceRoots );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The test sources and resources
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
addSourceRoots( writer, projectBaseDir, basedir,
|
||||
executedProject.getTestCompileSourceRoots(),
|
||||
project.getBuild().getTestOutputDirectory(),
|
||||
eclipseSourceRoots );
|
||||
|
||||
addResources( writer, projectBaseDir, basedir,
|
||||
project.getBuild().getTestResources(),
|
||||
project.getBuild().getTestOutputDirectory(),
|
||||
eclipseSourceRoots );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The default output
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
writer.startElement( "classpathentry" );
|
||||
|
||||
writer.addAttribute( "kind", "output" );
|
||||
|
||||
writer.addAttribute( "path", toRelative( projectBaseDir, project.getBuild().getOutputDirectory() ) );
|
||||
|
||||
writer.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The JRE reference
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
writer.startElement( "classpathentry" );
|
||||
|
||||
writer.addAttribute( "kind", "var" );
|
||||
|
||||
writer.addAttribute( "rootpath", "JRE_SRCROOT" );
|
||||
|
||||
writer.addAttribute( "path", "JRE_LIB" );
|
||||
|
||||
writer.addAttribute( "sourcepath", "JRE_SRC" );
|
||||
|
||||
writer.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The dependencies
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Collection referencedProjects = new HashSet();
|
||||
|
||||
Set artifacts = project.getArtifacts();
|
||||
|
||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
addDependency( writer, artifact, reactorProjects, referencedProjects );
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
|
||||
close( w );
|
||||
|
||||
return referencedProjects;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private void addSourceRoots( XMLWriter writer, File projectBaseDir, File basedir, List sourceRoots, String output, Map addedSourceRoots )
|
||||
{
|
||||
for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
|
||||
{
|
||||
String sourceRoot = (String) it.next();
|
||||
|
||||
if ( new File( sourceRoot ).isDirectory() )
|
||||
{
|
||||
String eclipseSourceRoot = toRelative( projectBaseDir, sourceRoot );
|
||||
|
||||
// Don't add the same sourceroots twice. No include/exclude
|
||||
// patterns possible in maven for (test|script|)source directories.
|
||||
if ( addedSourceRoots.containsKey( eclipseSourceRoot ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
writer.startElement( "classpathentry" );
|
||||
|
||||
writer.addAttribute( "kind", "src" );
|
||||
|
||||
if (!projectBaseDir.equals(basedir))
|
||||
{
|
||||
eclipseSourceRoot = eclipseSourceRoot.replaceAll( "/", "-" );
|
||||
}
|
||||
|
||||
addedSourceRoots.put( eclipseSourceRoot, sourceRoot );
|
||||
|
||||
writer.addAttribute( "path", eclipseSourceRoot );
|
||||
|
||||
if ( output != null )
|
||||
{
|
||||
writer.addAttribute( "output", toRelative( projectBaseDir, output ) );
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addResources( XMLWriter writer, File projectBaseDir, File basedir, List resources, String output, Map addedSourceRoots )
|
||||
{
|
||||
for ( Iterator it = resources.iterator(); it.hasNext(); )
|
||||
{
|
||||
Resource resource = (Resource) it.next();
|
||||
|
||||
if ( resource.getIncludes().size() != 0 )
|
||||
{
|
||||
log.warn( "This plugin currently doesn't support include patterns for resources. Adding the entire directory." );
|
||||
}
|
||||
|
||||
if ( resource.getExcludes().size() != 0 )
|
||||
{
|
||||
log.warn( "This plugin currently doesn't support exclude patterns for resources. Adding the entire directory." );
|
||||
}
|
||||
|
||||
if ( !StringUtils.isEmpty( resource.getTargetPath() ) )
|
||||
{
|
||||
output = resource.getTargetPath();
|
||||
}
|
||||
|
||||
File resourceDirectory = new File( resource.getDirectory() );
|
||||
|
||||
if ( !resourceDirectory.exists() || !resourceDirectory.isDirectory() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String resourceDir = resource.getDirectory();
|
||||
|
||||
String eclipseResourceDir = toRelative( projectBaseDir, resourceDir );
|
||||
|
||||
// don't add the same sourceroot twice; eclipse can't handle
|
||||
// that, even with mutual exclusive include/exclude patterns.
|
||||
if ( addedSourceRoots.containsKey( eclipseResourceDir ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! projectBaseDir.equals( basedir ) )
|
||||
{
|
||||
eclipseResourceDir = eclipseResourceDir.replaceAll( "/", "-" );
|
||||
}
|
||||
|
||||
addedSourceRoots.put( eclipseResourceDir, resourceDir );
|
||||
|
||||
writer.startElement( "classpathentry" );
|
||||
|
||||
writer.addAttribute( "kind", "src" );
|
||||
|
||||
writer.addAttribute( "path", eclipseResourceDir );
|
||||
|
||||
// Example of setting include/exclude patterns for future reference.
|
||||
//
|
||||
// TODO: figure out how to merge if the same dir is specified twice
|
||||
// with different in/exclude patterns. We can't write them now,
|
||||
// since only the the first one would be included.
|
||||
//
|
||||
// if ( resource.getIncludes().size() != 0 )
|
||||
// {
|
||||
// writer.addAttribute(
|
||||
// "including", StringUtils.join( resource.getIncludes().iterator(), "|" )
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// if ( resource.getExcludes().size() != 0 )
|
||||
// {
|
||||
// writer.addAttribute(
|
||||
// "excluding", StringUtils.join( resource.getExcludes().iterator(), "|" )
|
||||
// );
|
||||
// }
|
||||
|
||||
if ( output != null )
|
||||
{
|
||||
writer.addAttribute( "output", toRelative( projectBaseDir, output ) );
|
||||
}
|
||||
|
||||
writer.endElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void addSourceLinks( XMLWriter writer, File projectBaseDir, File basedir, Map sourceRoots )
|
||||
{
|
||||
List roots = new ArrayList( sourceRoots.keySet() );
|
||||
Collections.sort( roots );
|
||||
|
||||
for ( Iterator it = roots.iterator(); it.hasNext(); )
|
||||
{
|
||||
String linkName = (String) it.next();
|
||||
|
||||
String sourceRoot = (String) sourceRoots.get( linkName );
|
||||
|
||||
sourceRoot = sourceRoot.replace('\\', '/');
|
||||
|
||||
log.debug( "Adding link '" + linkName + "' to '" + sourceRoot + "'" );
|
||||
|
||||
if ( new File( sourceRoot ).isDirectory() )
|
||||
{
|
||||
writer.startElement( "link" );
|
||||
|
||||
writer.startElement( "name" );
|
||||
|
||||
writer.writeText( linkName );
|
||||
|
||||
writer.endElement(); // name
|
||||
|
||||
writer.startElement( "type" );
|
||||
|
||||
writer.writeText( "2" );
|
||||
|
||||
writer.endElement(); // type
|
||||
|
||||
writer.startElement( "location" );
|
||||
|
||||
writer.writeText( sourceRoot );
|
||||
|
||||
writer.endElement(); // location
|
||||
|
||||
writer.endElement(); // link
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addFileLink( XMLWriter writer, File projectBaseDir, File basedir, File file )
|
||||
{
|
||||
if ( file.isFile() )
|
||||
{
|
||||
writer.startElement( "link" );
|
||||
|
||||
writer.startElement( "name" );
|
||||
|
||||
writer.writeText( toRelative( projectBaseDir, file.toString() ).replaceAll( "/", "-" ) );
|
||||
|
||||
writer.endElement(); // name
|
||||
|
||||
writer.startElement( "type" );
|
||||
|
||||
writer.writeText( "1" );
|
||||
|
||||
writer.endElement(); // type
|
||||
|
||||
writer.startElement( "location" );
|
||||
|
||||
writer.writeText( file.toString().replaceAll( "\\\\", "/" ) );
|
||||
|
||||
writer.endElement(); // location
|
||||
|
||||
writer.endElement(); // link
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn( "Not adding a file link to " + file + "; it is not a file" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param writer
|
||||
* @param artifact
|
||||
* @param reactorProjects
|
||||
* @return null or the reactorProject providing this dependency
|
||||
*/
|
||||
private void addDependency( XMLWriter writer, Artifact artifact, List reactorProjects, Collection referencedProjects )
|
||||
{
|
||||
MavenProject reactorProject = findReactorProject( reactorProjects, artifact );
|
||||
|
||||
String path = null;
|
||||
|
||||
String kind = null;
|
||||
|
||||
if ( reactorProject != null )
|
||||
{
|
||||
// if there's a dependency on multiple artifact attachments of the
|
||||
// same project, don't add it again.
|
||||
|
||||
if ( !markAddedOnce( reactorProject, referencedProjects ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
path = "/" + reactorProject.getArtifactId();
|
||||
|
||||
kind = "src";
|
||||
}
|
||||
else
|
||||
{
|
||||
File artifactPath = artifact.getFile();
|
||||
|
||||
if ( artifactPath == null )
|
||||
{
|
||||
log.error( "The artifacts path was null. Artifact id: " + artifact.getId() );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
path = "M2_REPO/" + toRelative( localRepository, artifactPath.getPath() );
|
||||
|
||||
kind = "var";
|
||||
}
|
||||
|
||||
writer.startElement( "classpathentry" );
|
||||
|
||||
writer.addAttribute( "kind", kind );
|
||||
|
||||
writer.addAttribute( "path", path );
|
||||
|
||||
writer.endElement();
|
||||
}
|
||||
|
||||
private static boolean markAddedOnce( MavenProject project, Collection referencedProjects )
|
||||
{
|
||||
if ( referencedProjects.contains( project ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
referencedProjects.add( project );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that locates a project producing the given artifact.
|
||||
*
|
||||
* @param reactorProjects a list of projects to search.
|
||||
* @param artifact the artifact a project should produce.
|
||||
* @return null or the first project found producing the artifact.
|
||||
*/
|
||||
private static MavenProject findReactorProject( List reactorProjects, Artifact artifact )
|
||||
{
|
||||
if ( reactorProjects == null )
|
||||
{
|
||||
return null; // we're a single project
|
||||
}
|
||||
|
||||
for (Iterator it = reactorProjects.iterator(); it.hasNext(); )
|
||||
{
|
||||
MavenProject project = (MavenProject) it.next();
|
||||
|
||||
if ( project.getGroupId().equals( artifact.getGroupId() )
|
||||
&& project.getArtifactId().equals( artifact.getArtifactId() )
|
||||
&& project.getVersion().equals( artifact.getVersion() )
|
||||
)
|
||||
{
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void close( Writer closeable )
|
||||
{
|
||||
if ( closeable == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
closeable.close();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private static String toRelative( File basedir, String absolutePath )
|
||||
{
|
||||
String relative;
|
||||
|
||||
if ( absolutePath.equals( basedir.getAbsolutePath() ) )
|
||||
{
|
||||
relative = ".";
|
||||
}
|
||||
else if ( absolutePath.startsWith( basedir.getAbsolutePath() ) )
|
||||
{
|
||||
relative = absolutePath.substring( basedir.getAbsolutePath().length() + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
relative = absolutePath;
|
||||
}
|
||||
|
||||
relative = StringUtils.replace( relative, "\\", "/" );
|
||||
|
||||
return relative;
|
||||
}
|
||||
|
||||
private static void assertNotEmpty( String string, String elementName )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
if ( string == null )
|
||||
{
|
||||
throw new EclipsePluginException( "Missing element from the project descriptor: '" + elementName + "'." );
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleCompilerPlugin( Plugin plugin, Properties coreSettings )
|
||||
{
|
||||
Xpp3Dom pluginConfig = (Xpp3Dom) plugin.getConfiguration();
|
||||
|
||||
if ( pluginConfig == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String source = null;
|
||||
|
||||
Xpp3Dom sourceChild = pluginConfig.getChild( "source" );
|
||||
|
||||
if (sourceChild != null)
|
||||
{
|
||||
source = sourceChild.getValue();
|
||||
}
|
||||
|
||||
String target = null;
|
||||
|
||||
Xpp3Dom targetChild = pluginConfig.getChild( "target" );
|
||||
|
||||
if (targetChild != null)
|
||||
{
|
||||
target = targetChild.getValue();
|
||||
}
|
||||
|
||||
if ( source != null && !source.equals( "1.3" ) )
|
||||
{
|
||||
coreSettings.put( "org.eclipse.jdt.core.compiler.source", source );
|
||||
|
||||
coreSettings.put( "org.eclipse.jdt.core.compiler.compliance", source );
|
||||
}
|
||||
|
||||
if ( target != null && !target.equals( "1.2" ) )
|
||||
{
|
||||
coreSettings.put( "org.eclipse.jdt.core.compiler.codegen.targetPlatform", target );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||
|
||||
/**
|
||||
* Writes eclipse .wtpmodules file.
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipseWtpmodulesWriter
|
||||
{
|
||||
|
||||
private Log log;
|
||||
|
||||
public EclipseWtpmodulesWriter( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
protected void write( File basedir, MavenProject project, List referencedReactorArtifacts,
|
||||
EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository )
|
||||
throws EclipsePluginException
|
||||
{
|
||||
FileWriter w;
|
||||
|
||||
try
|
||||
{
|
||||
w = new FileWriter( new File( basedir, ".wtpmodules" ) ); //$NON-NLS-1$
|
||||
}
|
||||
catch ( IOException ex )
|
||||
{
|
||||
throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
|
||||
writer.startElement( "project-modules" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "id", "moduleCoreId" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
writer.startElement( "wb-module" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "deploy-name", project.getArtifactId() ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "module-type" ); //$NON-NLS-1$
|
||||
if ( "war".equals( project.getPackaging() ) ) //$NON-NLS-1$
|
||||
{
|
||||
// <module-type module-type-id="jst.web">
|
||||
// <version>2.4</version>
|
||||
// <property name="context-root" value="magnolia">
|
||||
// </property>
|
||||
// </module-type>
|
||||
|
||||
writer.addAttribute( "module-type-id", "jst.web" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
writer.startElement( "version" ); //$NON-NLS-1$
|
||||
|
||||
// defaults to 2.4, try to detect real version from dependencies
|
||||
String servletVersion = "2.4"; //$NON-NLS-1$
|
||||
|
||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
if ( "servletapi".equals( artifact.getArtifactId() ) //$NON-NLS-1$
|
||||
|| "geronimo-spec-servlet".equals( artifact.getArtifactId() ) ) //$NON-NLS-1$
|
||||
{
|
||||
servletVersion = StringUtils.substring( artifact.getVersion(), 0, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeText( servletVersion );
|
||||
writer.endElement();
|
||||
|
||||
writer.startElement( "property" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "name", "context-root" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "value", project.getArtifactId() ); //$NON-NLS-1$
|
||||
writer.endElement();
|
||||
}
|
||||
else if ( "ejb".equals( project.getPackaging() ) ) //$NON-NLS-1$
|
||||
{
|
||||
// <module-type module-type-id="jst.ejb">
|
||||
// <version>2.1</version>
|
||||
// <property name="java-output-path" value="/bin/"/>
|
||||
// </module-type>
|
||||
|
||||
writer.addAttribute( "module-type-id", "jst.ejb" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
writer.startElement( "version" ); //$NON-NLS-1$
|
||||
writer.writeText( "2.1" ); //$NON-NLS-1$
|
||||
// @todo this is the default, find real ejb version from dependencies
|
||||
writer.endElement();
|
||||
|
||||
writer.startElement( "property" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "name", "java-output-path" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "value", "/" + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
EclipseUtils.toRelativeAndFixSeparator( project.getBasedir(), project.getBuild().getOutputDirectory(),
|
||||
false ) );
|
||||
writer.endElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
// <module-type module-type-id="jst.utility">
|
||||
// <property name="java-output-path" value="/bin/"/>
|
||||
// </module-type>
|
||||
|
||||
writer.addAttribute( "module-type-id", "jst.utility" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
writer.startElement( "property" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "name", "java-output-path" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "value", "/" + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
EclipseUtils.toRelativeAndFixSeparator( project.getBasedir(), project.getBuild().getOutputDirectory(),
|
||||
false ) );
|
||||
writer.endElement();
|
||||
}
|
||||
writer.endElement(); // module-type
|
||||
|
||||
// source and resource paths.
|
||||
// deploy-path is "/" for utility and ejb projects, "/WEB-INF/classes" for webapps
|
||||
|
||||
String target = "/"; //$NON-NLS-1$
|
||||
if ( "war".equals( project.getPackaging() ) ) //$NON-NLS-1$
|
||||
{
|
||||
writeWarSpecificResources( writer, basedir, project, referencedReactorArtifacts, localRepository );
|
||||
|
||||
target = "/WEB-INF/classes"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for ( int j = 0; j < sourceDirs.length; j++ )
|
||||
{
|
||||
EclipseSourceDir dir = sourceDirs[j];
|
||||
// test src/resources are not added to wtpmodules
|
||||
if ( !dir.isTest() )
|
||||
{
|
||||
// <wb-resource deploy-path="/" source-path="/src/java" />
|
||||
writer.startElement( "wb-resource" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "deploy-path", target ); //$NON-NLS-1$
|
||||
writer.addAttribute( "source-path", dir.getPath() ); //$NON-NLS-1$
|
||||
writer.endElement();
|
||||
}
|
||||
}
|
||||
|
||||
writer.endElement(); // wb-module
|
||||
writer.endElement(); // project-modules
|
||||
|
||||
IOUtil.close( w );
|
||||
}
|
||||
|
||||
private void writeWarSpecificResources( XMLWriter writer, File basedir, MavenProject project,
|
||||
List referencedReactorArtifacts, ArtifactRepository localRepository )
|
||||
{
|
||||
|
||||
String warSourceDirectory = EclipseUtils.getPluginSetting( project, "maven-war-plugin", //$NON-NLS-1$
|
||||
"warSourceDirectory", //$NON-NLS-1$
|
||||
"/src/main/webapp" ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "wb-resource" ); //$NON-NLS-1$
|
||||
writer.addAttribute( "deploy-path", "/" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "source-path", //$NON-NLS-1$
|
||||
EclipseUtils.toRelativeAndFixSeparator( basedir, warSourceDirectory, false ) );
|
||||
writer.endElement();
|
||||
|
||||
// dependencies
|
||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
addDependency( writer, artifact, referencedReactorArtifacts, localRepository );
|
||||
}
|
||||
}
|
||||
|
||||
private void addDependency( XMLWriter writer, Artifact artifact, List referencedReactorProjects,
|
||||
ArtifactRepository localRepository )
|
||||
{
|
||||
String handle;
|
||||
|
||||
if ( referencedReactorProjects.contains( artifact ) )
|
||||
{
|
||||
// <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/artifactid/artifactid">
|
||||
// <dependency-type>uses</dependency-type>
|
||||
// </dependent-module>
|
||||
|
||||
handle = "module:/resource/" + artifact.getArtifactId() + "/" + artifact.getArtifactId(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
else
|
||||
{
|
||||
// <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/cl/cl/2.1/cl-2.1.jar">
|
||||
// <dependency-type>uses</dependency-type>
|
||||
// </dependent-module>
|
||||
|
||||
File artifactPath = artifact.getFile();
|
||||
|
||||
if ( artifactPath == null )
|
||||
{
|
||||
log.error( Messages.getString( "EclipsePlugin.artifactpathisnull", artifact.getId() ) ); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
String fullPath = artifactPath.getPath();
|
||||
File localRepositoryFile = new File( localRepository.getBasedir() );
|
||||
|
||||
handle = "module:/classpath/var/M2_REPO/" //$NON-NLS-1$
|
||||
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, fullPath, false );
|
||||
}
|
||||
|
||||
writer.startElement( "dependent-module" ); //$NON-NLS-1$
|
||||
|
||||
writer.addAttribute( "deploy-path", "/WEB-INF/lib" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
writer.addAttribute( "handle", handle ); //$NON-NLS-1$
|
||||
|
||||
writer.startElement( "dependency-type" ); //$NON-NLS-1$
|
||||
writer.writeText( "uses" ); //$NON-NLS-1$
|
||||
writer.endElement();
|
||||
|
||||
writer.endElement();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Messages
|
||||
{
|
||||
private static final String BUNDLE_NAME = "org.apache.maven.plugin.eclipse.messages"; //$NON-NLS-1$
|
||||
|
||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
|
||||
|
||||
private Messages()
|
||||
{
|
||||
}
|
||||
|
||||
public static String getString( String key )
|
||||
{
|
||||
try
|
||||
{
|
||||
return RESOURCE_BUNDLE.getString( key );
|
||||
}
|
||||
catch ( MissingResourceException e )
|
||||
{
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
|
||||
public static String getString( String key, Object[] params )
|
||||
{
|
||||
try
|
||||
{
|
||||
return MessageFormat.format( RESOURCE_BUNDLE.getString( key ), params );
|
||||
}
|
||||
catch ( MissingResourceException e )
|
||||
{
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
|
||||
public static String getString( String key, Object param )
|
||||
{
|
||||
return getString( key, new Object[] { param } );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
EclipsePlugin.missingpom=There must be a POM in the current working directory for the Eclipse plugin to work.
|
||||
EclipsePlugin.pompackaging=Don't generate Eclipse project for pom project
|
||||
EclipsePlugin.notadir=Not a directory: "{0}"
|
||||
EclipsePlugin.cantcreatedir=Can''t create directory "{0}"
|
||||
EclipsePlugin.erroropeningfile=Exception while opening file.
|
||||
EclipsePlugin.wrote=Wrote Eclipse project for "{0}" to {1}.
|
||||
EclipsePlugin.missingelement=Missing element from the project descriptor: "{0}"
|
||||
EclipsePlugin.includenotsupported=This plugin currently doesn't support include patterns for resources. Adding the entire directory.
|
||||
EclipsePlugin.excludenotsupported=This plugin currently doesn't support exclude patterns for resources. Adding the entire directory.
|
||||
EclipsePlugin.artifactpathisnull=The artifact path was null. Artifact id: {0}
|
||||
|
||||
EclipseSettingsWriter.wrotesettings=Wrote settings to {0}
|
||||
EclipseSettingsWriter.cannotcreatesettings=Cannot create settings file
|
||||
EclipseSettingsWriter.errorwritingsettings=Error writing settings file
|
||||
EclipseSettingsWriter.usingdefaults=Not writing settings - defaults suffice
|
||||
|
||||
EclipseClasspathWriter.lookingforsources=Looking for source archive for artifact {0}
|
||||
EclipseClasspathWriter.sourcesnotavailable=Sources for artifact {0} are not available
|
||||
EclipseClasspathWriter.sourcesavailable=Sources attachment for artifact {0} set to {1}
|
||||
|
||||
EclipseProjectWriter.notafile=Not adding a file link to {0}; it is not a file
|
|
@ -16,15 +16,6 @@ package org.apache.maven.plugin.eclipse;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
@ -33,6 +24,17 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
|
@ -61,12 +63,20 @@ public class EclipsePluginTest
|
|||
public void testProject4()
|
||||
throws Exception
|
||||
{
|
||||
testProject( "project-4", getTestFile( "target/project-4-test/" ) );
|
||||
testProject( "project-4", getTestFile( "target/project-4-test/" ) );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
public void testProject5()
|
||||
throws Exception
|
||||
{
|
||||
testProject( "project-5", null );
|
||||
}
|
||||
|
||||
public void testProject6()
|
||||
throws Exception
|
||||
{
|
||||
testProject( "project-6", null );
|
||||
}
|
||||
|
||||
private void testProject( String projectName, File outputDir )
|
||||
throws Exception
|
||||
|
@ -79,12 +89,16 @@ public class EclipsePluginTest
|
|||
|
||||
File repo = getTestFile( "src/test/repository" );
|
||||
|
||||
ArtifactRepositoryLayout localRepositoryLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
|
||||
ArtifactRepositoryLayout localRepositoryLayout = (ArtifactRepositoryLayout) lookup(
|
||||
ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", "file://" + repo.getAbsolutePath(),
|
||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local",
|
||||
"file://" + repo.getAbsolutePath(),
|
||||
localRepositoryLayout );
|
||||
|
||||
MavenProject project = builder.buildWithDependencies( new File( basedir, "project.xml" ), localRepository, null );
|
||||
MavenProject project = builder
|
||||
.buildWithDependencies( new File( basedir, "project.xml" ), localRepository, null );
|
||||
|
||||
File projectOutputDir = basedir;
|
||||
|
||||
|
@ -99,26 +113,56 @@ public class EclipsePluginTest
|
|||
projectOutputDir = new File( outputDir, project.getArtifactId() );
|
||||
}
|
||||
|
||||
System.err.println("basedir: " + basedir+"\noutputdir: " + outputDir+"\nprojectOutputDir: " + projectOutputDir );
|
||||
// Shouldn't PlexusTestCase at least offer a predefined log instance?
|
||||
// if ( log.isDebugEnabled() )
|
||||
// {
|
||||
// log.debug( "basedir: " + basedir + "\noutputdir: " + outputDir + "\nprojectOutputDir: " + projectOutputDir );
|
||||
// }
|
||||
|
||||
plugin.setOutputDir( outputDir );
|
||||
|
||||
|
||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
artifact.setFile(new File(localRepository.getBasedir(), localRepository.pathOf(artifact)));
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ) );
|
||||
}
|
||||
|
||||
plugin.setProject( project );
|
||||
|
||||
plugin.setLocalRepository( localRepository );
|
||||
|
||||
plugin.setArtifactFactory( (ArtifactFactory) lookup( ArtifactFactory.ROLE ) );
|
||||
plugin.setArtifactResolver( (ArtifactResolver) lookup( ArtifactResolver.ROLE ) );
|
||||
plugin.setRemoteArtifactRepositories( new ArrayList( 0 ) );
|
||||
|
||||
List projectNatures = new ArrayList();
|
||||
projectNatures.add( "org.eclipse.jdt.core.javanature" );
|
||||
plugin.setProjectnatures( projectNatures );
|
||||
|
||||
List buildcommands = new ArrayList();
|
||||
buildcommands.add( "org.eclipse.jdt.core.javabuilder" );
|
||||
plugin.setBuildcommands( buildcommands );
|
||||
|
||||
plugin.setClasspathContainers( new ArrayList() );
|
||||
|
||||
// @todo how to test injected parameters?
|
||||
|
||||
plugin.execute();
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "project" ), new File( projectOutputDir, ".project" ) );
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "project" ), new File( projectOutputDir,
|
||||
".project" ) );
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "classpath" ), new File( projectOutputDir, ".classpath" ) );
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "classpath" ), new File( projectOutputDir,
|
||||
".classpath" ) );
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "wtpmodules" ), new File( projectOutputDir,
|
||||
".wtpmodules" ) );
|
||||
|
||||
if ( new File( basedir, "settings" ).exists() )
|
||||
{
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "settings" ),
|
||||
new File( basedir, ".settings/org.eclipse.jdt.core.prefs" ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void assertFileEquals( String mavenRepo, File expectedFile, File actualFile )
|
||||
|
@ -137,14 +181,21 @@ public class EclipsePluginTest
|
|||
|
||||
expected = StringUtils.replace( expected, "${basedir}", basedir.replace( '\\', '/' ) );
|
||||
|
||||
if ( actualLines.size() < i )
|
||||
if ( actualLines.size() <= i )
|
||||
{
|
||||
fail( "Too few lines in the actual file. Was " + actualLines.size() + ", expected: " + expectedLines.size() );
|
||||
fail( "Too few lines in the actual file. Was " + actualLines.size() + ", expected: "
|
||||
+ expectedLines.size() );
|
||||
}
|
||||
|
||||
String actual = actualLines.get( i ).toString();
|
||||
|
||||
assertEquals( "Checking line #" + (i + 1), expected, actual );
|
||||
if ( expected.startsWith( "#" ) && actual.startsWith( "#" ) )
|
||||
{
|
||||
//ignore comments, for settings file
|
||||
continue;
|
||||
}
|
||||
|
||||
assertEquals( "Checking line #" + ( i + 1 ), expected, actual );
|
||||
}
|
||||
|
||||
assertTrue( "Unequal number of lines.", expectedLines.size() == actualLines.size() );
|
||||
|
@ -159,7 +210,7 @@ public class EclipsePluginTest
|
|||
|
||||
String line;
|
||||
|
||||
while ( (line = reader.readLine()) != null )
|
||||
while ( ( line = reader.readLine() ) != null )
|
||||
{
|
||||
lines.add( line );//StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) );
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
||||
<classpathentry kind="var" path="M2_REPO/maven/jars/maven-core-98.0.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/maven/jars/maven-core-98.0.jar" sourcepath="M2_REPO/maven/java-sources/maven-core-98.0-sources.jar"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipse</groupId>
|
||||
<artifactId>maven-eclipse-plugin-test-project-1</artifactId>
|
||||
<version>99.0</version>
|
||||
<name>Maven</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
|
@ -14,5 +13,4 @@
|
|||
<version>98.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="maven-eclipse-plugin-test-project-1">
|
||||
<module-type module-type-id="jst.utility">
|
||||
<property name="java-output-path" value="/target/classes"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="src/main/java"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipse</groupId>
|
||||
<artifactId>maven-eclipse-plugin-test-project-2</artifactId>
|
||||
<version>88.0</version>
|
||||
<name>Maven</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -14,5 +13,15 @@
|
|||
<version>2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#Fri Aug 26 21:33:13 CEST 2005
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
|
||||
eclipse.preferences.version=1
|
|
@ -0,0 +1,9 @@
|
|||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="maven-eclipse-plugin-test-project-2">
|
||||
<module-type module-type-id="jst.utility">
|
||||
<property name="java-output-path" value="/target/classes"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="src/main/resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -1,9 +1,7 @@
|
|||
<projectDescription>
|
||||
<name>maven-eclipse-plugin-test-project-3</name>
|
||||
<comment>Tests creating just one sourceroot when test sourceroot and
|
||||
main sourceroot are the same, and tests the same for
|
||||
two resourceroots for the same directory but with different
|
||||
include/excludes.</comment>
|
||||
<comment>Tests creating just one sourceroot when test sourceroot and main sourceroot are the same, and tests the same for two
|
||||
resourceroots for the same directory but with different include/excludes.</comment>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipse</groupId>
|
||||
<artifactId>maven-eclipse-plugin-test-project-3</artifactId>
|
||||
<version>88.0</version>
|
||||
<name>Maven</name>
|
||||
|
||||
<description>
|
||||
Tests creating just one sourceroot when test sourceroot and
|
||||
main sourceroot are the same, and tests the same for
|
||||
two resourceroots for the same directory but with different
|
||||
include/excludes.
|
||||
Tests creating just one sourceroot when test sourceroot and main sourceroot are the same, and tests the same for two
|
||||
resourceroots for the same directory but with different include/excludes.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -21,7 +17,6 @@
|
|||
<version>2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/main/java</testSourceDirectory>
|
||||
|
@ -47,6 +42,11 @@
|
|||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="maven-eclipse-plugin-test-project-3">
|
||||
<module-type module-type-id="jst.utility">
|
||||
<property name="java-output-path" value="/target/classes"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="src/main/resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -1,16 +1,11 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipse</groupId>
|
||||
<artifactId>maven-eclipse-plugin-test-project-4</artifactId>
|
||||
<version>88.0</version>
|
||||
<name>Maven</name>
|
||||
|
||||
<description>
|
||||
Tests creating eclipse files in a different location
|
||||
</description>
|
||||
|
||||
<description>Tests creating eclipse files in a different location</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -18,7 +13,6 @@
|
|||
<version>2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testOutputDirectory>target/test-classes-dir</testOutputDirectory>
|
||||
<resources>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="maven-eclipse-plugin-test-project-4">
|
||||
<module-type module-type-id="jst.utility">
|
||||
<property name="java-output-path" value="/target/classes"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="src-main-java"/>
|
||||
<wb-resource deploy-path="/" source-path="src-main-resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -0,0 +1,6 @@
|
|||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
||||
<classpathentry kind="var" path="M2_REPO/maven/jars/maven-core-98.0.jar" sourcepath="M2_REPO/maven/java-sources/maven-core-98.0-sources.jar"/>
|
||||
</classpath>
|
|
@ -0,0 +1,14 @@
|
|||
<projectDescription>
|
||||
<name>maven-eclipse-plugin-test-project-5</name>
|
||||
<comment/>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>war</packaging>
|
||||
<groupId>eclipse</groupId>
|
||||
<artifactId>maven-eclipse-plugin-test-project-5</artifactId>
|
||||
<version>99.0</version>
|
||||
<name>Maven</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>98.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<configuration>
|
||||
<projectnatures>
|
||||
org.eclipse.jdt.core.javanature, org.eclipse.wst.common.modulecore.ModuleCoreNature
|
||||
</projectnatures>
|
||||
<buildcommands>
|
||||
org.eclipse.wst.common.modulecore.ComponentStructuralBuilder, org.eclipse.jdt.core.javabuilder,
|
||||
org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver
|
||||
</buildcommands>
|
||||
<classpathContainers>
|
||||
org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5,
|
||||
org.eclipse.jst.j2ee.internal.web.container/wtptest
|
||||
</classpathContainers>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,5 @@
|
|||
#Sat Aug 20 22:43:01 CEST 2005
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.source=1.4
|
||||
org.eclipse.jdt.core.compiler.compliance=1.4
|
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DummyClass
|
||||
{
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="maven-eclipse-plugin-test-project-5">
|
||||
<module-type module-type-id="jst.web">
|
||||
<version>2.4</version>
|
||||
<property name="context-root" value="maven-eclipse-plugin-test-project-5"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/maven/jars/maven-core-98.0.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -0,0 +1,6 @@
|
|||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
||||
<classpathentry kind="var" path="M2_REPO/maven/jars/maven-core-98.0.jar" sourcepath="M2_REPO/maven/java-sources/maven-core-98.0-sources.jar"/>
|
||||
</classpath>
|
|
@ -0,0 +1,14 @@
|
|||
<projectDescription>
|
||||
<name>maven-eclipse-plugin-test-project-6</name>
|
||||
<comment/>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>ejb</packaging>
|
||||
<groupId>eclipse</groupId>
|
||||
<artifactId>maven-eclipse-plugin-test-project-6</artifactId>
|
||||
<version>99.0</version>
|
||||
<name>Maven</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>98.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DummyClass
|
||||
{
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="maven-eclipse-plugin-test-project-6">
|
||||
<module-type module-type-id="jst.ejb">
|
||||
<version>2.1</version>
|
||||
<property name="java-output-path" value="/target/classes"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="src/main/java"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
Loading…
Reference in New Issue