This is an automated email from the ASF dual-hosted git repository. sjaranowski pushed a commit to branch MPIR-460 in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git
commit 5bcf5f598649ff728a0cc5d10dbd148b56a55880 Author: Slawomir Jaranowski <s.jaranow...@gmail.com> AuthorDate: Sun Jun 2 16:17:38 2024 +0200 [MPIR-460] Dependency Information for maven-plugin --- src/it/MPIR-460-jar/invoker.properties | 18 ++++++++++ src/it/MPIR-460-jar/pom.xml | 39 ++++++++++++++++++++ src/it/MPIR-460-jar/verify.groovy | 31 ++++++++++++++++ src/it/MPIR-460-maven-plugin/invoker.properties | 18 ++++++++++ src/it/MPIR-460-maven-plugin/pom.xml | 39 ++++++++++++++++++++ src/it/MPIR-460-maven-plugin/verify.groovy | 31 ++++++++++++++++ .../projectinfo/DependencyInformationReport.java | 41 +++++++++++++++++++--- 7 files changed, 213 insertions(+), 4 deletions(-) diff --git a/src/it/MPIR-460-jar/invoker.properties b/src/it/MPIR-460-jar/invoker.properties new file mode 100644 index 0000000..0e9501c --- /dev/null +++ b/src/it/MPIR-460-jar/invoker.properties @@ -0,0 +1,18 @@ +# 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 = ${project.groupId}:${project.artifactId}:${project.version}:dependency-info diff --git a/src/it/MPIR-460-jar/pom.xml b/src/it/MPIR-460-jar/pom.xml new file mode 100644 index 0000000..5ccb672 --- /dev/null +++ b/src/it/MPIR-460-jar/pom.xml @@ -0,0 +1,39 @@ +<?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</groupId> + <artifactId>MPIR-460-jar</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>MPIR-460 IT test: dependency-info for jar packaging</name> + <description> + Coordinate list are generated for many tools + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> +</project> diff --git a/src/it/MPIR-460-jar/verify.groovy b/src/it/MPIR-460-jar/verify.groovy new file mode 100644 index 0000000..c6fc32f --- /dev/null +++ b/src/it/MPIR-460-jar/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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/dependency-info.html' ).text + +assert !report.contains('<pre><plugin>') +assert !report.contains('</plugin></pre>') + +assert report.contains('<pre><dependency>') +assert report.contains('</dependency></pre>') + +assert report.contains('Apache Ivy') +assert report.contains('Groovy Grap') +assert report.contains('Gradle/Grail') +assert report.contains('Scala SBT') +assert report.contains('Leiningen') diff --git a/src/it/MPIR-460-maven-plugin/invoker.properties b/src/it/MPIR-460-maven-plugin/invoker.properties new file mode 100644 index 0000000..0e9501c --- /dev/null +++ b/src/it/MPIR-460-maven-plugin/invoker.properties @@ -0,0 +1,18 @@ +# 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 = ${project.groupId}:${project.artifactId}:${project.version}:dependency-info diff --git a/src/it/MPIR-460-maven-plugin/pom.xml b/src/it/MPIR-460-maven-plugin/pom.xml new file mode 100644 index 0000000..9021e38 --- /dev/null +++ b/src/it/MPIR-460-maven-plugin/pom.xml @@ -0,0 +1,39 @@ +<?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</groupId> + <artifactId>MPIR-460-maven-plugin</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>maven-plugin</packaging> + + <name>MPIR-460 IT test: dependency-info for maven-plugin</name> + <description> + Only coordinate for Maven plugin is generated + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> +</project> diff --git a/src/it/MPIR-460-maven-plugin/verify.groovy b/src/it/MPIR-460-maven-plugin/verify.groovy new file mode 100644 index 0000000..205a6c3 --- /dev/null +++ b/src/it/MPIR-460-maven-plugin/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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/dependency-info.html' ).text + +assert report.contains('<pre><plugin>') +assert report.contains('</plugin></pre>') + +assert !report.contains('<pre><dependency>') +assert !report.contains('</dependency></pre>') + +assert !report.contains('Apache Ivy') +assert !report.contains('Groovy Grap') +assert !report.contains('Gradle/Grail') +assert !report.contains('Scala SBT') +assert !report.contains('Leiningen') diff --git a/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java b/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java index d1d67a5..7bac534 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java @@ -37,6 +37,7 @@ import org.codehaus.plexus.i18n.I18N; public final class DependencyInformationReport extends AbstractProjectInfoReport { private static final String JAR_PACKAGING = "jar"; + private static final String PLUGIN_PACKAGING = "maven-plugin"; /** */ @@ -130,6 +131,32 @@ public final class DependencyInformationReport extends AbstractProjectInfoReport protected void renderBody() { startSection(getTitle()); + if (PLUGIN_PACKAGING.equals(packaging)) { + renderMavenPluginCoordinate(); + } else { + renderMavenDependencyCoordinate(); + renderIvyDependencyCoordinate(); + renderGrapeDependencyCoordinate(); + renderGradleDependencyCoordinate(); + renderScalaDependencyCoordinate(); + renderLeiningenDependencyCoordinate(); + } + + endSection(); + } + + private void renderMavenPluginCoordinate() { + Formatter plugin = new Formatter() + .format("<plugin>%n") + .format(" <groupId>%s</groupId>%n", groupId) + .format(" <artifactId>%s</artifactId>%n", artifactId) + .format(" <version>%s</version>%n", version) + .format("</plugin>"); + + renderDependencyInfo("Apache Maven", plugin); + } + + private void renderMavenDependencyCoordinate() { Formatter mavenDependency = new Formatter() .format("<dependency>%n") .format(" <groupId>%s</groupId>%n", groupId) @@ -141,31 +168,39 @@ public final class DependencyInformationReport extends AbstractProjectInfoReport } renderDependencyInfo("Apache Maven", mavenDependency.format("</dependency>")); + } + private void renderIvyDependencyCoordinate() { renderDependencyInfo( "Apache Ivy", new Formatter() .format("<dependency org=\"%s\" name=\"%s\" rev=\"%s\">%n", groupId, artifactId, version) .format(" <artifact name=\"%s\" type=\"%s\" />%n", artifactId, packaging) .format("</dependency>")); + } + private void renderGrapeDependencyCoordinate() { renderDependencyInfo( "Groovy Grape", new Formatter() .format("@Grapes(%n") .format("@Grab(group='%s', module='%s', version='%s')%n", groupId, artifactId, version) .format(")")); + } + private void renderGradleDependencyCoordinate() { renderDependencyInfo( "Gradle/Grails", new Formatter().format("implementation '%s:%s:%s'", groupId, artifactId, version)); + } + private void renderScalaDependencyCoordinate() { renderDependencyInfo( "Scala SBT", new Formatter() .format("libraryDependencies += \"%s\" %% \"%s\" %% \"%s\"", groupId, artifactId, version)); + } - // Leiningen - + private void renderLeiningenDependencyCoordinate() { Formatter leiningenDependency = new Formatter().format("[%s", groupId); if (!groupId.equals(artifactId)) { @@ -175,8 +210,6 @@ public final class DependencyInformationReport extends AbstractProjectInfoReport leiningenDependency.format(" \"%s\"]", version); renderDependencyInfo("Leiningen", leiningenDependency); - - endSection(); } private void renderDependencyInfo(String name, Formatter formatter) {