Author: olamy Date: Fri Sep 3 21:25:57 2010 New Revision: 992480 URL: http://svn.apache.org/viewvc?rev=992480&view=rev Log: fix new configuration model
Added: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml (with props) maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java (with props) maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy (with props) Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/ReportPlugin.java Added: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml?rev=992480&view=auto ============================================================================== --- maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml (added) +++ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml Fri Sep 3 21:25:57 2010 @@ -0,0 +1,76 @@ +<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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.site.its</groupId> + <artifactId>it-plugin-test</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>maven-plugin</packaging> + + <name>it-plugin-test Maven Mojo</name> + <url>http://maven.apache.org</url> + + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>@pom.version@</version> + <configuration> + <reportPlugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>2.2</version> + <configuration> + <dependencyDetailsEnabled>false</dependencyDetailsEnabled> + <dependencyLocationsEnabled>false</dependencyLocationsEnabled> + </configuration> + <reports> + <report>scm</report> + <report>summary</report> + </reports> + <reportSets> + <reportSet> + <reports> + <report>index</report> + </reports> + </reportSet> + </reportSets> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.7</version> + </plugin> + </reportPlugins> + </configuration> + </plugin> + </plugins> + </build> + + <reporting> + <excludeDefaults>true</excludeDefaults> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>2.5.1</version> + </plugin> + </plugins> + </reporting> +</project> Propchange: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java?rev=992480&view=auto ============================================================================== --- maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java (added) +++ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java Fri Sep 3 21:25:57 2010 @@ -0,0 +1,81 @@ +package org.apache.maven.plugins.it; + +/* + * 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.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * Goal which touches a timestamp file. + * + * @goal touch + * + * @phase process-sources + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} Propchange: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/src/main/java/org/apache/maven/plugins/it/MyMojo.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy?rev=992480&view=auto ============================================================================== --- maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy (added) +++ maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy Fri Sep 3 21:25:57 2010 @@ -0,0 +1,38 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +assert !new File(basedir, 'target/surefire-reports').exists(); +assert !new File(basedir, 'target/surefire-reports/org.apache.maven.plugins.site.its.AppTest.txt').exists(); + +assert !new File(basedir, 'target/site/surefire-report.html').exists(); +assert new File(basedir, 'target/site/index.html').exists(); +assert !new File(basedir, 'target/site/checkstyle.html').exists(); +assert !new File(basedir, 'target/site/cpd.html').exists(); +assert new File(basedir, 'target/site/apidocs/index.html').exists(); +assert !new File(basedir, 'target/site/apidocs/org/apache/maven/plugins/site/its/App.html').exists(); +assert !new File(basedir, 'target/site/cobertura/index.html').exists(); +assert !new File(basedir, 'target/site/xref/index.html').exists(); +assert !new File(basedir, 'target/site/xref-test/index.html').exists(); + +assert !new File(basedir, 'target/site/taglist.html').exists(); +assert !new File(basedir, 'target/site/team-list.html').exists(); + +assert !new File(basedir, 'target/site/dependencies.html').exists(); + +return true; \ No newline at end of file Propchange: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/branches/maven-site-plugin-3.x/src/it/new-configuration/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java?rev=992480&r1=992479&r2=992480&view=diff ============================================================================== --- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java (original) +++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java Fri Sep 3 21:25:57 2010 @@ -155,13 +155,13 @@ public class DefaultMavenReportExecutor logger.info( "configuring report plugin " + plugin.getId() ); } - List<String> goals = new ArrayList<String>(); + Set<String> goals = new HashSet<String>(); List<RemoteRepository> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories(); PluginDescriptor pluginDescriptor = mavenPluginManager.getPluginDescriptor(plugin, remoteRepositories , session.getRepositorySession()); - if ( reportPlugin.getReportSets().isEmpty() ) + if ( reportPlugin.getReportSets().isEmpty() && reportPlugin.getReports().isEmpty() ) { List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos(); for ( MojoDescriptor mojoDescriptor : mojoDescriptors ) @@ -171,9 +171,16 @@ public class DefaultMavenReportExecutor } else { - for ( ReportSet reportSet : reportPlugin.getReportSets() ) + if (reportPlugin.getReportSets() != null) { - goals.addAll( reportSet.getReports() ); + for ( ReportSet reportSet : reportPlugin.getReportSets() ) + { + goals.addAll( reportSet.getReports() ); + } + } + if (!reportPlugin.getReports().isEmpty()) + { + goals.addAll( reportPlugin.getReports() ); } } Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/ReportPlugin.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/ReportPlugin.java?rev=992480&r1=992479&r2=992480&view=diff ============================================================================== --- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/ReportPlugin.java (original) +++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/ReportPlugin.java Fri Sep 3 21:25:57 2010 @@ -20,6 +20,7 @@ package org.apache.maven.plugins.site; */ import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.maven.model.Plugin; @@ -44,6 +45,8 @@ public class ReportPlugin private PlexusConfiguration configuration; private List<ReportSet> reportSets; + + private List<String> reports; public String getGroupId() { @@ -100,4 +103,14 @@ public class ReportPlugin this.reportSets = reportSets; } + public List<String> getReports() + { + return reports == null ? Collections.<String>emptyList() : reports; + } + + public void setReports( List<String> reports ) + { + this.reports = reports; + } + }