Skip to content

Commit dc1710d

Browse files
[MPIR-460] Dependency Information for maven-plugin
1 parent 2ca83d0 commit dc1710d

File tree

7 files changed

+213
-4
lines changed

7 files changed

+213
-4
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:dependency-info

src/it/MPIR-460-jar/pom.xml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.apache.maven.plugins.project-info-reports</groupId>
27+
<artifactId>MPIR-460-jar</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
<packaging>jar</packaging>
30+
31+
<name>MPIR-460 IT test: dependency-info for jar packaging</name>
32+
<description>
33+
Coordinates list are generated for many tools
34+
</description>
35+
36+
<properties>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
</properties>
39+
</project>

src/it/MPIR-460-jar/verify.groovy

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
def report = new File( basedir, 'target/site/dependency-info.html' ).text
20+
21+
assert !report.contains('<pre>&lt;plugin&gt;')
22+
assert !report.contains('&lt;/plugin&gt;</pre>')
23+
24+
assert report.contains('<pre>&lt;dependency&gt;')
25+
assert report.contains('&lt;/dependency&gt;</pre>')
26+
27+
assert report.contains('Apache Ivy')
28+
assert report.contains('Groovy Grape')
29+
assert report.contains('Gradle/Grails')
30+
assert report.contains('Scala SBT')
31+
assert report.contains('Leiningen')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:dependency-info

src/it/MPIR-460-maven-plugin/pom.xml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.apache.maven.plugins.project-info-reports</groupId>
27+
<artifactId>MPIR-460-maven-plugin</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
<packaging>maven-plugin</packaging>
30+
31+
<name>MPIR-460 IT test: dependency-info for maven-plugin</name>
32+
<description>
33+
Only coordinates for Maven plugin is generated
34+
</description>
35+
36+
<properties>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
</properties>
39+
</project>
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
def report = new File( basedir, 'target/site/dependency-info.html' ).text
20+
21+
assert report.contains('<pre>&lt;plugin&gt;')
22+
assert report.contains('&lt;/plugin&gt;</pre>')
23+
24+
assert !report.contains('<pre>&lt;dependency&gt;')
25+
assert !report.contains('&lt;/dependency&gt;</pre>')
26+
27+
assert !report.contains('Apache Ivy')
28+
assert !report.contains('Groovy Grape')
29+
assert !report.contains('Gradle/Grails')
30+
assert !report.contains('Scala SBT')
31+
assert !report.contains('Leiningen')

src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java

+37-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
public final class DependencyInformationReport extends AbstractProjectInfoReport {
3838

3939
private static final String JAR_PACKAGING = "jar";
40+
private static final String PLUGIN_PACKAGING = "maven-plugin";
4041

4142
/**
4243
*/
@@ -130,6 +131,32 @@ protected String getI18Nsection() {
130131
protected void renderBody() {
131132
startSection(getTitle());
132133

134+
if (PLUGIN_PACKAGING.equals(packaging)) {
135+
renderMavenPluginCoordinates();
136+
} else {
137+
renderMavenDependencyCoordinates();
138+
renderIvyDependencyCoordinates();
139+
renderGrapeDependencyCoordinates();
140+
renderGradleDependencyCoordinates();
141+
renderScalaDependencyCoordinates();
142+
renderLeiningenDependencyCoordinates();
143+
}
144+
145+
endSection();
146+
}
147+
148+
private void renderMavenPluginCoordinates() {
149+
Formatter plugin = new Formatter()
150+
.format("<plugin>%n")
151+
.format(" <groupId>%s</groupId>%n", groupId)
152+
.format(" <artifactId>%s</artifactId>%n", artifactId)
153+
.format(" <version>%s</version>%n", version)
154+
.format("</plugin>");
155+
156+
renderDependencyInfo("Apache Maven", plugin);
157+
}
158+
159+
private void renderMavenDependencyCoordinates() {
133160
Formatter mavenDependency = new Formatter()
134161
.format("<dependency>%n")
135162
.format(" <groupId>%s</groupId>%n", groupId)
@@ -141,31 +168,39 @@ protected void renderBody() {
141168
}
142169

143170
renderDependencyInfo("Apache Maven", mavenDependency.format("</dependency>"));
171+
}
144172

173+
private void renderIvyDependencyCoordinates() {
145174
renderDependencyInfo(
146175
"Apache Ivy",
147176
new Formatter()
148177
.format("<dependency org=\"%s\" name=\"%s\" rev=\"%s\">%n", groupId, artifactId, version)
149178
.format(" <artifact name=\"%s\" type=\"%s\" />%n", artifactId, packaging)
150179
.format("</dependency>"));
180+
}
151181

182+
private void renderGrapeDependencyCoordinates() {
152183
renderDependencyInfo(
153184
"Groovy Grape",
154185
new Formatter()
155186
.format("@Grapes(%n")
156187
.format("@Grab(group='%s', module='%s', version='%s')%n", groupId, artifactId, version)
157188
.format(")"));
189+
}
158190

191+
private void renderGradleDependencyCoordinates() {
159192
renderDependencyInfo(
160193
"Gradle/Grails", new Formatter().format("implementation '%s:%s:%s'", groupId, artifactId, version));
194+
}
161195

196+
private void renderScalaDependencyCoordinates() {
162197
renderDependencyInfo(
163198
"Scala SBT",
164199
new Formatter()
165200
.format("libraryDependencies += \"%s\" %% \"%s\" %% \"%s\"", groupId, artifactId, version));
201+
}
166202

167-
// Leiningen
168-
203+
private void renderLeiningenDependencyCoordinates() {
169204
Formatter leiningenDependency = new Formatter().format("[%s", groupId);
170205

171206
if (!groupId.equals(artifactId)) {
@@ -175,8 +210,6 @@ protected void renderBody() {
175210
leiningenDependency.format(" \"%s\"]", version);
176211

177212
renderDependencyInfo("Leiningen", leiningenDependency);
178-
179-
endSection();
180213
}
181214

182215
private void renderDependencyInfo(String name, Formatter formatter) {

0 commit comments

Comments
 (0)