diff --git a/src/it/MPIR-460-jar/invoker.properties b/src/it/MPIR-460-jar/invoker.properties new file mode 100644 index 00000000..0e9501c2 --- /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 00000000..3d8e27c4 --- /dev/null +++ b/src/it/MPIR-460-jar/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.project-info-reports + MPIR-460-jar + 1.0-SNAPSHOT + jar + + MPIR-460 IT test: dependency-info for jar packaging + + Coordinates list are generated for many tools + + + + UTF-8 + + diff --git a/src/it/MPIR-460-jar/verify.groovy b/src/it/MPIR-460-jar/verify.groovy new file mode 100644 index 00000000..f1b1fd84 --- /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('
<plugin>')
+assert !report.contains('</plugin>
') + +assert report.contains('
<dependency>')
+assert report.contains('</dependency>
') + +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 00000000..0e9501c2 --- /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 00000000..f03a0393 --- /dev/null +++ b/src/it/MPIR-460-maven-plugin/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.project-info-reports + MPIR-460-maven-plugin + 1.0-SNAPSHOT + maven-plugin + + MPIR-460 IT test: dependency-info for maven-plugin + + Only coordinates for Maven plugin is generated + + + + UTF-8 + + 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 00000000..b60bfac6 --- /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('
<plugin>')
+assert report.contains('</plugin>
') + +assert !report.contains('
<dependency>')
+assert !report.contains('</dependency>
') + +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 d1d67a5f..4d57b22f 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 @@ 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 @@ protected String getI18Nsection() { 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("%n") + .format(" %s%n", groupId) + .format(" %s%n", artifactId) + .format(" %s%n", version) + .format(""); + + renderDependencyInfo("Apache Maven", plugin); + } + + private void renderMavenDependencyCoordinates() { Formatter mavenDependency = new Formatter() .format("%n") .format(" %s%n", groupId) @@ -141,31 +168,39 @@ protected void renderBody() { } renderDependencyInfo("Apache Maven", mavenDependency.format("")); + } + private void renderIvyDependencyCoordinates() { renderDependencyInfo( "Apache Ivy", new Formatter() .format("%n", groupId, artifactId, version) .format(" %n", artifactId, packaging) .format("")); + } + 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 @@ protected void renderBody() { leiningenDependency.format(" \"%s\"]", version); renderDependencyInfo("Leiningen", leiningenDependency); - - endSection(); } private void renderDependencyInfo(String name, Formatter formatter) {