You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/04/02 20:16:22 UTC
svn commit: r761364 [1/2] - in
/tuscany/maven-plugins/trunk/maven-bundle-plugin: ./
src/main/java/org/apache/tuscany/maven/plugin/eclipse/
src/main/resources/org/apache/tuscany/maven/plugin/eclipse/
Author: rfeng
Date: Thu Apr 2 18:16:21 2009
New Revision: 761364
URL: http://svn.apache.org/viewvc?rev=761364&view=rev
Log:
Update to the latest maven-eclipse-plugin 2.6
Modified:
tuscany/maven-plugins/trunk/maven-bundle-plugin/pom.xml
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/AbstractIdeSupportMojo.java
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseClasspathWriter.java
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseCleanMojo.java
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipsePlugin.java
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseProjectWriter.java
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/Messages.java
tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/resources/org/apache/tuscany/maven/plugin/eclipse/messages.properties
Modified: tuscany/maven-plugins/trunk/maven-bundle-plugin/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-bundle-plugin/pom.xml?rev=761364&r1=761363&r2=761364&view=diff
==============================================================================
--- tuscany/maven-plugins/trunk/maven-bundle-plugin/pom.xml (original)
+++ tuscany/maven-plugins/trunk/maven-bundle-plugin/pom.xml Thu Apr 2 18:16:21 2009
@@ -156,7 +156,7 @@
<artifactId>maven-plugin-api</artifactId>
<version>2.0.8</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@@ -168,44 +168,44 @@
</exclusion>
</exclusions>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>2.0.8</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0.8</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0.8</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>1.1</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
- <version>2.5.1</version>
+ <version>2.6</version>
</dependency>
-
+
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.3.0-v20070530</version>
<scope>compile</scope>
</dependency>
-
+
</dependencies>
<build>
Modified: tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/AbstractIdeSupportMojo.java
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/AbstractIdeSupportMojo.java?rev=761364&r1=761363&r2=761364&view=diff
==============================================================================
--- tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/AbstractIdeSupportMojo.java (original)
+++ tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/AbstractIdeSupportMojo.java Thu Apr 2 18:16:21 2009
@@ -20,7 +20,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -30,7 +29,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.jar.Attributes;
@@ -52,8 +50,10 @@
import org.apache.maven.artifact.resolver.WarningResolutionListener;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.RuntimeInformation;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Exclusion;
@@ -61,18 +61,18 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.eclipse.Constants;
+import org.apache.maven.plugin.eclipse.Messages;
import org.apache.maven.plugin.ide.IdeDependency;
import org.apache.maven.plugin.ide.IdeUtils;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.IOUtil;
/**
* Abstract base plugin which takes care of the common stuff usually needed by maven IDE plugins. A plugin extending
- * AbstractIdeSupportMojo should implement the <code>setup()</code> and <code>writeConfiguration()</code> methods,
- * plus the getters needed to get the various configuration flags and required components. The lifecycle:
- *
+ * AbstractIdeSupportMojo should implement the <code>setup()</code> and <code>writeConfiguration()</code> methods, plus
+ * the getters needed to get the various configuration flags and required components. The lifecycle:
+ *
* <pre>
* *** calls setup() where you can configure your specific stuff and stop the mojo from execute if appropriate ***
* - manually resolve project dependencies, NOT failing if a dependency is missing
@@ -81,9 +81,9 @@
* *** calls writeConfiguration(), passing the list of resolved referenced dependencies ***
* - report the list of missing sources or just tell how to turn this feature on if the flag was disabled
* </pre>
- *
+ *
* @author Fabrizio Giustina
- * @version $Id: AbstractIdeSupportMojo.java 628794 2008-02-18 16:09:11Z aheritier $
+ * @version $Id: AbstractIdeSupportMojo.java 727620 2008-12-18 02:35:18Z baerrach $
*/
public abstract class AbstractIdeSupportMojo
extends AbstractMojo
@@ -94,24 +94,23 @@
* Additionally it copies all libraries to a project local directory and references them instead of referencing the
* files in the local Maven repository. It also ensured that the "Bundle-Classpath" in META-INF/MANIFEST.MF is
* synchronized.
- *
+ *
* @parameter expression="${eclipse.pde}" default-value="true"
*/
protected boolean pde;
-
+
/**
* The project whose project files to create.
- *
+ *
* @parameter expression="${project}"
* @required
* @readonly
*/
protected MavenProject project;
- // [rfeng] Change it to use the current project
/**
* The currently executed project (can be a reactor project).
- *
+ *
* @parameter expression="${executedProject}"
* @readonly
*/
@@ -119,14 +118,14 @@
/**
* The project packaging.
- *
+ *
* @parameter expression="${project.packaging}"
*/
protected String packaging;
/**
* Artifact factory, needed to download source jars for inclusion in classpath.
- *
+ *
* @component role="org.apache.maven.artifact.factory.ArtifactFactory"
* @required
* @readonly
@@ -135,7 +134,7 @@
/**
* Artifact resolver, needed to download source jars for inclusion in classpath.
- *
+ *
* @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
* @required
* @readonly
@@ -144,7 +143,7 @@
/**
* Artifact collector, needed to resolve dependencies.
- *
+ *
* @component role="org.apache.maven.artifact.resolver.ArtifactCollector"
* @required
* @readonly
@@ -157,8 +156,15 @@
protected ArtifactMetadataSource artifactMetadataSource;
/**
+ * The runtime information for Maven, used to retrieve Maven's version number.
+ *
+ * @component
+ */
+ private RuntimeInformation runtimeInformation;
+
+ /**
* Remote repositories which will be searched for source attachments.
- *
+ *
* @parameter expression="${project.remoteArtifactRepositories}"
* @required
* @readonly
@@ -167,7 +173,7 @@
/**
* Local maven repository.
- *
+ *
* @parameter expression="${localRepository}"
* @required
* @readonly
@@ -176,7 +182,7 @@
/**
* If the executed project is a reactor project, this will contains the full list of projects in the reactor.
- *
+ *
* @parameter expression="${reactorProjects}"
* @required
* @readonly
@@ -185,7 +191,7 @@
/**
* Skip the operation when true.
- *
+ *
* @parameter expression="${eclipse.skip}" default-value="false"
*/
private boolean skip;
@@ -193,9 +199,9 @@
/**
* Enables/disables the downloading of source attachments. Defaults to false. When this flag is <code>true</code>
* remote repositories are checked for sources: in order to avoid repeated check for unavailable source archives, a
- * status cache is mantained into the target dir of the root project. Run <code>mvn:clean</code> or delete the
- * file <code>mvn-eclipse-cache.properties</code> in order to reset this cache.
- *
+ * status cache is mantained. To reset this cache run <code>mvn eclipse:remove-cache</code>, or use the
+ * <code>forceRecheck</code> option.
+ *
* @parameter expression="${downloadSources}"
*/
protected boolean downloadSources;
@@ -203,21 +209,31 @@
/**
* Enables/disables the downloading of javadoc attachments. Defaults to false. When this flag is <code>true</code>
* remote repositories are checked for javadocs: in order to avoid repeated check for unavailable javadoc archives,
- * a status cache is mantained into the target dir of the root project. Run <code>mvn:clean</code> or delete the
- * file <code>mvn-eclipse-cache.properties</code> in order to reset this cache.
- *
+ * a status cache is mantained. To reset this cache run <code>mvn eclipse:remove-cache</code>, or use the
+ * <code>forceRecheck</code> option.
+ *
* @parameter expression="${downloadJavadocs}"
*/
protected boolean downloadJavadocs;
/**
+ * Enables/disables the rechecking of the remote repository for downloading source/javadoc attachments. Defaults to
+ * false. When this flag is <code>true</code> and the source or javadoc attachment has a status cache to indicate
+ * that it is not available, then the remote repository will be rechecked for a source or javadoc attachment and the
+ * status cache updated to reflect the new state.
+ *
+ * @parameter expression="${forceRecheck}"
+ */
+ protected boolean forceRecheck;
+
+ /**
* Plexus logger needed for debugging manual artifact resolution.
*/
protected Logger logger;
/**
* Getter for <code>artifactMetadataSource</code>.
- *
+ *
* @return Returns the artifactMetadataSource.
*/
public ArtifactMetadataSource getArtifactMetadataSource()
@@ -227,7 +243,7 @@
/**
* Setter for <code>artifactMetadataSource</code>.
- *
+ *
* @param artifactMetadataSource The artifactMetadataSource to set.
*/
public void setArtifactMetadataSource( ArtifactMetadataSource artifactMetadataSource )
@@ -237,7 +253,7 @@
/**
* Getter for <code>project</code>.
- *
+ *
* @return Returns the project.
*/
public MavenProject getProject()
@@ -247,7 +263,7 @@
/**
* Setter for <code>project</code>.
- *
+ *
* @param project The project to set.
*/
public void setProject( MavenProject project )
@@ -257,7 +273,7 @@
/**
* Getter for <code>reactorProjects</code>.
- *
+ *
* @return Returns the reactorProjects.
*/
public List getReactorProjects()
@@ -267,7 +283,7 @@
/**
* Setter for <code>reactorProjects</code>.
- *
+ *
* @param reactorProjects The reactorProjects to set.
*/
public void setReactorProjects( List reactorProjects )
@@ -277,7 +293,7 @@
/**
* Getter for <code>remoteArtifactRepositories</code>.
- *
+ *
* @return Returns the remoteArtifactRepositories.
*/
public List getRemoteArtifactRepositories()
@@ -287,7 +303,7 @@
/**
* Setter for <code>remoteArtifactRepositories</code>.
- *
+ *
* @param remoteArtifactRepositories The remoteArtifactRepositories to set.
*/
public void setRemoteArtifactRepositories( List remoteArtifactRepositories )
@@ -297,7 +313,7 @@
/**
* Getter for <code>artifactFactory</code>.
- *
+ *
* @return Returns the artifactFactory.
*/
public ArtifactFactory getArtifactFactory()
@@ -307,7 +323,7 @@
/**
* Setter for <code>artifactFactory</code>.
- *
+ *
* @param artifactFactory The artifactFactory to set.
*/
public void setArtifactFactory( ArtifactFactory artifactFactory )
@@ -317,7 +333,7 @@
/**
* Getter for <code>artifactResolver</code>.
- *
+ *
* @return Returns the artifactResolver.
*/
public ArtifactResolver getArtifactResolver()
@@ -327,7 +343,7 @@
/**
* Setter for <code>artifactResolver</code>.
- *
+ *
* @param artifactResolver The artifactResolver to set.
*/
public void setArtifactResolver( ArtifactResolver artifactResolver )
@@ -337,7 +353,7 @@
/**
* Getter for <code>executedProject</code>.
- *
+ *
* @return Returns the executedProject.
*/
public MavenProject getExecutedProject()
@@ -347,7 +363,7 @@
/**
* Setter for <code>executedProject</code>.
- *
+ *
* @param executedProject The executedProject to set.
*/
public void setExecutedProject( MavenProject executedProject )
@@ -357,7 +373,7 @@
/**
* Getter for <code>localRepository</code>.
- *
+ *
* @return Returns the localRepository.
*/
public ArtifactRepository getLocalRepository()
@@ -367,7 +383,7 @@
/**
* Setter for <code>localRepository</code>.
- *
+ *
* @param localRepository The localRepository to set.
*/
public void setLocalRepository( ArtifactRepository localRepository )
@@ -377,7 +393,7 @@
/**
* Getter for <code>downloadJavadocs</code>.
- *
+ *
* @return Returns the downloadJavadocs.
*/
public boolean getDownloadJavadocs()
@@ -387,8 +403,8 @@
/**
* Setter for <code>downloadJavadocs</code>.
- *
- * @param downloadJavadocs The downloadJavadocs to set.
+ *
+ * @param downloadJavadoc The downloadJavadocs to set.
*/
public void setDownloadJavadocs( boolean downloadJavadoc )
{
@@ -397,7 +413,7 @@
/**
* Getter for <code>downloadSources</code>.
- *
+ *
* @return Returns the downloadSources.
*/
public boolean getDownloadSources()
@@ -407,7 +423,7 @@
/**
* Setter for <code>downloadSources</code>.
- *
+ *
* @param downloadSources The downloadSources to set.
*/
public void setDownloadSources( boolean downloadSources )
@@ -428,14 +444,14 @@
/**
* return <code>false</code> if projects available in a reactor build should be considered normal dependencies,
* <code>true</code> if referenced project will be linked and not need artifact resolution.
- *
+ *
* @return <code>true</code> if referenced project will be linked and not need artifact resolution
*/
protected abstract boolean getUseProjectReferences();
/**
* Hook for preparation steps before the actual plugin execution.
- *
+ *
* @return <code>true</code> if execution should continue or <code>false</code> if not.
* @throws MojoExecutionException generic mojo exception
*/
@@ -444,7 +460,7 @@
/**
* Main plugin method where dependencies should be processed in order to generate IDE configuration files.
- *
+ *
* @param deps list of <code>IdeDependency</code> objects, with artifacts, sources and javadocs already resolved
* @throws MojoExecutionException generic mojo exception
*/
@@ -513,7 +529,7 @@
* Resolve project dependencies. Manual resolution is needed in order to avoid resolution of multiproject artifacts
* (if projects will be linked each other an installed jar is not needed) and to avoid a failure when a jar is
* missing.
- *
+ *
* @throws MojoExecutionException if dependencies can't be resolved
* @return resolved IDE dependencies, with attached jars for non-reactor dependencies
*/
@@ -561,7 +577,7 @@
{
getLog().debug( e.getMessage(), e );
getLog().error(
- Messages.getString( "artifactresolution", new Object[] { //$NON-NLS-1$
+ Messages.getString( "AbstractIdeSupportMojo.artifactresolution", new Object[] { //$NON-NLS-1$
e.getGroupId(), e.getArtifactId(), e.getVersion(),
e.getMessage() } ) );
@@ -592,7 +608,7 @@
{
getLog().debug( e.getMessage(), e );
getLog().warn(
- Messages.getString( "artifactdownload", new Object[] { //$NON-NLS-1$
+ Messages.getString( "AbstractIdeSupportMojo.artifactdownload", new Object[] { //$NON-NLS-1$
e.getGroupId(), e.getArtifactId(), e.getVersion(),
e.getMessage() } ) );
}
@@ -600,7 +616,7 @@
{
getLog().debug( e.getMessage(), e );
getLog().warn(
- Messages.getString( "artifactresolution", new Object[] { //$NON-NLS-1$
+ Messages.getString( "AbstractIdeSupportMojo.artifactresolution", new Object[] { //$NON-NLS-1$
e.getGroupId(), e.getArtifactId(), e.getVersion(),
e.getMessage() } ) );
}
@@ -617,9 +633,9 @@
}
}
- if ( includeArtifact &&
- ( !( getUseProjectReferences() && isAvailableAsAReactorProject( art ) ) || emittedReactorProjectId.add( art.getGroupId() +
- '-' + art.getArtifactId() ) ) )
+ if ( includeArtifact
+ && ( !( getUseProjectReferences() && isAvailableAsAReactorProject( art ) ) || emittedReactorProjectId.add( art.getGroupId()
+ + '-' + art.getArtifactId() ) ) )
{
// the following doesn't work: art.getArtifactHandler().getPackaging() always returns "jar"
@@ -715,7 +731,7 @@
/**
* Find the name of the project as used in eclipse.
- *
+ *
* @param artifact The artifact to find the eclipse name for.
* @return The name os the eclipse project.
*/
@@ -724,7 +740,7 @@
/**
* Returns the list of project artifacts. Also artifacts generated from referenced projects will be added, but with
* the <code>resolved</code> property set to true.
- *
+ *
* @return list of projects artifacts
* @throws MojoExecutionException if unable to parse dependency versions
*/
@@ -749,7 +765,7 @@
{
throw new MojoExecutionException(
Messages.getString(
- "unabletoparseversion", new Object[] { //$NON-NLS-1$
+ "AbstractIdeSupportMojo.unabletoparseversion", new Object[] { //$NON-NLS-1$
dependency.getArtifactId(),
dependency.getVersion(),
dependency.getManagementKey(), e.getMessage() } ),
@@ -797,37 +813,47 @@
/**
* Utility method that locates a project producing the given artifact.
- *
+ *
* @param artifact the artifact a project should produce.
* @return <code>true</code> if the artifact is produced by a reactor projectart.
*/
protected boolean isAvailableAsAReactorProject( Artifact artifact )
{
+ return getReactorProject( artifact ) != null;
+ }
+
+ /**
+ * Checks the list of reactor projects to see if the artifact is included.
+ *
+ * @param artifact the artifact to check if it is in the reactor
+ * @return the reactor project or null if it is not in the reactor
+ */
+ protected MavenProject getReactorProject( Artifact artifact ) {
if ( reactorProjects != null )
{
for ( Iterator iter = reactorProjects.iterator(); iter.hasNext(); )
{
MavenProject reactorProject = (MavenProject) iter.next();
- if ( reactorProject.getGroupId().equals( artifact.getGroupId() ) &&
- reactorProject.getArtifactId().equals( artifact.getArtifactId() ) )
+ if ( reactorProject.getGroupId().equals( artifact.getGroupId() )
+ && reactorProject.getArtifactId().equals( artifact.getArtifactId() ) )
{
if ( reactorProject.getVersion().equals( artifact.getVersion() ) )
{
- return true;
+ return reactorProject;
}
else
{
getLog().info(
- "Artifact " +
- artifact.getId() +
- " already available as a reactor project, but with different version. Expected: " +
- artifact.getVersion() + ", found: " + reactorProject.getVersion() );
+ "Artifact "
+ + artifact.getId()
+ + " already available as a reactor project, but with different version. Expected: "
+ + artifact.getVersion() + ", found: " + reactorProject.getVersion() );
}
}
}
}
- return false;
+ return null;
}
/**
@@ -861,7 +887,7 @@
}
catch ( InvalidVersionSpecificationException e )
{
- throw new MojoExecutionException( Messages.getString( "unabletoparseversion", new Object[] { //$NON-NLS-1$
+ throw new MojoExecutionException( Messages.getString( "AbstractIdeSupportMojo.unabletoparseversion", new Object[] { //$NON-NLS-1$
projectId, d.getVersion(),
d.getManagementKey(), e.getMessage() } ),
e );
@@ -876,104 +902,35 @@
}
/**
- * Find the reactor target dir. executedProject doesn't have the multiproject root dir set, and the only way to
- * extract it is iterating on parent projects.
- *
- * @param prj current project
- * @return the parent target dir.
- */
- private File getReactorTargetDir( MavenProject prj )
- {
- if ( prj.getParent() != null )
- {
- if ( prj.getParent().getBasedir() != null && prj.getParent().getBasedir().exists() )
- {
- return getReactorTargetDir( prj.getParent() );
- }
- }
- return new File( prj.getBuild().getDirectory() );
- }
-
- /**
* Resolve source artifacts and download them if <code>downloadSources</code> is <code>true</code>. Source and
* javadocs artifacts will be attached to the <code>IdeDependency</code> Resolve source and javadoc artifacts. The
- * resolved artifacts will be downloaded based on the <code>downloadSources</code> and
- * <code>downloadJavadocs</code> attributes. Source and
- *
+ * resolved artifacts will be downloaded based on the <code>downloadSources</code> and <code>downloadJavadocs</code>
+ * attributes. Source and
+ *
* @param deps resolved dependencies
*/
private void resolveSourceAndJavadocArtifacts( IdeDependency[] deps )
{
-
- File reactorTargetDir = getReactorTargetDir( project );
- File unavailableArtifactsTmpFile = new File( reactorTargetDir, "mvn-eclipse-cache.properties" );
-
- getLog().info( "Using source status cache: " + unavailableArtifactsTmpFile.getAbsolutePath() );
-
- // create target dir if missing
- if ( !unavailableArtifactsTmpFile.getParentFile().exists() )
- {
- unavailableArtifactsTmpFile.getParentFile().mkdirs();
- }
-
- Properties unavailableArtifactsCache = new Properties();
- if ( unavailableArtifactsTmpFile.exists() )
- {
- InputStream is = null;
- try
- {
- is = new FileInputStream( unavailableArtifactsTmpFile );
- unavailableArtifactsCache.load( is );
- }
- catch ( IOException e )
- {
- getLog().warn( "Unable to read source status for reactor projects" );
- }
- finally
- {
- IOUtil.close( is );
- }
-
- }
-
final List missingSources =
- resolveDependenciesWithClassifier( deps, "sources", getDownloadSources(), unavailableArtifactsCache );
+ resolveDependenciesWithClassifier( deps, "sources", getDownloadSources() );
missingSourceDependencies.addAll( missingSources );
final List missingJavadocs =
- resolveDependenciesWithClassifier( deps, "javadoc", getDownloadJavadocs(), unavailableArtifactsCache );
+ resolveDependenciesWithClassifier( deps, "javadoc", getDownloadJavadocs() );
missingJavadocDependencies.addAll( missingJavadocs );
-
- FileOutputStream fos = null;
- try
- {
- fos = new FileOutputStream( unavailableArtifactsTmpFile );
- unavailableArtifactsCache.store( fos, "Temporary index for unavailable sources and javadocs" );
- }
- catch ( IOException e )
- {
- getLog().warn( "Unable to cache source status for reactor projects" );
- }
- finally
- {
- IOUtil.close( fos );
- }
-
}
/**
- * Resolve the required artifacts for each of the dependency. <code>sources</code> or <code>javadoc</code>
- * artifacts (depending on the <code>classifier</code>) are attached to the dependency.
- *
+ * Resolve the required artifacts for each of the dependency. <code>sources</code> or <code>javadoc</code> artifacts
+ * (depending on the <code>classifier</code>) are attached to the dependency.
+ *
* @param deps resolved dependencies
* @param inClassifier the classifier we are looking for (either <code>sources</code> or <code>javadoc</code>)
* @param includeRemoteRepositories flag whether we should search remote repositories for the artifacts or not
- * @param unavailableArtifactsCache cache of unavailable artifacts
* @return the list of dependencies for which the required artifact was not found
*/
private List resolveDependenciesWithClassifier( IdeDependency[] deps, String inClassifier,
- boolean includeRemoteRepositories,
- Properties unavailableArtifactsCache )
+ boolean includeRemoteRepositories )
{
List missingClassifierDependencies = new ArrayList();
@@ -994,21 +951,37 @@
if ( getLog().isDebugEnabled() )
{
getLog().debug(
- "Searching for sources for " + dependency.getId() + ":" + dependency.getClassifier() +
- " at " + dependency.getId() + ":" + inClassifier );
+ "Searching for sources for " + dependency.getId() + ":" + dependency.getClassifier()
+ + " at " + dependency.getId() + ":" + inClassifier );
}
- String key =
- dependency.getClassifier() == null ? dependency.getId() + ":" + inClassifier : dependency.getId() +
- ":" + inClassifier + ":" + dependency.getClassifier();
+ Artifact baseArtifact =
+ artifactFactory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), dependency.getType(),
+ dependency.getClassifier() );
+ baseArtifact =
+ IdeUtils.resolveArtifact( artifactResolver, baseArtifact, remoteRepos, localRepository, getLog() );
+ if (!baseArtifact.isResolved()) {
+ // base artifact does not exist - no point checking for javadoc/sources
+ continue;
+ }
- if ( !unavailableArtifactsCache.containsKey( key ) )
+ Artifact artifact =
+ IdeUtils.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), dependency.getClassifier(),
+ inClassifier, artifactFactory );
+ File notAvailableMarkerFile = IdeUtils.getNotAvailableMarkerFile( localRepository, artifact );
+
+ if (forceRecheck && notAvailableMarkerFile.exists()) {
+ if (!notAvailableMarkerFile.delete()) {
+ getLog().warn( Messages.getString( "AbstractIdeSupportMojo.unabletodeletenotavailablemarkerfile", notAvailableMarkerFile ) );
+ }
+ }
+
+ if ( !notAvailableMarkerFile.exists() )
{
- Artifact artifact =
- IdeUtils.resolveArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getVersion(), dependency.getClassifier(),
- inClassifier, localRepository, artifactResolver,
- artifactFactory, remoteRepos, getLog() );
+ artifact =
+ IdeUtils.resolveArtifact( artifactResolver, artifact, remoteRepos, localRepository, getLog() );
if ( artifact.isResolved() )
{
if ( "sources".equals( inClassifier ) )
@@ -1022,7 +995,19 @@
}
else
{
- unavailableArtifactsCache.put( key, Boolean.TRUE.toString() );
+ if ( includeRemoteRepositories )
+ {
+ try
+ {
+ notAvailableMarkerFile.createNewFile();
+ getLog().debug( Messages.getString( "AbstractIdeSupportMojo.creatednotavailablemarkerfile", notAvailableMarkerFile ) );
+ }
+ catch ( IOException e )
+ {
+ getLog().warn( Messages.getString( "AbstractIdeSupportMojo.failedtocreatenotavailablemarkerfile",
+ notAvailableMarkerFile ) );
+ }
+ }
// add the dependencies to the list
// of those lacking the required
// artifact
@@ -1048,17 +1033,17 @@
{
if ( getDownloadSources() )
{
- msg.append( Messages.getString( "sourcesnotavailable" ) ); //$NON-NLS-1$
+ msg.append( Messages.getString( "AbstractIdeSupportMojo.sourcesnotavailable" ) ); //$NON-NLS-1$
}
else
{
- msg.append( Messages.getString( "sourcesnotdownloaded" ) ); //$NON-NLS-1$
+ msg.append( Messages.getString( "AbstractIdeSupportMojo.sourcesnotdownloaded" ) ); //$NON-NLS-1$
}
for ( Iterator it = missingSourceDependencies.iterator(); it.hasNext(); )
{
IdeDependency art = (IdeDependency) it.next();
- msg.append( Messages.getString( "sourcesmissingitem", art.getId() ) ); //$NON-NLS-1$
+ msg.append( Messages.getString( "AbstractIdeSupportMojo.sourcesmissingitem", art.getId() ) ); //$NON-NLS-1$
}
msg.append( "\n" ); //$NON-NLS-1$
}
@@ -1067,17 +1052,17 @@
{
if ( getDownloadJavadocs() )
{
- msg.append( Messages.getString( "javadocnotavailable" ) ); //$NON-NLS-1$
+ msg.append( Messages.getString( "AbstractIdeSupportMojo.javadocnotavailable" ) ); //$NON-NLS-1$
}
else
{
- msg.append( Messages.getString( "javadocnotdownloaded" ) ); //$NON-NLS-1$
+ msg.append( Messages.getString( "AbstractIdeSupportMojo.javadocnotdownloaded" ) ); //$NON-NLS-1$
}
for ( Iterator it = missingJavadocDependencies.iterator(); it.hasNext(); )
{
IdeDependency art = (IdeDependency) it.next();
- msg.append( Messages.getString( "javadocmissingitem", art.getId() ) ); //$NON-NLS-1$
+ msg.append( Messages.getString( "AbstractIdeSupportMojo.javadocmissingitem", art.getId() ) ); //$NON-NLS-1$
}
msg.append( "\n" ); //$NON-NLS-1$
}
@@ -1092,7 +1077,7 @@
/**
* Checks if jar has to be resolved for the given artifact
- *
+ *
* @param art the artifact to check
* @return true if resolution should happen
*/
@@ -1103,7 +1088,7 @@
/**
* Checks if a projects reference has to be used for the given artifact
- *
+ *
* @param art the artifact to check
* @return true if a project reference has to be used.
*/
@@ -1111,7 +1096,29 @@
{
return getUseProjectReferences() && isAvailableAsAReactorProject( art );
}
-
+
+ /**
+ * Checks whether the currently running Maven satisfies the specified version (range).
+ *
+ * @param version The version range to test for, must not be <code>null</code>.
+ * @return <code>true</code> if the current Maven version matches the specified version range, <code>false</code>
+ * otherwise.
+ */
+ protected boolean isMavenVersion( String version )
+ {
+ try
+ {
+ VersionRange versionRange = VersionRange.createFromVersionSpec( version );
+ ArtifactVersion mavenVersion = runtimeInformation.getApplicationVersion();
+ return versionRange.containsVersion( mavenVersion );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ throw new IllegalArgumentException( e.getMessage() );
+ }
+ }
+
+ // [rfeng]
protected boolean isOSGiBundle() {
File base = project.getBasedir();
File mf = new File(base, "META-INF/MANIFEST.MF");
@@ -1133,4 +1140,5 @@
}
return false;
}
+
}
Modified: tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseClasspathWriter.java
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseClasspathWriter.java?rev=761364&r1=761363&r2=761364&view=diff
==============================================================================
--- tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseClasspathWriter.java (original)
+++ tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseClasspathWriter.java Thu Apr 2 18:16:21 2009
@@ -32,9 +32,13 @@
import java.util.Set;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.BuildCommand;
import org.apache.maven.plugin.eclipse.Constants;
import org.apache.maven.plugin.eclipse.EclipseSourceDir;
+import org.apache.maven.plugin.eclipse.Messages;
import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter;
+import org.apache.maven.plugin.eclipse.writers.EclipseAntExternalLaunchConfigurationWriter;
+import org.apache.maven.plugin.eclipse.writers.EclipseLaunchConfigurationWriter;
import org.apache.maven.plugin.ide.IdeDependency;
import org.apache.maven.plugin.ide.IdeUtils;
import org.codehaus.plexus.util.IOUtil;
@@ -44,20 +48,50 @@
/**
* 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@apache.org">Fabrizio Giustina</a>
- * @version $Id: EclipseClasspathWriter.java 636955 2008-03-14 02:10:42Z aheritier $
+ * @version $Id: EclipseClasspathWriter.java 750073 2009-03-04 16:55:01Z aheritier $
*/
public class EclipseClasspathWriter
extends AbstractEclipseWriter
{
/**
+ *
+ */
+ private static final String ORG_ECLIPSE_AJDT_INPATH = "org.eclipse.ajdt.inpath";
+
+ /**
+ *
+ */
+ private static final String ORG_ECLIPSE_AJDT_ASPECTPATH = "org.eclipse.ajdt.aspectpath";
+
+ /**
+ *
+ */
+ private static final String NAME = "name";
+
+ /**
+ *
+ */
+ private static final String VALUE = "value";
+
+ /**
+ *
+ */
+ private static final String ATTRIBUTE = "attribute";
+
+ /**
+ *
+ */
+ private static final String ATTRIBUTES = "attributes";
+
+ /**
* Eclipse build path variable M2_REPO
*/
- private static final String M2_REPO = "M2_REPO"; //$NON-NLS-1$
+ protected static final String M2_REPO = "M2_REPO"; //$NON-NLS-1$
/**
* Attribute for sourcepath.
@@ -120,7 +154,7 @@
private static final String FILE_DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$
/**
- * @see org.apache.tuscany.sca.maven.plugin.eclipse.writers.EclipseWriter#write()
+ * @see org.apache.maven.plugin.eclipse.writers.EclipseWriter#write()
*/
public void write()
throws MojoExecutionException
@@ -175,8 +209,8 @@
{
EclipseSourceDir dir = config.getSourceDirs()[j];
- log.debug( "Processing " + ( dir.isResource() ? "re" : "" ) + "source " + dir.getPath() + ": output=" +
- dir.getOutput() + "; default output=" + defaultOutput );
+ log.debug( "Processing " + ( dir.isResource() ? "re" : "" ) + "source " + dir.getPath() + ": output="
+ + dir.getOutput() + "; default output=" + defaultOutput );
boolean isSpecial = false;
@@ -187,8 +221,7 @@
// and if the default output has any sources that copy there.
if ( dir.getOutput() != null // resource output dir is set
- &&
- !dir.getOutput().equals( defaultOutput ) // output dir is not default target/classes
+ && !dir.getOutput().equals( defaultOutput ) // output dir is not default target/classes
&& dir.getOutput().startsWith( defaultOutput ) // ... but is nested
&& byOutputDir.get( defaultOutput ) != null // ???
&& !( (List) byOutputDir.get( defaultOutput ) ).isEmpty() // ???
@@ -197,8 +230,8 @@
// do not specify as source since the output will be nested. Instead, mark
// it as a todo, and handle it with a custom build.xml file later.
- log.debug( "Marking as special to prevent output folder nesting: " + dir.getPath() + " (output=" +
- dir.getOutput() + ")" );
+ log.debug( "Marking as special to prevent output folder nesting: " + dir.getPath() + " (output="
+ + dir.getOutput() + ")" );
isSpecial = true;
specialSources.add( dir );
@@ -215,9 +248,18 @@
writer.addAttribute( ATTR_OUTPUT, dir.getOutput() );
}
- if ( StringUtils.isNotEmpty( dir.getInclude() ) )
+ String includes = dir.getInclude();
+
+ if ( !dir.isResource() )
+ {
+ // automatically include java files only: eclipse doesn't have the concept of a source only directory so it
+ // will try to include non-java files found in maven source dirs
+ includes = StringUtils.isEmpty( includes ) ? "**/*.java" : includes + "|**/*.java";
+ }
+
+ if ( StringUtils.isNotEmpty( includes ) )
{
- writer.addAttribute( ATTR_INCLUDING, dir.getInclude() );
+ writer.addAttribute( ATTR_INCLUDING, includes );
}
String excludes = dir.getExclude();
@@ -255,12 +297,12 @@
buildXmlPrinter.addAttribute( "default", "copy-resources" );
buildXmlPrinter.startElement( "target" );
- buildXmlPrinter.addAttribute( "name", "init" );
+ buildXmlPrinter.addAttribute( NAME, "init" );
// initialize filtering tokens here
buildXmlPrinter.endElement();
buildXmlPrinter.startElement( "target" );
- buildXmlPrinter.addAttribute( "name", "copy-resources" );
+ buildXmlPrinter.addAttribute( NAME, "copy-resources" );
buildXmlPrinter.addAttribute( "depends", "init" );
for ( Iterator it = specialSources.iterator(); it.hasNext(); )
@@ -295,8 +337,8 @@
}
catch ( IOException e )
{
- throw new MojoExecutionException( "Cannot create " + config.getEclipseProjectDirectory() +
- "/maven-eclipse.xml", e );
+ throw new MojoExecutionException( "Cannot create " + config.getEclipseProjectDirectory()
+ + "/maven-eclipse.xml", e );
}
log.info( "Creating external launcher file" );
@@ -310,9 +352,9 @@
new BuildCommand(
"org.eclipse.ui.externaltools.ExternalToolBuilder",
"LaunchConfigHandle",
- "<project>/" +
- EclipseLaunchConfigurationWriter.FILE_DOT_EXTERNAL_TOOL_BUILDERS +
- "Maven_Ant_Builder.launch" ) );
+ "<project>/"
+ + EclipseLaunchConfigurationWriter.FILE_DOT_EXTERNAL_TOOL_BUILDERS
+ + "Maven_Ant_Builder.launch" ) );
}
*/
@@ -325,33 +367,39 @@
writer.addAttribute( ATTR_PATH, defaultOutput );
writer.endElement();
+ Set addedDependencies = new HashSet();
+ // TODO if (..magic property equals orderDependencies..)
+
// ----------------------------------------------------------------------
- // Container classpath entries
+ // Java API dependencies that may complete the classpath container so must
+ // be declared BEFORE so that container access rules don't fail
// ----------------------------------------------------------------------
-
- for ( Iterator it = config.getClasspathContainers().iterator(); it.hasNext(); )
+ IdeDependency[] depsToWrite = config.getDepsOrdered();
+ for ( int j = 0; j < depsToWrite.length; j++ )
{
- writer.startElement( ELT_CLASSPATHENTRY );
- writer.addAttribute( ATTR_KIND, "con" ); //$NON-NLS-1$
- writer.addAttribute( ATTR_PATH, (String) it.next() );
- writer.endElement(); // name
+ IdeDependency dep = depsToWrite[j];
+ if ( dep.isJavaApi() )
+ {
+ String depId = getDependencyId( dep );
+ if ( !addedDependencies.contains( depId ) )
+ {
+ addDependency( writer, dep );
+ addedDependencies.add( depId );
+ }
+ }
}
// ----------------------------------------------------------------------
// The dependencies
// ----------------------------------------------------------------------
- Set addedDependencies = new HashSet();
- // TODO if (..magic property equals orderDependencies..)
- IdeDependency[] depsToWrite = config.getDepsOrdered();
for ( int j = 0; j < depsToWrite.length; j++ )
{
IdeDependency dep = depsToWrite[j];
if ( dep.isAddedToClasspath() )
{
- String depId =
- dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getClassifier() + ":" + dep.getVersion();
- /* avoid duplicates in the classpath for artifacts with different types (like ejbs) */
+ String depId = getDependencyId( dep );
+ /* avoid duplicates in the classpath for artifacts with different types (like ejbs or test-jars) */
if ( !addedDependencies.contains( depId ) )
{
addDependency( writer, dep );
@@ -360,12 +408,37 @@
}
}
+ // ----------------------------------------------------------------------
+ // Container classpath entries
+ // ----------------------------------------------------------------------
+
+ for ( Iterator it = config.getClasspathContainers().iterator(); it.hasNext(); )
+ {
+ writer.startElement( ELT_CLASSPATHENTRY );
+ writer.addAttribute( ATTR_KIND, "con" ); //$NON-NLS-1$
+ writer.addAttribute( ATTR_PATH, (String) it.next() );
+ writer.endElement(); // name
+ }
+
writer.endElement();
IOUtil.close( w );
}
+ private String getDependencyId( IdeDependency dep )
+ {
+ String depId =
+ dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getClassifier() + ":" + dep.getVersion();
+
+ if ( dep.isReferencedProject() )
+ {
+ // This dependency will be refered as an eclipse project
+ depId = dep.getEclipseProjectName();
+ }
+ return depId;
+ }
+
protected void addDependency( XMLWriter writer, IdeDependency dep )
throws MojoExecutionException
{
@@ -452,11 +525,10 @@
if ( ATTR_VAR.equals( kind ) )
{
sourcepath =
- M2_REPO +
- "/" //$NON-NLS-1$
- +
- IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, dep.getSourceAttachment(),
- false );
+ M2_REPO
+ + "/" //$NON-NLS-1$
+ + IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, dep.getSourceAttachment(),
+ false );
}
else
{
@@ -477,6 +549,12 @@
}
+ // Skip aspectj libraries since they are in the container.
+ if ( ( config.getAjdtVersion() != 0 ) && dep.getArtifactId().toLowerCase().startsWith( "aspectj" ) )
+ {
+ return;
+ }
+
writer.startElement( ELT_CLASSPATHENTRY );
writer.addAttribute( ATTR_KIND, kind );
writer.addAttribute( ATTR_PATH, path );
@@ -492,30 +570,60 @@
{
if ( !attributeElemOpen )
{
- writer.startElement( "attributes" ); //$NON-NLS-1$
+ writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
+ attributeElemOpen = true;
+ }
+
+ writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
+ writer.addAttribute( VALUE, "jar:" + new File( javadocpath ).toURI() + "!/" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ writer.addAttribute( NAME, "javadoc_location" ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.endElement();
+
+ }
+
+ if ( Constants.PROJECT_PACKAGING_WAR.equals( this.config.getPackaging() ) && config.getWtpapplicationxml()
+ && kind.equals( ATTR_VAR ) && !dep.isTestDependency() && !dep.isProvided()
+ && !dep.isSystemScopedOutsideProject( this.config.getProject() ) )
+ {
+ if ( !attributeElemOpen )
+ {
+ writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
+ attributeElemOpen = true;
+ }
+
+ writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
+ writer.addAttribute( VALUE, "/WEB-INF/lib" ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.addAttribute( NAME, "org.eclipse.jst.component.dependency" ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.endElement();
+
+ }
+
+ if ( dep.isAjdtDependency() && ( config.getAjdtVersion() >= 1.5 ) )
+ {
+ if ( !attributeElemOpen )
+ {
+ writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
attributeElemOpen = true;
}
- writer.startElement( "attribute" ); //$NON-NLS-1$
- writer.addAttribute( "value", "jar:" + new File( javadocpath ).toURI() + "!/" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- writer.addAttribute( "name", "javadoc_location" ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
+ writer.addAttribute( NAME, ORG_ECLIPSE_AJDT_ASPECTPATH ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.addAttribute( VALUE, Boolean.TRUE.toString() ); //$NON-NLS-1$ //$NON-NLS-2$
writer.endElement();
}
- if ( Constants.PROJECT_PACKAGING_WAR.equals( this.config.getPackaging() ) && config.getWtpapplicationxml() &&
- kind.equals( ATTR_VAR ) && !dep.isTestDependency() && !dep.isProvided() &&
- !dep.isSystemScopedOutsideProject( this.config.getProject() ) )
+ if ( dep.isAjdtWeaveDependency() && ( config.getAjdtVersion() >= 1.5 ) )
{
if ( !attributeElemOpen )
{
- writer.startElement( "attributes" ); //$NON-NLS-1$
+ writer.startElement( ATTRIBUTES ); //$NON-NLS-1$
attributeElemOpen = true;
}
- writer.startElement( "attribute" ); //$NON-NLS-1$
- writer.addAttribute( "value", "/WEB-INF/lib" ); //$NON-NLS-1$ //$NON-NLS-2$
- writer.addAttribute( "name", "org.eclipse.jst.component.dependency" ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.startElement( ATTRIBUTE ); //$NON-NLS-1$
+ writer.addAttribute( NAME, ORG_ECLIPSE_AJDT_INPATH ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.addAttribute( VALUE, Boolean.TRUE.toString() ); //$NON-NLS-1$ //$NON-NLS-2$
writer.endElement();
}
Modified: tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseCleanMojo.java
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseCleanMojo.java?rev=761364&r1=761363&r2=761364&view=diff
==============================================================================
--- tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseCleanMojo.java (original)
+++ tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/plugin/eclipse/EclipseCleanMojo.java Thu Apr 2 18:16:21 2009
@@ -19,17 +19,16 @@
package org.apache.tuscany.maven.plugin.eclipse;
import java.io.File;
-import java.io.IOException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.eclipse.Constants;
import org.apache.maven.plugin.eclipse.EclipseConfigFile;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.maven.plugin.ide.IdeUtils;
/**
* Deletes the .project, .classpath, .wtpmodules files and .settings folder used by Eclipse.
- *
+ *
* @goal clean
*/
public class EclipseCleanMojo
@@ -77,29 +76,34 @@
private static final String FILE_ECLIPSE_JDT_CORE_PREFS = ".settings/org.eclipse.jdt.core.prefs"; //$NON-NLS-1$
/**
+ * AJDT preferences.
+ */
+ private static final String FILE_AJDT_PREFS = ".settings/org.eclipse.ajdt.ui.prefs"; //$NON-NLS-1$
+
+ /**
* Packaging for the current project.
- *
+ *
* @parameter expression="${project.packaging}"
*/
private String packaging;
/**
* The root directory of the project
- *
+ *
* @parameter expression="${basedir}"
*/
private File basedir;
/**
* Skip the operation when true.
- *
+ *
* @parameter expression="${eclipse.skip}" default-value="false"
*/
private boolean skip;
/**
* additional generic configuration files for eclipse
- *
+ *
* @parameter
*/
private EclipseConfigFile[] additionalConfig;
@@ -128,6 +132,7 @@
delete( new File( basedir, FILE_DOT_COMPONENT_15 ) );
delete( new File( basedir, FILE_FACET_CORE_XML ) );
delete( new File( basedir, FILE_ECLIPSE_JDT_CORE_PREFS ) );
+ delete( new File( basedir, FILE_AJDT_PREFS ) );
File settingsDir = new File( basedir, DIR_DOT_SETTINGS );
if ( settingsDir.exists() && settingsDir.isDirectory() && settingsDir.list().length == 0 )
@@ -154,47 +159,19 @@
/**
* Delete a file, handling log messages and exceptions
- *
+ *
* @param f File to be deleted
* @throws MojoExecutionException only if a file exists and can't be deleted
*/
protected void delete( File f )
throws MojoExecutionException
{
- if ( f.isDirectory() )
- {
- getLog().info( Messages.getString( "EclipseCleanMojo.deletingDirectory", f.getName() ) ); //$NON-NLS-1$
- }
- else
- {
- getLog().info( Messages.getString( "EclipseCleanMojo.deletingFile", f.getName() ) ); //$NON-NLS-1$
- }
-
- if ( f.exists() )
- {
- if ( !f.delete() )
- {
- try
- {
- FileUtils.forceDelete( f );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( Messages.getString( "EclipseCleanMojo.failedtodelete", //$NON-NLS-1$
- new Object[] { f.getName(),
- f.getAbsolutePath() } ) );
- }
- }
- }
- else
- {
- getLog().debug( Messages.getString( "EclipseCleanMojo.nofilefound", f.getName() ) ); //$NON-NLS-1$
- }
+ IdeUtils.delete( f, getLog() );
}
/**
* Getter for <code>basedir</code>.
- *
+ *
* @return Returns the basedir.
*/
public File getBasedir()
@@ -204,7 +181,7 @@
/**
* Setter for <code>basedir</code>.
- *
+ *
* @param basedir The basedir to set.
*/
public void setBasedir( File basedir )