Hi Jeff,
I deduce you are testing my current development version...? ;)
I don't see how this particular commit could have broken site generation
as it only concerns the DeployMojo. However, I see that it could break
site:stage-deploy, is this what you are seeing?
I don't exclude that I broke something somewhere else, but I need more
info to track it down, a stack trace or better a test project would help.
Cheers,
-Lukas
Jeff Jensen wrote:
Hi Lukas!
I have a question on this commit, as it causes our site gen to now fail.
With the following change:
+ if ( site == null )
+ {
+ throw new MojoExecutionException(
+ "Missing site information in the distribution management of the
project " + name );
+ }
the following use case configuration encounters the above exception:
- a project parent pom has a<distributionManagement><site> element
(modules of course inherit it)
- a corporate parent pom does not have a<distributionManagement><site>
element
We never run site gen for the corporate parent pom, so any
<distributionManagement><site> element added will make it work but is
unneeded/fake.
So wondering if this configuration use case was considered and the
correct answer is to add a "fake"<site> element to the corporate
parent or possibly this check for site definition needs tweaking (can
it consider the effective one?)?
On Fri, Mar 4, 2011 at 6:58 AM,<[email protected]> wrote:
Author: ltheussl
Date: Fri Mar 4 12:58:01 2011
New Revision: 1077924
URL: http://svn.apache.org/viewvc?rev=1077924&view=rev
Log:
refactor: re-use getSite() so we properly catch null values also in stage-deploy
Modified:
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
Modified:
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java?rev=1077924&r1=1077923&r2=1077924&view=diff
==============================================================================
---
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
(original)
+++
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
Fri Mar 4 12:58:01 2011
@@ -26,6 +26,8 @@ import java.util.Locale;
import org.apache.maven.artifact.manager.WagonConfigurationException;
import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Site;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
@@ -552,4 +554,43 @@ public abstract class AbstractDeployMojo
return parent;
}
+
+ /**
+ * Extract the distributionManagment site from the given MavenProject.
+ *
+ * @param project the MavenProject. Not null.
+ *
+ * @return the project site. Not null.
+ * Also site.getUrl() and site.getId() are guaranteed to be not null.
+ *
+ * @throws MojoExecutionException if any of the site info is missing.
+ */
+ protected static Site getSite( final MavenProject project )
+ throws MojoExecutionException
+ {
+ final String name = project.getName() + " ("
+ + project.getGroupId() + ":" + project.getArtifactId() + ":" +
project.getVersion() + ")";
+
+ final DistributionManagement distributionManagement =
project.getDistributionManagement();
+
+ if ( distributionManagement == null )
+ {
+ throw new MojoExecutionException( "Missing distribution management in
project " + name );
+ }
+
+ final Site site = distributionManagement.getSite();
+
+ if ( site == null )
+ {
+ throw new MojoExecutionException(
+ "Missing site information in the distribution management of the
project " + name );
+ }
+
+ if ( site.getUrl() == null || site.getId() == null )
+ {
+ throw new MojoExecutionException( "Missing site data: specify url and
id for project " + name );
+ }
+
+ return site;
+ }
}
Modified:
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java?rev=1077924&r1=1077923&r2=1077924&view=diff
==============================================================================
---
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
(original)
+++
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
Fri Mar 4 12:58:01 2011
@@ -19,10 +19,8 @@ package org.apache.maven.plugins.site;
* under the License.
*/
-import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Site;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
/**
* Deploys the generated site using<code>scp</code> or<code>file</code>
@@ -68,30 +66,4 @@ public class SiteDeployMojo
return site.getUrl();
}
-
- private static Site getSite( final MavenProject project )
- throws MojoExecutionException
- {
- final DistributionManagement distributionManagement =
project.getDistributionManagement();
-
- if ( distributionManagement == null )
- {
- throw new MojoExecutionException( "Missing distribution management
information in the project." );
- }
-
- final Site site = distributionManagement.getSite();
-
- if ( site == null )
- {
- throw new MojoExecutionException(
- "Missing site information in the distribution management element in
the project." );
- }
-
- if ( site.getUrl() == null || site.getId() == null )
- {
- throw new MojoExecutionException( "Missing site data for deploy:
specify url and id!" );
- }
-
- return site;
- }
}
Modified:
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java?rev=1077924&r1=1077923&r2=1077924&view=diff
==============================================================================
---
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
(original)
+++
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
Fri Mar 4 12:58:01 2011
@@ -93,6 +93,7 @@ public class SiteStageDeployMojo
* @return the site URL for staging
*/
private String getStagingSiteURL( String usersStagingSiteURL )
+ throws MojoExecutionException
{
String topLevelURL = null;
@@ -106,7 +107,7 @@ public class SiteStageDeployMojo
{
// The user didn't specify a URL, use the top level target dir
topLevelURL =
- getTopLevelParent( project
).getDistributionManagement().getSite().getUrl() + "/" +
DEFAULT_STAGING_DIRECTORY;
+ getSite( getTopLevelParent( project ) ).getUrl() + "/" +
DEFAULT_STAGING_DIRECTORY;
getLog().debug( "stagingSiteURL NOT specified, using the top level
project: " + topLevelURL );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]