Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions src/it/report-changes-generation-notEscapeText/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin-test</artifactId>
<version>99.0</version>
<name>Maven</name>
<packaging>jar</packaging>
<description>Test report.</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<issueManagement>
<system>jira</system>
<url>http://localhost/bla</url>
</issueManagement>
<properties>
<changesPluginVersion>@project.version@</changesPluginVersion>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>${changesPluginVersion}</version>
<configuration>
<escapeText>false</escapeText>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>${changesPluginVersion}</version>
<executions>
<execution>
<id>validate-changes</id>
<phase>pre-site</phase>
<goals>
<goal>changes-validate</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>@sitePluginVersion@</version>
</plugin>
</plugins>
</build>
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<issueLinkTemplatePerSystem>
<jira>http://myjira/browse/%ISSUE%</jira>
</issueLinkTemplatePerSystem>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>changes</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
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.
-->

<document xmlns="http://maven.apache.org/changes/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/changes/2.0.0 http://maven.apache.org/xsd/changes-2.0.0.xsd">
<body>
<release version="1.1" date="2005-03-01" description="Subsequent release">
<action type="update"><![CDATA[
<strong>HTML tags</strong> are not escaped, but passed as raw text.
]]></action>
</release>
</body>
</document>
27 changes: 27 additions & 0 deletions src/it/report-changes-generation-notEscapeText/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.
*/


def report = new File(basedir, 'target/site/changes.html')
assert report.exists()

def content = report.text

// HTML tags in action text are escaped, and not passed as raw text
assert content.contains('<strong>HTML tags</strong> are not escaped, but passed as raw text.')
3 changes: 3 additions & 0 deletions src/it/report-changes-generation/src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ under the License.
Updated dependencies.
</action>
<action type="update">No dev action</action>
<action type="update"><![CDATA[
<strong>HTML tags</strong> are escaped and not passed as raw text.
]]></action>
</release>

<release version="1.0" date="2005-01-01" description="First release">
Expand Down
3 changes: 3 additions & 0 deletions src/it/report-changes-generation/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ assert content.contains('Thanks to External Submitter,')
assert content.contains('<a class="externalLink" href="mailto:others@users.com">others</a>')
// no link to empty dev value
assert content.contains('<td>-</td></tr>')

// HTML tags in action text are escaped, and not passed as raw text
assert content.contains('&lt;strong&gt;HTML tags&lt;/strong&gt; are escaped and not passed as raw text.')
16 changes: 16 additions & 0 deletions src/main/java/org/apache/maven/plugins/changes/ChangesReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ public class ChangesReport extends AbstractChangesReport {
@Parameter(property = "changes.addActionDate", defaultValue = "false")
private boolean addActionDate;

/**
* Whether the change description should be escaped (default), or passed as is to the report renderer.
*
* <p>
* <i>Example</i>: If you are generating the changes report as HTML, and want HTML tags included in your changes XML
* (like <code>&lt;b&gt;Bold&lt;/b&gt;</code>) to be interpreted correctly in the generated output, you have to set this
* parameter to <code>false</code>. You can use a <code>&lt;![CDATA[...]]&gt;</code> block in your changes XML to
* enclose descriptions with HTML tags.
* </p>
*
* @since 3.0
*/
@Parameter(defaultValue = "true")
private boolean escapeText;

/**
* The directory for interpolated changes.xml.
*
Expand Down Expand Up @@ -243,6 +258,7 @@ public void executeReport(Locale locale) throws MavenReportException {
}

report.setLinkToFeed(feedGenerated);
report.setEscapeText(escapeText);

report.render();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class ChangesReportRenderer extends AbstractIssuesReportRenderer {

private boolean linkToFeed;

private boolean escapeText;

public ChangesReportRenderer(Sink sink, ResourceBundle bundleName, ChangesXML changesXML) {
super(sink, bundleName);
this.issueLinksPerSystem = new HashMap<>();
Expand Down Expand Up @@ -106,6 +108,10 @@ public void setLinkToFeed(boolean generateLinkTofeed) {
this.linkToFeed = generateLinkTofeed;
}

public void setEscapeText(boolean escapeText) {
this.escapeText = escapeText;
}

/**
* Checks whether links to the issues can be generated for the given system.
*
Expand Down Expand Up @@ -159,7 +165,11 @@ private void constructAction(Action action) {

String actionDescription = action.getAction();

text(actionDescription);
if (escapeText || StringUtils.isEmpty(actionDescription)) {
text(actionDescription);
} else {
sink.rawText(actionDescription);
}

// no null check needed classes from modello return a new ArrayList
if (StringUtils.isNotEmpty(action.getIssue())
Expand Down