Skip to content

Commit 9f88610

Browse files
committed
Prepare for Doxia 2.0.0
1 parent 462c1fc commit 9f88610

File tree

5 files changed

+60
-32
lines changed

5 files changed

+60
-32
lines changed

pom.xml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ under the License.
2828
</parent>
2929

3030
<artifactId>maven-dependency-plugin</artifactId>
31-
<version>3.6.2-SNAPSHOT</version>
31+
<version>3.7.0-SNAPSHOT</version>
3232
<packaging>maven-plugin</packaging>
3333

3434
<name>Apache Maven Dependency Plugin</name>
@@ -165,33 +165,23 @@ under the License.
165165
<scope>provided</scope>
166166
</dependency>
167167

168-
<!-- reporting -->
168+
<!-- doxia -->
169169
<dependency>
170170
<groupId>org.apache.maven.doxia</groupId>
171171
<artifactId>doxia-sink-api</artifactId>
172-
<version>1.12.0</version>
173-
<exclusions>
174-
<exclusion>
175-
<groupId>org.codehaus.plexus</groupId>
176-
<artifactId>plexus-container-default</artifactId>
177-
</exclusion>
178-
</exclusions>
172+
<version>2.0.0-M8</version>
179173
</dependency>
174+
175+
<!-- reporting -->
180176
<dependency>
181177
<groupId>org.apache.maven.reporting</groupId>
182178
<artifactId>maven-reporting-api</artifactId>
183-
<version>3.1.1</version>
179+
<version>4.0.0-M9</version>
184180
</dependency>
185181
<dependency>
186182
<groupId>org.apache.maven.reporting</groupId>
187183
<artifactId>maven-reporting-impl</artifactId>
188-
<version>3.2.0</version>
189-
<exclusions>
190-
<exclusion>
191-
<groupId>org.codehaus.plexus</groupId>
192-
<artifactId>plexus-container-default</artifactId>
193-
</exclusion>
194-
</exclusions>
184+
<version>4.0.0-M13</version>
195185
</dependency>
196186
<dependency>
197187
<groupId>commons-io</groupId>

src/it/projects/analyze-report/verify.bsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
9+
*
1010
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
11+
*
1212
* Unless required by applicable law or agreed to in writing,
1313
* software distributed under the License is distributed on an
1414
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,7 @@
1919

2020
import java.io.*;
2121

22-
File htmlFile = new File( basedir, "target/site/dependency-analysis.html" );
22+
File htmlFile = new File( basedir, "target/reports/dependency-analysis.html" );
2323

2424
if ( !htmlFile.isFile() )
2525
{

src/it/projects/analyze-testDependencyWithNonTestScope/verify.bsh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
9+
*
1010
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
11+
*
1212
* Unless required by applicable law or agreed to in writing,
1313
* software distributed under the License is distributed on an
1414
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,7 +24,7 @@ import org.jsoup.nodes.Document;
2424
import org.jsoup.nodes.Element;
2525
import org.jsoup.select.Elements;
2626

27-
File htmlFile = new File( basedir, "target/site/dependency-analysis.html" );
27+
File htmlFile = new File( basedir, "target/reports/dependency-analysis.html" );
2828

2929
if ( !htmlFile.isFile() )
3030
{
@@ -37,7 +37,7 @@ if ( htmlFile.length() == 0 )
3737

3838
Document doc = Jsoup.parse( htmlFile, "UTF-8");
3939

40-
Elements entry = doc.select( "#contentBox > section > section:nth-child(5) > table > tbody > tr.b" );
40+
Elements entry = doc.select( "#bodyColumn > section > section:nth-child(5) > table > tbody > tr.b" );
4141

4242
if( entry.isEmpty() )
4343
{
@@ -50,7 +50,7 @@ else if ( entry.size() != 1 )
5050
}
5151

5252
Element groupIdElement = doc.select(
53-
"#contentBox > section > section:nth-child(5) > table > tbody > tr.b > td:nth-child(1)" ).first();
53+
"#bodyColumn > section > section:nth-child(5) > table > tbody > tr.b > td:nth-child(1)" ).first();
5454

5555
String groupId = groupIdElement.text();
5656

src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java renamed to src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
@Mojo(name = "analyze-report", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
4343
@Execute(phase = LifecyclePhase.TEST_COMPILE)
44-
public class AnalyzeReportMojo extends AbstractMavenReport {
44+
public class AnalyzeReport extends AbstractMavenReport {
4545
// fields -----------------------------------------------------------------
4646

4747
/**
@@ -115,13 +115,11 @@ public void executeReport(Locale locale) throws MavenReportException {
115115
@Override
116116
public boolean canGenerateReport() {
117117
if (skip) {
118-
getLog().info("Skipping plugin execution");
119118
return false;
120119
}
121120

122121
// Step 0: Checking pom availability
123122
if ("pom".equals(project.getPackaging())) {
124-
getLog().info("Skipping pom project");
125123
return false;
126124
}
127125

src/test/java/org/apache/maven/plugins/dependency/TestSkip.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020

2121
import java.io.File;
2222

23+
import org.apache.maven.model.Plugin;
2324
import org.apache.maven.plugin.Mojo;
25+
import org.apache.maven.plugin.MojoExecution;
26+
import org.apache.maven.plugin.descriptor.MojoDescriptor;
27+
import org.apache.maven.plugin.descriptor.PluginDescriptor;
2428
import org.apache.maven.plugin.logging.Log;
2529
import org.mockito.ArgumentCaptor;
2630

@@ -42,7 +46,7 @@ public void testSkipAnalyzeOnly() throws Exception {
4246
}
4347

4448
public void testSkipAnalyzeReport() throws Exception {
45-
doSpecialTest("analyze-report");
49+
doSpecialTest("analyze-report", true);
4650
}
4751

4852
public void testSkipAnalyzeDuplicate() throws Exception {
@@ -110,19 +114,55 @@ protected void doTest(String mojoName) throws Exception {
110114
}
111115

112116
protected void doSpecialTest(String mojoName) throws Exception {
113-
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml");
117+
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", false);
118+
}
119+
120+
protected void doSpecialTest(String mojoName, boolean addMojoExecution) throws Exception {
121+
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", addMojoExecution);
114122
}
115123

116124
private void doConfigTest(String mojoName, String configFile) throws Exception {
125+
doConfigTest(mojoName, configFile, false);
126+
}
127+
128+
private void doConfigTest(String mojoName, String configFile, boolean addMojoExecution) throws Exception {
117129
File testPom = new File(getBasedir(), "target/test-classes/unit/skip-test/" + configFile);
118130
Mojo mojo = lookupMojo(mojoName, testPom);
119-
assertNotNull(mojo);
131+
assertNotNull("Mojo not found.", mojo);
132+
133+
if (addMojoExecution) {
134+
setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution(mojoName));
135+
}
120136
Log log = mock(Log.class);
121137
mojo.setLog(log);
122138
mojo.execute();
123139

124140
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
125141
verify(log, atLeastOnce()).info(captor.capture());
126-
assertTrue(captor.getValue().contains("Skipping plugin execution"));
142+
String skipMessage;
143+
if (addMojoExecution) {
144+
MojoExecution me = getMockMojoExecution(mojoName);
145+
String reportMojoInfo = me.getPlugin().getId() + ":" + me.getGoal();
146+
skipMessage = "Skipping " + reportMojoInfo + " report goal";
147+
} else {
148+
skipMessage = "Skipping plugin execution";
149+
}
150+
assertTrue(captor.getValue().contains(skipMessage));
151+
}
152+
153+
private MojoExecution getMockMojoExecution(String goal) {
154+
MojoDescriptor md = new MojoDescriptor();
155+
md.setGoal(goal);
156+
157+
MojoExecution me = new MojoExecution(md);
158+
159+
PluginDescriptor pd = new PluginDescriptor();
160+
Plugin p = new Plugin();
161+
p.setGroupId("org.apache.maven.plugins");
162+
p.setArtifactId("maven-dependency-plugin");
163+
pd.setPlugin(p);
164+
md.setPluginDescriptor(pd);
165+
166+
return me;
127167
}
128168
}

0 commit comments

Comments
 (0)