This is an automated email from the ASF dual-hosted git repository. sjaranowski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git
The following commit(s) were added to refs/heads/master by this push: new dc1710d [MPIR-460] Dependency Information for maven-plugin dc1710d is described below commit dc1710d595de4467be743d4c55a020eef1bc22e3 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..3d8e27c --- /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> + Coordinates 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..f1b1fd8 --- /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 Grape') +assert report.contains('Gradle/Grails') +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..f03a039 --- /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 coordinates 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..b60bfac --- /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 Grape') +assert !report.contains('Gradle/Grails') +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..4d57b22 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)) { + renderMavenPluginCoordinates(); + } else { + renderMavenDependencyCoordinates(); + renderIvyDependencyCoordinates(); + renderGrapeDependencyCoordinates(); + renderGradleDependencyCoordinates(); + renderScalaDependencyCoordinates(); + renderLeiningenDependencyCoordinates(); + } + + endSection(); + } + + private void renderMavenPluginCoordinates() { + 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 renderMavenDependencyCoordinates() { 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 renderIvyDependencyCoordinates() { 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 renderGrapeDependencyCoordinates() { renderDependencyInfo( "Groovy Grape", new Formatter() .format("@Grapes(%n") .format("@Grab(group='%s', module='%s', version='%s')%n", groupId, artifactId, version) .format(")")); + } + private void renderGradleDependencyCoordinates() { renderDependencyInfo( "Gradle/Grails", new Formatter().format("implementation '%s:%s:%s'", groupId, artifactId, version)); + } + private void renderScalaDependencyCoordinates() { renderDependencyInfo( "Scala SBT", new Formatter() .format("libraryDependencies += \"%s\" %% \"%s\" %% \"%s\"", groupId, artifactId, version)); + } - // Leiningen - + private void renderLeiningenDependencyCoordinates() { 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) {