This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch MSHARED-1343 in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git
commit 963f3e24701741f589600e560990e7d9afd0459e Author: Michael Osipov <micha...@apache.org> AuthorDate: Sun Dec 10 12:32:40 2023 +0100 [MSHARED-1343] Make parameter outputDirectory read/write in AbstractMavenReport --- src/it/use-as-direct-mojo-2/invoker.properties | 20 ++++++++++ src/it/use-as-direct-mojo-2/pom.xml | 46 ++++++++++++++++++++++ src/it/use-as-direct-mojo-2/verify.groovy | 40 +++++++++++++++++++ .../use-as-direct-mojo-markup-2/invoker.properties | 20 ++++++++++ src/it/use-as-direct-mojo-markup-2/pom.xml | 46 ++++++++++++++++++++++ src/it/use-as-direct-mojo-markup-2/verify.groovy | 34 ++++++++++++++++ .../maven/reporting/AbstractMavenReport.java | 2 +- 7 files changed, 207 insertions(+), 1 deletion(-) diff --git a/src/it/use-as-direct-mojo-2/invoker.properties b/src/it/use-as-direct-mojo-2/invoker.properties new file mode 100644 index 0000000..e6cbf2d --- /dev/null +++ b/src/it/use-as-direct-mojo-2/invoker.properties @@ -0,0 +1,20 @@ +# 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 = custom-reporting:custom +invoker.goals.2 = custom-reporting:custom-renderer +invoker.goals.3 = custom-reporting:external diff --git a/src/it/use-as-direct-mojo-2/pom.xml b/src/it/use-as-direct-mojo-2/pom.xml new file mode 100644 index 0000000..f5f7dc4 --- /dev/null +++ b/src/it/use-as-direct-mojo-2/pom.xml @@ -0,0 +1,46 @@ +<?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.reporting.its</groupId> + <artifactId>use-as-direct-mojo-2</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>Use report as direct mojo</name> + <description>Use report directly as mojo: "mvn my-plugin:my-report"</description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.reporting.its</groupId> + <artifactId>custom-reporting-plugin</artifactId> + <version>1.0-SNAPSHOT</version> + <configuration> + <outputDirectory>${project.build.directory}/custom-reports</outputDirectory> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/use-as-direct-mojo-2/verify.groovy b/src/it/use-as-direct-mojo-2/verify.groovy new file mode 100644 index 0000000..3109a0f --- /dev/null +++ b/src/it/use-as-direct-mojo-2/verify.groovy @@ -0,0 +1,40 @@ +/* + * 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 outputDir = new File( basedir, 'target/custom-reports/' ) + +File f = new File( outputDir, 'custom-report.html' ); +assert f.exists(); +assert f.text.contains( 'Custom Maven Report content.' ); + +f = new File( outputDir, 'custom-report-with-renderer.html' ); +assert f.exists(); +text = f.text.normalize(); +assert text.contains( 'Custom Maven Report with Renderer content.' ); +assert text.contains( '''\ +<div class="verbatim"> +<pre>Custom verbatim text.</pre></div>'''.normalize() ); +assert text.contains( '''\ +<div class="verbatim source"><pre class="prettyprint">var custom_code = true;</pre></div>'''.normalize() ); + +f = new File( outputDir, 'external/report.html' ); +assert f.exists(); +assert f.text.contains( '<h1>External Report</h1>' ); + +return true; diff --git a/src/it/use-as-direct-mojo-markup-2/invoker.properties b/src/it/use-as-direct-mojo-markup-2/invoker.properties new file mode 100644 index 0000000..a0197fd --- /dev/null +++ b/src/it/use-as-direct-mojo-markup-2/invoker.properties @@ -0,0 +1,20 @@ +# 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 = custom-reporting:custom -Doutput.format=xdoc +invoker.goals.2 = custom-reporting:custom-renderer -Doutput.format=apt +invoker.goals.3 = custom-reporting:external -Doutput.format=anything diff --git a/src/it/use-as-direct-mojo-markup-2/pom.xml b/src/it/use-as-direct-mojo-markup-2/pom.xml new file mode 100644 index 0000000..a9e08a2 --- /dev/null +++ b/src/it/use-as-direct-mojo-markup-2/pom.xml @@ -0,0 +1,46 @@ +<?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.reporting.its</groupId> + <artifactId>use-as-direct-mojo-markup-2</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>Use report as direct mojo to markup</name> + <description>Use report directly as mojo to markup: "mvn my-plugin:my-report"</description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.reporting.its</groupId> + <artifactId>custom-reporting-plugin</artifactId> + <version>1.0-SNAPSHOT</version> + <configuration> + <outputDirectory>${project.build.directory}/custom-reports</outputDirectory> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/use-as-direct-mojo-markup-2/verify.groovy b/src/it/use-as-direct-mojo-markup-2/verify.groovy new file mode 100644 index 0000000..09f1367 --- /dev/null +++ b/src/it/use-as-direct-mojo-markup-2/verify.groovy @@ -0,0 +1,34 @@ +/* + * 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 outputDir = new File( basedir, 'target/custom-reports/' ) + +File f = new File( outputDir, 'custom-report.xdoc' ); +assert f.exists(); +assert f.text.contains( 'Custom Maven Report content.' ); + +f = new File( outputDir, 'custom-report-with-renderer.apt' ); +assert f.exists(); +assert f.text.contains( 'Custom Maven Report with Renderer content.' ); + +f = new File( outputDir, 'external/report.html' ); +assert f.exists(); +assert f.text.contains( '<h1>External Report</h1>' ); + +return true; diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java index d48e3f1..ceeebac 100644 --- a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java +++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java @@ -84,7 +84,7 @@ public abstract class AbstractMavenReport extends AbstractMojo implements MavenM * user-defined mojo parameter with a default value) to generate multi-page reports or external reports with the * main output file (entry point) denoted by {@link #getOutputName()}. */ - @Parameter(defaultValue = "${project.build.directory}/reports", readonly = true, required = true) + @Parameter(defaultValue = "${project.build.directory}/reports", required = true) protected File outputDirectory; /**