From 99553a6d2053cd8448f807f218f81117baa3d3b5 Mon Sep 17 00:00:00 2001 From: Alix Lourme Date: Thu, 29 Sep 2016 23:40:05 +0200 Subject: [PATCH] [MPIR-349] Bad modules links in 'index/modules' reports when 'distributionManagement.site.url' comes from settings.xml --- maven-project-info-reports-plugin/pom.xml | 1 + .../src/it/MPIR-349/module-flat/pom.xml | 35 ++++++ .../src/it/MPIR-349/parent/invoker.properties | 23 ++++ .../parent/module-hierarchical/pom.xml | 34 ++++++ .../src/it/MPIR-349/parent/pom.xml | 73 +++++++++++ .../src/it/MPIR-349/parent/verify.groovy | 24 ++++ .../src/it/settings.xml | 7 ++ .../AbstractProjectInfoReport.java | 32 +++-- .../maven/report/projectinfo/IndexReport.java | 17 +-- .../report/projectinfo/ModulesReport.java | 115 ++++++++++-------- .../report/projectinfo/ModulesReportTest.java | 49 +++++++- ...dulesVariableSettingInterpolationStub.java | 42 +++++++ .../SettingsSitePublishVariableStub.java | 50 ++++++++ ...le-settings-interpolated-plugin-config.xml | 62 ++++++++++ .../subproject-site-url/pom.xml | 41 +++++++ 15 files changed, 539 insertions(+), 66 deletions(-) create mode 100644 maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml create mode 100644 maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties create mode 100644 maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml create mode 100644 maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml create mode 100644 maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy create mode 100644 maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java create mode 100644 maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java create mode 100644 maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml create mode 100644 maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml diff --git a/maven-project-info-reports-plugin/pom.xml b/maven-project-info-reports-plugin/pom.xml index be452e095b..67f8b8c0a5 100644 --- a/maven-project-info-reports-plugin/pom.xml +++ b/maven-project-info-reports-plugin/pom.xml @@ -557,6 +557,7 @@ under the License. ${project.build.directory}/it */pom.xml + */parent/pom.xml pom.xml diff --git a/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml b/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml new file mode 100644 index 0000000000..49d3d2c7f7 --- /dev/null +++ b/maven-project-info-reports-plugin/src/it/MPIR-349/module-flat/pom.xml @@ -0,0 +1,35 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.project-info-reports.its + mpir-349 + 1.0-SNAPSHOT + ../parent + + mpir-349-module-hierarchical + jar + Test Module Hierarchical + diff --git a/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties new file mode 100644 index 0000000000..679f593150 --- /dev/null +++ b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/invoker.properties @@ -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 diff --git a/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml new file mode 100644 index 0000000000..b3f51ea7a8 --- /dev/null +++ b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/module-hierarchical/pom.xml @@ -0,0 +1,34 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.project-info-reports.its + mpir-349 + 1.0-SNAPSHOT + + mpir-349-module-flat + jar + Test Module Flat + diff --git a/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml new file mode 100644 index 0000000000..ac6ad92006 --- /dev/null +++ b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/pom.xml @@ -0,0 +1,73 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.project-info-reports.its + mpir-349 + 1.0-SNAPSHOT + pom + + plugins report: check that index report has variables from settings interpolated + see MPIR-349 and DOXIASITETOOLS-166. + + + + projectSite + ${sitePublishLocation}/foo/${project.artifactId} + + + + + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + @pom.version@ + + + + index + modules + + + + + + + + + ../module-flat + module-hierarchical + + diff --git a/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy new file mode 100644 index 0000000000..7807929823 --- /dev/null +++ b/maven-project-info-reports-plugin/src/it/MPIR-349/parent/verify.groovy @@ -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' ) diff --git a/maven-project-info-reports-plugin/src/it/settings.xml b/maven-project-info-reports-plugin/src/it/settings.xml index 2ef786a66a..f217c8ebcc 100644 --- a/maven-project-info-reports-plugin/src/it/settings.xml +++ b/maven-project-info-reports-plugin/src/it/settings.xml @@ -52,6 +52,13 @@ under the License. + + + site-location + + file://tmp/sitePublish + + diff --git a/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java b/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java index dcf8437aa4..14288b29a6 100644 --- a/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java +++ b/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java @@ -152,6 +152,14 @@ public abstract class AbstractProjectInfoReport @Parameter( property = "project.remoteArtifactRepositories" ) protected List remoteRepositories; + /** + * The reactor projects. + * + * @since 2.10 + */ + @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) + protected List reactorProjects; + /** * The current user system settings for use in Maven. * @@ -178,8 +186,8 @@ public abstract class AbstractProjectInfoReport private boolean skip; /** - * Skip the project info report generation if a report-specific section of the POM is empty. - * Defaults to true. + * Skip the project info report generation if a report-specific section of the POM is empty. Defaults to + * true. * * @since 2.8 */ @@ -223,8 +231,8 @@ public void execute() siteTool.getDefaultSkinArtifact( localRepository, project.getRemoteArtifactRepositories() ); // CHECKSTYLE_OFF: LineLength - SiteRenderingContext siteContext = - siteRenderer.createContextForSkin( defaultSkin.getFile(), attributes, model, getName( locale ), locale ); + SiteRenderingContext siteContext = siteRenderer.createContextForSkin( defaultSkin.getFile(), attributes, + model, getName( locale ), locale ); // CHECKSTYLE_ON: LineLength RenderingContext context = new RenderingContext( outputDirectory, filename ); @@ -314,6 +322,16 @@ protected MavenProject getProject() return project; } + /** + * Reactor projects + * + * @return List of projects + */ + protected List getReactorProjects() + { + return reactorProjects; + } + /** * @param pluginId The id of the plugin * @return The information about the plugin. @@ -454,7 +472,7 @@ public CustomI18N( MavenProject project, Settings settings, File customBundleFil } catch ( MalformedURLException e ) { - //could not happen. + // could not happen. } this.bundle = ResourceBundle.getBundle( this.bundleName, locale, classLoader ); @@ -561,7 +579,7 @@ public String getString( String bundleName, Locale locale, String key ) } 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 +594,7 @@ public String getString( String bundleName, Locale locale, String key ) } catch ( final InterpolationException e ) { - //What does this exception mean? + // What does this exception mean? } return value; diff --git a/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java b/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java index 1e3f01816e..5c59c1d66d 100644 --- a/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java +++ b/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java @@ -22,11 +22,13 @@ 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 String getDescription( Locale locale ) @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 @@ private static class ProjectIndexRenderer 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 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; diff --git a/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java b/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java index d05ee411c1..ff0d37038d 100644 --- a/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java +++ b/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java @@ -20,6 +20,7 @@ */ 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.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 boolean canGenerateReport() boolean result = super.canGenerateReport(); if ( result && skipEmptyReport ) { - result = !isEmpty( getProject().getModel().getModules() ) ; + result = !isEmpty( getProject().getModel().getModules() ); } return result; @@ -66,8 +67,8 @@ public boolean canGenerateReport() @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 @@ protected String getI18Nsection() static class ModulesRenderer extends AbstractProjectInfoRenderer { + + protected final Log log; + protected MavenProject project; + protected List 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 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 void renderBody() List 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 void renderBody() 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 void renderBody() endSection(); } - private static void setDistMgmntSiteUrl( Model model, String url ) + private MavenProject getModuleFromReactor( MavenProject project, List 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 @@ private static String getDistMgmntSiteUrl( MavenProject project ) 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 ) diff --git a/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java b/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java index 31c3dc2377..c589f8af2b 100644 --- a/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java +++ b/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java @@ -1,5 +1,8 @@ package org.apache.maven.report.projectinfo; +import java.io.File; +import java.lang.reflect.Field; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,12 +24,18 @@ 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 +71,7 @@ public void testReport() 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 +90,41 @@ public void testReport() 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" ) ); + } } diff --git a/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java b/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java new file mode 100644 index 0000000000..06544f6b05 --- /dev/null +++ b/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/ModulesVariableSettingInterpolationStub.java @@ -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 getModules() + { + return Arrays.asList( "subproject-site-url" ); + } +} diff --git a/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java b/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java new file mode 100644 index 0000000000..786ce2be0e --- /dev/null +++ b/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/stubs/SettingsSitePublishVariableStub.java @@ -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 getProfiles() + { + Profile p = new Profile(); + p.setId( "site-location" ); + p.addProperty( "sitePublishLocation", "file://tmp/sitePublish" ); + return Collections.singletonList( p ); + } + + @Override + public List getActiveProfiles() + { + return Collections.singletonList( "site-location" ); + } +} diff --git a/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml b/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml new file mode 100644 index 0000000000..318521c915 --- /dev/null +++ b/maven-project-info-reports-plugin/src/test/resources/plugin-configs/modules-variable-settings-interpolated-plugin-config.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + org.apache.maven.plugin.projectinfo.tests + modules + 1.0-SNAPSHOT + pom + modules project info + + + + junit + junit + 3.8.2 + test + + + + + subproject-site-url + + + + + + maven-project-info-reports-plugin + + target/test-harness/modules + ${localRepository} + + + + + + + + + + projectSite + ${sitePublishLocation}/foo/${project.artifactId} + + + + \ No newline at end of file diff --git a/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml b/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml new file mode 100644 index 0000000000..9b91c9675a --- /dev/null +++ b/maven-project-info-reports-plugin/src/test/resources/plugin-configs/subproject-site-url/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + org.apache.maven.plugin.projectinfo.tests + modules + 1.0-SNAPSHOT + ../modules-variable-settings-interpolated-plugin-config.xml + + org.apache.maven.plugin.projectinfo.tests + project-site-url + 1.0-SNAPSHOT + jar + project-site-url + + + + + projectSite + ${sitePublishLocation}/foo/parent/${project.artifactId} + + +