Author: vsiveton
Date: Sun Feb 3 07:19:28 2008
New Revision: 617996
URL: http://svn.apache.org/viewvc?rev=617996&view=rev
Log:
MJAVADOC-116: Impossible to aggregate javadoc if snapshot never built
o bumped to maven artifacts to 2.0.8 to have MultipleArtifactsNotFoundException
from maven-artifact:2.0.8
o added 2.0.8 as prerequisites
o add checkMissingArtifactsInReactor() to check if missing artifacts are in
reactor
Modified:
maven/plugins/trunk/maven-javadoc-plugin/pom.xml
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=617996&r1=617995&r2=617996&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Sun Feb 3 07:19:28 2008
@@ -52,7 +52,7 @@
</scm>
<prerequisites>
- <maven>2.0.6</maven>
+ <maven>2.0.8</maven>
</prerequisites>
<build>
@@ -96,47 +96,59 @@
</build>
<dependencies>
+ <!-- maven -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
- <version>2.0.2</version>
- <exclusions>
- <!-- Using org.codehaus.plexus:plexus-utils instead of -->
- <exclusion>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
+ <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</groupId>
<artifactId>maven-settings</artifactId>
- <version>2.0.2</version>
- <exclusions>
- <!-- Using org.codehaus.plexus:plexus-utils instead of -->
- <exclusion>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
+ <version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0.2</version>
- <exclusions>
- <!-- Using org.codehaus.plexus:plexus-utils instead of -->
- <exclusion>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
+ <version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
- <artifactId>maven-reporting-impl</artifactId>
- <version>2.0.2</version>
+ <artifactId>maven-reporting-api</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+
+ <!-- Doxia -->
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-sink-api</artifactId>
+ <version>${doxiaVersion}</version>
+ </dependency>
+
+ <!-- Doxia-sitetools -->
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-site-renderer</artifactId>
+ <version>${doxia-sitetoolsVersion}</version>
<exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
<!-- Using org.codehaus.plexus:plexus-utils instead of -->
<exclusion>
<groupId>plexus</groupId>
@@ -144,29 +156,65 @@
</exclusion>
</exclusions>
</dependency>
+
+ <!-- wagon -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.4.6</version>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ <version>${wagonVersion}</version>
</dependency>
+
+ <!-- misc -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
+
+ <!-- Plexus -->
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>1.0-alpha-7</version>
+ <exclusions>
+ <!-- Using org.codehaus.plexus:plexus-utils instead of -->
+ <exclusion>
+ <groupId>plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.4.6</version>
</dependency>
<dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <properties>
+ <!-- TODO need to bump it -->
+ <doxiaVersion>1.0-alpha-7</doxiaVersion>
+ <doxia-sitetoolsVersion>1.0-alpha-7</doxia-sitetoolsVersion>
+ <wagonVersion>1.0-beta-2</wagonVersion>
+ </properties>
<profiles>
<profile>
Modified:
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=617996&r1=617995&r2=617996&view=diff
==============================================================================
---
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
(original)
+++
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
Sun Feb 3 07:19:28 2008
@@ -28,8 +28,10 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
+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.Locale;
@@ -45,11 +47,11 @@
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.plugin.AbstractMojo;
@@ -1835,9 +1837,39 @@
Set dependencyArtifacts = subProject.createArtifacts(
factory, null, null );
if ( !dependencyArtifacts.isEmpty() )
{
- ArtifactResolutionResult result = resolver
- .resolveTransitively( dependencyArtifacts,
subProject.getArtifact(), subProject
- .getRemoteArtifactRepositories(),
localRepository, artifactMetadataSource );
+ ArtifactResolutionResult result = null;
+ try
+ {
+ result = resolver.resolveTransitively(
dependencyArtifacts, subProject.getArtifact(),
+
subProject.getRemoteArtifactRepositories(),
+
localRepository, artifactMetadataSource );
+ }
+ catch ( MultipleArtifactsNotFoundException e )
+ {
+ if ( checkMissingArtifactsInReactor(
dependencyArtifacts, e.getMissingArtifacts() ) )
+ {
+ getLog().warn( "IGNORED to add some
artifacts in the classpath. See above." );
+ }
+ else
+ {
+ //we can't find all the artifacts in the
reactor so bubble the exception up.
+ throw new MavenReportException(
e.getMessage(), e );
+ }
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ throw new MavenReportException(
e.getMessage(), e );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new MavenReportException(
e.getMessage(), e );
+ }
+
+ if ( result == null )
+ {
+ continue;
+ }
+
populateCompileArtifactMap( compileArtifactMap,
JavadocUtil.getCompileArtifacts( result.getArtifacts() ) );
if ( getLog().isDebugEnabled() )
@@ -1862,10 +1894,6 @@
}
}
}
- catch ( AbstractArtifactResolutionException e )
- {
- throw new MavenReportException( e.getMessage(), e );
- }
catch ( InvalidDependencyVersionException e )
{
throw new MavenReportException( e.getMessage(), e );
@@ -3034,5 +3062,48 @@
{
throw new MavenReportException( "Option <noindex/> conflicts with
<splitindex/>" );
}
+ }
+
+ /**
+ * This method is checking to see if the artifacts that can't be resolved
are all
+ * part of this reactor. This is done to prevent a chicken or egg scenario
with
+ * fresh projects. See MJAVADOC-116 for more info.
+ *
+ * @param dependencyArtifacts the sibling projects in the reactor
+ * @param missing the artifacts that can't be found
+ * @return true if ALL missing artifacts are found in the reactor.
+ * @see DefaultPluginManager#checkRequiredMavenVersion( plugin,
localRepository, remoteRepositories )
+ */
+ private boolean checkMissingArtifactsInReactor( Collection
dependencyArtifacts, Collection missing )
+ {
+ Set foundInReactor = new HashSet();
+ Iterator iter = missing.iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact mArtifact = (Artifact) iter.next();
+ Iterator pIter = reactorProjects.iterator();
+ while ( pIter.hasNext() )
+ {
+ MavenProject p = (MavenProject) pIter.next();
+ if ( p.getArtifactId().equals( mArtifact.getArtifactId() )
+ && p.getGroupId().equals( mArtifact.getGroupId() )
+ && p.getVersion().equals( mArtifact.getVersion() ) )
+ {
+ getLog()
+ .warn(
+ "The dependency: [" + p.getId()
+ + "} can't be resolved but has been found
in the reactor (probably snapshots).\n"
+ + "This dependency has been excluded from
the Javadoc classpath. "
+ + "You should rerun javadoc after executing
mvn install." );
+
+ //found it, move on.
+ foundInReactor.add( p );
+ break;
+ }
+ }
+ }
+
+ //if all of them have been found, we can continue.
+ return foundInReactor.size() == missing.size();
}
}