-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSITE-842] $currentFileName and $alignedFileName are incorrect for M…
…aven Report plugins that use several Sink instances * Ensured that the actual filename of the Sink being rendered is exposed in RenderingContext for multi-page reports * Subpages (or subsinks) in subdirectories are now supported This closes #8
- Loading branch information
1 parent
fd563ae
commit 42617d0
Showing
9 changed files
with
420 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 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 = clean install | ||
invoker.debug.1 = false | ||
invoker.goals.2 = site | ||
invoker.maven.version = 3.0+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?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.site.its</groupId> | ||
<artifactId>MSITE-842</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>maven-plugin</packaging> | ||
|
||
<name>it-plugin-test Maven Mojo</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.reporting</groupId> | ||
<artifactId>maven-reporting-impl</artifactId> | ||
<version>3.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>@project.version@</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<configuration> | ||
<templateFile>${basedir}/src/site/show-properties.vm</templateFile> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
|
||
<reporting> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins.site.its</groupId> | ||
<artifactId>MSITE-842</artifactId> | ||
<version>${project.version}</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>2.9</version> | ||
<reportSets> | ||
<reportSet> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</reportSet> | ||
</reportSets> | ||
</plugin> | ||
</plugins> | ||
</reporting> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
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. | ||
--> | ||
|
||
alignedFileName = MSITE-842.html | ||
|
||
currentFileName = MSITE-842.html | ||
|
||
getRelativePath() = . | ||
|
||
content = Main Sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
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. | ||
--> | ||
|
||
alignedFileName = another-page.html | ||
|
||
currentFileName = another-page.html | ||
|
||
getRelativePath() = . | ||
|
||
content = Another Sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
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. | ||
--> | ||
|
||
alignedFileName = ../sub/sub.html | ||
|
||
currentFileName = sub/sub.html | ||
|
||
getRelativePath() = .. | ||
|
||
content = Subdirectory Sink |
100 changes: 100 additions & 0 deletions
100
src/it/projects/MSITE-842/src/main/java/org/apache/maven/plugins/it/MyReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package org.apache.maven.plugins.it; | ||
|
||
/* | ||
* 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 org.apache.maven.doxia.sink.Sink; | ||
import org.apache.maven.reporting.AbstractMavenReport; | ||
import org.apache.maven.reporting.MavenReportException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Goal which creates several pages in a report. | ||
* | ||
* @goal test | ||
* @phase site | ||
*/ | ||
public class MyReport | ||
extends AbstractMavenReport | ||
{ | ||
|
||
public String getOutputName() | ||
{ | ||
return "MSITE-842"; | ||
} | ||
|
||
public String getName( Locale locale ) | ||
{ | ||
return "MSITE-842"; | ||
} | ||
|
||
public String getDescription( Locale locale ) | ||
{ | ||
return "Test Report for MSITE-842"; | ||
} | ||
|
||
@Override | ||
protected void executeReport( Locale locale ) throws MavenReportException | ||
{ | ||
// Main Sink | ||
Sink mainSink = getSink(); | ||
if ( mainSink == null ) | ||
{ | ||
throw new MavenReportException("Could not get the main Sink"); | ||
} | ||
|
||
// Write to the main Sink | ||
mainSink.text( "Main Sink" ); | ||
|
||
// Create a new sink! | ||
Sink anotherSink; | ||
try | ||
{ | ||
anotherSink = getSinkFactory().createSink( outputDirectory, "another-page.html" ); | ||
} | ||
catch ( IOException e ) | ||
{ | ||
throw new MavenReportException( "Could not create sink for another-page.html in " + | ||
outputDirectory.getAbsolutePath(), e ); | ||
} | ||
|
||
// Write to the other Sink | ||
anotherSink.text( "Another Sink" ); | ||
|
||
// Create a new sink, in a subdirectory | ||
File subDirectory = new File( outputDirectory, "sub" ); | ||
Sink subDirectorySink; | ||
try | ||
{ | ||
subDirectorySink = getSinkFactory().createSink( subDirectory, "sub.html" ); | ||
} | ||
catch ( IOException e ) | ||
{ | ||
throw new MavenReportException( "Could not create sink for sub.html in " + | ||
subDirectory.getAbsolutePath(), e ); | ||
} | ||
|
||
// Write to the sink in the subdirectory | ||
subDirectorySink.text( "Subdirectory Sink" ); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
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. | ||
--> | ||
|
||
alignedFileName = $alignedFileName | ||
|
||
currentFileName = $currentFileName | ||
|
||
getRelativePath() = $docRenderingContext.getRelativePath() | ||
|
||
content = $bodyContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
/* | ||
* 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 resultFile; | ||
File expectedFile; | ||
|
||
// Check MSITE-842.html (must exist and be exactly like the model | ||
resultFile = new File(basedir, "target/site/MSITE-842.html"); | ||
expectedFile = new File(basedir, "src/it/MSITE-842.html"); | ||
|
||
assert resultFile.exists() && resultFile.isFile() | ||
assert resultFile.text.normalize().equals(expectedFile.text.normalize()) | ||
|
||
// Check another-page.html (must exist and be exactly like the model | ||
resultFile = new File(basedir, "target/site/another-page.html"); | ||
expectedFile = new File(basedir, "src/it/another-page.html"); | ||
|
||
assert resultFile.exists() && resultFile.isFile() | ||
assert resultFile.text.normalize().equals(expectedFile.text.normalize()) | ||
|
||
// Check sub/sub.html (must exist and be exactly like the model | ||
resultFile = new File(basedir, "target/site/sub/sub.html"); | ||
expectedFile = new File(basedir, "src/it/sub/sub.html"); | ||
|
||
assert resultFile.exists() && resultFile.isFile() | ||
assert resultFile.text.normalize().equals(expectedFile.text.normalize()) | ||
|
Oops, something went wrong.