Author: hboutemy
Date: Sat Oct 1 20:26:36 2016
New Revision: 1763031
URL: http://svn.apache.org/viewvc?rev=1763031&view=rev
Log:
[MPIR-349] fixed module links when data comes from settings.xml: use project
from reactor instead of (wrongly) building it
Submitted by: Alix Lourme
applied with little formatting fixes
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
(with props)
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
(with props)
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/settings.xml
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
Modified: maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml?rev=1763031&r1=1763030&r2=1763031&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml Sat Oct 1
20:26:36 2016
@@ -86,6 +86,9 @@ under the License.
<name>Simon Wang</name>
<email>[email protected]</email>
</contributor>
+ <contributor>
+ <name>Alix Lourme</name>
+ </contributor>
</contributors>
<prerequisites>
@@ -557,6 +560,7 @@ under the License.
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
+ <pomInclude>*/parent/pom.xml</pomInclude>
</pomIncludes>
<pomExcludes>
<pomExclude>pom.xml</pomExclude>
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+-->
+
+<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>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.project-info-reports.its</groupId>
+ <artifactId>mpir-349</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+ <artifactId>mpir-349-module-hierarchical</artifactId>
+ <packaging>jar</packaging>
+ <name>Test Module Hierarchical</name>
+</project>
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,23 @@
+# 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.
+
+invoker.goals.1 =
${project.groupId}:${project.artifactId}:${project.version}:index
+invoker.goals.2 =
${project.groupId}:${project.artifactId}:${project.version}:modules
+invoker.maven.version = 3.0+
+
+# Specific profile defined in settings.xml, for variables interpolation in
module URL check (in 'index' and 'modules' reports)
+invoker.profiles=site-location
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+-->
+
+<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>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.project-info-reports.its</groupId>
+ <artifactId>mpir-349</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>mpir-349-module-flat</artifactId>
+ <packaging>jar</packaging>
+ <name>Test Module Flat</name>
+</project>
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+-->
+
+<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.project-info-reports.its</groupId>
+ <artifactId>mpir-349</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>plugins report: check that index report has variables from settings
interpolated</name>
+ <description>see MPIR-349 and DOXIASITETOOLS-166.</description>
+
+ <distributionManagement>
+ <site>
+ <id>projectSite</id>
+ <url>${sitePublishLocation}/foo/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>@pom.version@</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>index</report>
+ <report>modules</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <modules>
+ <module>../module-flat</module>
+ <module>module-hierarchical</module>
+ </modules>
+</project>
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+File indexPage = new File( basedir, 'target/site/index.html' )
+assert !indexPage.text.contains( 'sitePublishLocation' )
+
+File modulesPage = new File( basedir, 'target/site/modules.html' )
+assert !modulesPage.text.contains( 'sitePublishLocation' )
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/it/settings.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/settings.xml?rev=1763031&r1=1763030&r2=1763031&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/settings.xml
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/settings.xml
Sat Oct 1 20:26:36 2016
@@ -52,6 +52,13 @@ under the License.
</pluginRepository>
</pluginRepositories>
</profile>
+ <profile>
+ <!-- Used for MPIR-349 ITS (variables from settings interpolation) -->
+ <id>site-location</id>
+ <properties>
+ <sitePublishLocation>file://tmp/sitePublish</sitePublishLocation>
+ </properties>
+ </profile>
</profiles>
<mirrors>
<mirror>
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java?rev=1763031&r1=1763030&r2=1763031&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
Sat Oct 1 20:26:36 2016
@@ -153,6 +153,14 @@ public abstract class AbstractProjectInf
protected List<ArtifactRepository> remoteRepositories;
/**
+ * The reactor projects.
+ *
+ * @since 2.10
+ */
+ @Parameter( defaultValue = "${reactorProjects}", required = true, readonly
= true )
+ protected List<MavenProject> reactorProjects;
+
+ /**
* The current user system settings for use in Maven.
*
* @since 2.3
@@ -178,8 +186,8 @@ public abstract class AbstractProjectInf
private boolean skip;
/**
- * Skip the project info report generation if a report-specific section of
the POM is empty.
- * Defaults to <code>true</code>.
+ * Skip the project info report generation if a report-specific section of
the POM is empty. Defaults to
+ * <code>true</code>.
*
* @since 2.8
*/
@@ -222,10 +230,8 @@ public abstract class AbstractProjectInf
Artifact defaultSkin =
siteTool.getDefaultSkinArtifact( localRepository,
project.getRemoteArtifactRepositories() );
- // CHECKSTYLE_OFF: LineLength
- SiteRenderingContext siteContext =
- siteRenderer.createContextForSkin( defaultSkin.getFile(),
attributes, model, getName( locale ), locale );
- // CHECKSTYLE_ON: LineLength
+ SiteRenderingContext siteContext =
siteRenderer.createContextForSkin( defaultSkin.getFile(), attributes,
+
model, getName( locale ), locale );
RenderingContext context = new RenderingContext( outputDirectory,
filename );
@@ -315,6 +321,16 @@ public abstract class AbstractProjectInf
}
/**
+ * Reactor projects
+ *
+ * @return List of projects
+ */
+ protected List<MavenProject> getReactorProjects()
+ {
+ return reactorProjects;
+ }
+
+ /**
* @param pluginId The id of the plugin
* @return The information about the plugin.
*/
@@ -454,7 +470,7 @@ public abstract class AbstractProjectInf
}
catch ( MalformedURLException e )
{
- //could not happen.
+ // could not happen.
}
this.bundle = ResourceBundle.getBundle( this.bundleName, locale,
classLoader );
@@ -561,7 +577,7 @@ public abstract class AbstractProjectInf
}
catch ( final IOException e )
{
- //In which cases could this happen? And what should we do?
+ // In which cases could this happen? And what should we do?
}
interpolator.addValueSource( new PropertiesBasedValueSource(
System.getProperties() ) );
@@ -576,7 +592,7 @@ public abstract class AbstractProjectInf
}
catch ( final InterpolationException e )
{
- //What does this exception mean?
+ // What does this exception mean?
}
return value;
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java?rev=1763031&r1=1763030&r2=1763031&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
Sat Oct 1 20:26:36 2016
@@ -22,11 +22,13 @@ package org.apache.maven.report.projecti
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.tools.SiteTool;
+import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.codehaus.plexus.i18n.I18N;
+import java.util.List;
import java.util.Locale;
/**
@@ -70,10 +72,9 @@ public class IndexReport
@Override
public void executeReport( Locale locale )
{
- ProjectIndexRenderer r =
- new ProjectIndexRenderer( project, mavenProjectBuilder,
localRepository,
- getName( locale ), getDescription(
locale ), getSink(),
- getI18N( locale ), locale, siteTool );
+ ProjectIndexRenderer r = new ProjectIndexRenderer( project,
getReactorProjects(), mavenProjectBuilder,
+ localRepository,
getName( locale ), getDescription( locale ),
+ getSink(), getI18N(
locale ), locale, getLog(), siteTool );
r.render();
}
@@ -106,11 +107,11 @@ public class IndexReport
private boolean modules = false;
- ProjectIndexRenderer( MavenProject project, MavenProjectBuilder
mavenProjectBuilder,
- ArtifactRepository localRepository, String
title, String description,
- Sink sink, I18N i18n, Locale locale, SiteTool
siteTool )
+ ProjectIndexRenderer( MavenProject project, List<MavenProject>
reactorProjects,
+ MavenProjectBuilder mavenProjectBuilder,
ArtifactRepository localRepository, String title,
+ String description, Sink sink, I18N i18n, Locale
locale, Log log, SiteTool siteTool )
{
- super( sink, project, mavenProjectBuilder, localRepository, i18n,
locale, siteTool );
+ super( sink, project, reactorProjects, mavenProjectBuilder,
localRepository, i18n, locale, log, siteTool );
this.title = title;
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java?rev=1763031&r1=1763030&r2=1763031&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
Sat Oct 1 20:26:36 2016
@@ -20,6 +20,7 @@ package org.apache.maven.report.projecti
*/
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Locale;
@@ -28,8 +29,8 @@ import org.apache.maven.artifact.reposit
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.tools.SiteTool;
import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Model;
import org.apache.maven.model.Site;
+import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
@@ -57,7 +58,7 @@ public class ModulesReport
boolean result = super.canGenerateReport();
if ( result && skipEmptyReport )
{
- result = !isEmpty( getProject().getModel().getModules() ) ;
+ result = !isEmpty( getProject().getModel().getModules() );
}
return result;
@@ -66,8 +67,8 @@ public class ModulesReport
@Override
public void executeReport( Locale locale )
{
- new ModulesRenderer( getSink(), getProject(), mavenProjectBuilder,
localRepository,
- getI18N( locale ), locale, siteTool ).render();
+ new ModulesRenderer( getSink(), getProject(), getReactorProjects(),
mavenProjectBuilder, localRepository,
+ getI18N( locale ), locale, getLog(), siteTool
).render();
}
/** {@inheritDoc} */
@@ -92,24 +93,31 @@ public class ModulesReport
static class ModulesRenderer
extends AbstractProjectInfoRenderer
{
+
+ protected final Log log;
+
protected MavenProject project;
+ protected List<MavenProject> reactorProjects;
+
protected MavenProjectBuilder mavenProjectBuilder;
protected ArtifactRepository localRepository;
protected SiteTool siteTool;
- ModulesRenderer( Sink sink, MavenProject project, MavenProjectBuilder
mavenProjectBuilder,
- ArtifactRepository localRepository, I18N i18n, Locale
locale,
- SiteTool siteTool )
+ ModulesRenderer( Sink sink, MavenProject project, List<MavenProject>
reactorProjects,
+ MavenProjectBuilder mavenProjectBuilder,
ArtifactRepository localRepository, I18N i18n,
+ Locale locale, Log log, SiteTool siteTool )
{
super( sink, i18n, locale );
this.project = project;
+ this.reactorProjects = reactorProjects;
this.mavenProjectBuilder = mavenProjectBuilder;
this.localRepository = localRepository;
this.siteTool = siteTool;
+ this.log = log;
}
@Override
@@ -124,15 +132,15 @@ public class ModulesReport
List<String> modules = project.getModel().getModules();
if ( modules == null || modules.isEmpty() )
- {
- startSection( getTitle() );
+ {
+ startSection( getTitle() );
- paragraph( getI18nString( "nolist" ) );
+ paragraph( getI18nString( "nolist" ) );
- endSection();
+ endSection();
- return;
- }
+ return;
+ }
startSection( getTitle() );
@@ -148,32 +156,39 @@ public class ModulesReport
for ( String module : modules )
{
- Model moduleModel;
- File f = new File( project.getBasedir(), module + "/pom.xml" );
- if ( f.exists() )
+ MavenProject moduleProject = getModuleFromReactor( project,
reactorProjects, module );
+
+ if ( moduleProject == null )
{
- try
+ log.warn( "Module " + module + " not found in reactor:
loading locally" );
+
+ File f = new File( project.getBasedir(), module +
"/pom.xml" );
+ if ( f.exists() )
{
- moduleModel = mavenProjectBuilder.build( f,
localRepository, null ).getModel();
+ try
+ {
+ moduleProject = mavenProjectBuilder.build( f,
localRepository, null );
+ }
+ catch ( ProjectBuildingException e )
+ {
+ throw new IllegalStateException( "Unable to read
local module POM", e );
+ }
}
- catch ( ProjectBuildingException e )
+ else
{
- throw new IllegalStateException( "Unable to read local
module POM", e );
+ moduleProject = new MavenProject();
+ moduleProject.setName( module );
+ moduleProject.setDistributionManagement( new
DistributionManagement() );
+ moduleProject.getDistributionManagement().setSite( new
Site() );
+
moduleProject.getDistributionManagement().getSite().setUrl( module );
}
}
- else
- {
- moduleModel = new Model();
- moduleModel.setName( module );
- setDistMgmntSiteUrl( moduleModel, module );
- }
-
final String moduleName =
- ( moduleModel.getName() == null ) ?
moduleModel.getArtifactId() : moduleModel.getName();
- final String moduleHref = getRelativeLink( baseUrl,
getDistMgmntSiteUrl( moduleModel ),
- moduleModel.getArtifactId() );
+ ( moduleProject.getName() == null ) ?
moduleProject.getArtifactId() : moduleProject.getName();
+ final String moduleHref =
+ getRelativeLink( baseUrl, getDistMgmntSiteUrl(
moduleProject ), moduleProject.getArtifactId() );
- tableRow( new String[] { linkedName( moduleName, moduleHref ),
moduleModel.getDescription() } );
+ tableRow( new String[] { linkedName( moduleName, moduleHref ),
moduleProject.getDescription() } );
}
endTable();
@@ -181,19 +196,32 @@ public class ModulesReport
endSection();
}
- private static void setDistMgmntSiteUrl( Model model, String url )
+ private MavenProject getModuleFromReactor( MavenProject project,
List<MavenProject> reactorProjects,
+ String module )
{
- if ( model.getDistributionManagement() == null )
+ // Mainly case of unit test
+ if ( reactorProjects == null )
{
- model.setDistributionManagement( new DistributionManagement()
);
+ return null;
}
+ try
+ {
+ File moduleBasedir = new File( project.getBasedir(), module
).getCanonicalFile();
- if ( model.getDistributionManagement().getSite() == null )
+ for ( MavenProject reactorProject : reactorProjects )
+ {
+ if ( moduleBasedir.equals( reactorProject.getBasedir() ) )
+ {
+ return reactorProject;
+ }
+ }
+ }
+ catch ( IOException e )
{
- model.getDistributionManagement().setSite( new Site() );
+ log.error( "Error while populating modules menu: " +
e.getMessage(), e );
}
-
- model.getDistributionManagement().getSite().setUrl( url );
+ // module not found in reactor
+ return null;
}
/**
@@ -207,17 +235,6 @@ public class ModulesReport
return getDistMgmntSiteUrl( project.getDistributionManagement() );
}
- /**
- * Return distributionManagement.site.url if defined, null otherwise.
- *
- * @param model not null
- * @return could be null
- */
- private static String getDistMgmntSiteUrl( Model model )
- {
- return getDistMgmntSiteUrl( model.getDistributionManagement() );
- }
-
private static String getDistMgmntSiteUrl( DistributionManagement
distMgmnt )
{
if ( distMgmnt != null && distMgmnt.getSite() != null &&
distMgmnt.getSite().getUrl() != null )
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java?rev=1763031&r1=1763030&r2=1763031&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
Sat Oct 1 20:26:36 2016
@@ -19,14 +19,22 @@ package org.apache.maven.report.projecti
* under the License.
*/
+import java.io.File;
+import java.lang.reflect.Field;
import java.net.URL;
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.report.projectinfo.stubs.SubProject1Stub;
+import org.codehaus.plexus.util.ReflectionUtils;
+
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.TextBlock;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
+import edu.emory.mathcs.backport.java.util.Collections;
+
/**
* @author ltheussl
* @version $Id$
@@ -62,8 +70,7 @@ public class ModulesReportTest
assertTrue( response.getContentLength() > 0 );
// Test the Page title
- String expectedTitle = prepareTitle( getString( "report.modules.name"
),
- getString( "report.modules.title" ) );
+ String expectedTitle = prepareTitle( getString( "report.modules.name"
), getString( "report.modules.title" ) );
assertEquals( expectedTitle, response.getTitle() );
// Test the texts
@@ -82,4 +89,41 @@ public class ModulesReportTest
assertEquals( "project2", cellTexts[2][0] );
assertEquals( "project2 description", cellTexts[2][1] );
}
+
+ /**
+ * Test report with variable from settings interpolation in modules URL
links (MPIR-349)
+ *
+ * @throws Exception if any
+ */
+ public void testReportModuleLinksVariableSettingsInterpolated()
+ throws Exception
+ {
+ String pluginXml =
"modules-variable-settings-interpolated-plugin-config.xml";
+ File pluginXmlFile = new File( getBasedir(),
"src/test/resources/plugin-configs/" + pluginXml );
+ AbstractProjectInfoReport mojo = createReportMojo( "modules",
pluginXmlFile );
+
+ class SubProjectStub
+ extends SubProject1Stub
+ {
+ @Override
+ public File getBasedir()
+ {
+ return new File(
"src/test/resources/plugin-configs/subproject-site-url" ).getAbsoluteFile();
+ }
+
+ @Override
+ protected String getPOM()
+ {
+ return "pom.xml";
+ }
+ }
+ Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses(
"reactorProjects", mojo.getClass() );
+ field.setAccessible( true );
+ field.set( mojo, Collections.singletonList( new SubProjectStub() ) );
+
+ generateReport( mojo, pluginXmlFile );
+
+ assertFalse( "Variable 'sitePublishLocation' should be interpolated",
+ FileUtils.readFileToString( getGeneratedReport(
"modules.html" ) ).contains( "sitePublishLocation" ) );
+ }
}
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,42 @@
+package org.apache.maven.report.projectinfo.stubs;
+
+/*
+ * 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.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Alix Lourme
+ */
+public class ModulesVariableSettingInterpolationStub
+ extends ProjectInfoProjectStub
+{
+ @Override
+ protected String getPOM()
+ {
+ return "modules-variable-settings-interpolated-plugin-config.xml";
+ }
+
+ @Override
+ public List<String> getModules()
+ {
+ return Arrays.<String>asList( "subproject-site-url" );
+ }
+}
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,50 @@
+package org.apache.maven.report.projectinfo.stubs;
+
+/*
+ * 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.
+ */
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.settings.Profile;
+import org.apache.maven.settings.Settings;
+
+/**
+ * @author Alix Lourme
+ */
+public class SettingsSitePublishVariableStub
+ extends Settings
+{
+ private static final long serialVersionUID = 7852264203210559193L;
+
+ @Override
+ public List<Profile> getProfiles()
+ {
+ Profile p = new Profile();
+ p.setId( "site-location" );
+ p.addProperty( "sitePublishLocation", "file://tmp/sitePublish" );
+ return Collections.singletonList( p );
+ }
+
+ @Override
+ public List<String> getActiveProfiles()
+ {
+ return Collections.singletonList( "site-location" );
+ }
+}
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,62 @@
+<!--
+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.
+-->
+
+<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.plugin.projectinfo.tests</groupId>
+ <artifactId>modules</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>modules project info</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>subproject-site-url</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <configuration>
+ <outputDirectory>target/test-harness/modules</outputDirectory>
+ <localRepository>${localRepository}</localRepository>
+ <project
implementation="org.apache.maven.report.projectinfo.stubs.ModulesVariableSettingInterpolationStub"/>
+ <settings
implementation="org.apache.maven.report.projectinfo.stubs.SettingsSitePublishVariableStub"/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <distributionManagement>
+ <site>
+ <id>projectSite</id>
+ <url>${sitePublishLocation}/foo/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+</project>
\ No newline at end of file
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml?rev=1763031&view=auto
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
(added)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
Sat Oct 1 20:26:36 2016
@@ -0,0 +1,41 @@
+<!--
+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.
+-->
+
+<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>
+ <parent>
+ <groupId>org.apache.maven.plugin.projectinfo.tests</groupId>
+ <artifactId>modules</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
<relativePath>../modules-variable-settings-interpolated-plugin-config.xml</relativePath>
+ </parent>
+ <groupId>org.apache.maven.plugin.projectinfo.tests</groupId>
+ <artifactId>project-site-url</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>project-site-url</name>
+
+ <!-- When Maven model read, inheritance doesn't exist => fake declaration -->
+ <distributionManagement>
+ <site>
+ <id>projectSite</id>
+ <url>${sitePublishLocation}/foo/parent/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+</project>
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain