Skip to content

Commit 50397c4

Browse files
committed
[MDEP-903] Upgrade to Doxia 2.0.0 Milestone Stack
This closes #314
1 parent 1115ecb commit 50397c4

File tree

5 files changed

+62
-63
lines changed

5 files changed

+62
-63
lines changed

pom.xml

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,17 @@ under the License.
8787
</distributionManagement>
8888

8989
<properties>
90-
<mavenVersion>3.6.3</mavenVersion>
9190
<javaVersion>8</javaVersion>
92-
91+
<mavenVersion>3.6.3</mavenVersion>
92+
<resolverVersion>1.4.1</resolverVersion>
93+
<slf4jVersion>1.7.36</slf4jVersion>
9394
<jettyVersion>9.4.55.v20240627</jettyVersion>
9495
<mockito.version>4.11.0</mockito.version>
9596
<plexus-archiver.version>4.10.0</plexus-archiver.version>
9697
<pluginTestingVersion>3.3.0</pluginTestingVersion>
97-
<resolverVersion>1.4.1</resolverVersion>
98-
<slf4jVersion>1.7.36</slf4jVersion>
99-
10098
<project.build.outputTimestamp>2024-06-18T07:04:19Z</project.build.outputTimestamp>
10199
</properties>
102100

103-
<dependencyManagement>
104-
<dependencies>
105-
<!-- override the version from maven-reporting-impl -->
106-
<dependency>
107-
<groupId>org.apache.commons</groupId>
108-
<artifactId>commons-text</artifactId>
109-
<version>1.12.0</version>
110-
</dependency>
111-
</dependencies>
112-
</dependencyManagement>
113-
114101
<dependencies>
115102
<!-- maven -->
116103
<dependency>
@@ -156,49 +143,23 @@ under the License.
156143
<scope>provided</scope>
157144
</dependency>
158145

159-
<!-- reporting -->
146+
<!-- doxia -->
160147
<dependency>
161148
<groupId>org.apache.maven.doxia</groupId>
162149
<artifactId>doxia-sink-api</artifactId>
163-
<version>1.12.0</version>
164-
<exclusions>
165-
<exclusion>
166-
<groupId>org.codehaus.plexus</groupId>
167-
<artifactId>plexus-container-default</artifactId>
168-
</exclusion>
169-
</exclusions>
150+
<version>2.0.0-M12</version>
170151
</dependency>
152+
153+
<!-- reporting -->
171154
<dependency>
172155
<groupId>org.apache.maven.reporting</groupId>
173156
<artifactId>maven-reporting-api</artifactId>
174-
<version>3.1.1</version>
157+
<version>4.0.0-M12</version>
175158
</dependency>
176159
<dependency>
177160
<groupId>org.apache.maven.reporting</groupId>
178161
<artifactId>maven-reporting-impl</artifactId>
179-
<version>3.2.0</version>
180-
<exclusions>
181-
<exclusion>
182-
<groupId>org.codehaus.plexus</groupId>
183-
<artifactId>plexus-container-default</artifactId>
184-
</exclusion>
185-
<exclusion>
186-
<groupId>org.apache.maven</groupId>
187-
<artifactId>maven-artifact</artifactId>
188-
</exclusion>
189-
<exclusion>
190-
<groupId>org.apache.maven</groupId>
191-
<artifactId>maven-core</artifactId>
192-
</exclusion>
193-
<exclusion>
194-
<groupId>org.apache.maven</groupId>
195-
<artifactId>maven-model</artifactId>
196-
</exclusion>
197-
<exclusion>
198-
<groupId>org.apache.maven</groupId>
199-
<artifactId>maven-plugin-api</artifactId>
200-
</exclusion>
201-
</exclusions>
162+
<version>4.0.0-M15</version>
202163
</dependency>
203164
<dependency>
204165
<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
@@ -42,7 +42,7 @@
4242
*/
4343
@Mojo(name = "analyze-report", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
4444
@Execute(phase = LifecyclePhase.TEST_COMPILE)
45-
public class AnalyzeReportMojo extends AbstractMavenReport {
45+
public class AnalyzeReport extends AbstractMavenReport {
4646
// fields -----------------------------------------------------------------
4747

4848
/**
@@ -124,13 +124,11 @@ public void executeReport(Locale locale) throws MavenReportException {
124124
@Override
125125
public boolean canGenerateReport() {
126126
if (skip) {
127-
getLog().info("Skipping plugin execution");
128127
return false;
129128
}
130129

131130
// Step 0: Checking pom availability
132131
if ("pom".equals(project.getPackaging())) {
133-
getLog().info("Skipping pom project");
134132
return false;
135133
}
136134

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

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
import java.io.File;
2222

2323
import org.apache.maven.execution.MavenSession;
24+
import org.apache.maven.model.Plugin;
2425
import org.apache.maven.plugin.Mojo;
26+
import org.apache.maven.plugin.MojoExecution;
27+
import org.apache.maven.plugin.descriptor.MojoDescriptor;
28+
import org.apache.maven.plugin.descriptor.PluginDescriptor;
2529
import org.apache.maven.plugin.logging.Log;
2630
import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
2731
import org.apache.maven.project.MavenProject;
@@ -56,7 +60,7 @@ public void testSkipAnalyzeOnly() throws Exception {
5660
}
5761

5862
public void testSkipAnalyzeReport() throws Exception {
59-
doSpecialTest("analyze-report");
63+
doSpecialTest("analyze-report", true);
6064
}
6165

6266
public void testSkipAnalyzeDuplicate() throws Exception {
@@ -124,19 +128,55 @@ protected void doTest(String mojoName) throws Exception {
124128
}
125129

126130
protected void doSpecialTest(String mojoName) throws Exception {
127-
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml");
131+
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", false);
132+
}
133+
134+
protected void doSpecialTest(String mojoName, boolean addMojoExecution) throws Exception {
135+
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", addMojoExecution);
128136
}
129137

130138
private void doConfigTest(String mojoName, String configFile) throws Exception {
139+
doConfigTest(mojoName, configFile, false);
140+
}
141+
142+
private void doConfigTest(String mojoName, String configFile, boolean addMojoExecution) throws Exception {
131143
File testPom = new File(getBasedir(), "target/test-classes/unit/skip-test/" + configFile);
132144
Mojo mojo = lookupMojo(mojoName, testPom);
133-
assertNotNull(mojo);
145+
assertNotNull("Mojo not found.", mojo);
146+
147+
if (addMojoExecution) {
148+
setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution(mojoName));
149+
}
134150
Log log = mock(Log.class);
135151
mojo.setLog(log);
136152
mojo.execute();
137153

138154
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
139155
verify(log, atLeastOnce()).info(captor.capture());
140-
assertTrue(captor.getValue().contains("Skipping plugin execution"));
156+
String skipMessage;
157+
if (addMojoExecution) {
158+
MojoExecution me = getMockMojoExecution(mojoName);
159+
String reportMojoInfo = me.getPlugin().getId() + ":" + me.getGoal();
160+
skipMessage = "Skipping " + reportMojoInfo + " report goal";
161+
} else {
162+
skipMessage = "Skipping plugin execution";
163+
}
164+
assertTrue(captor.getValue().contains(skipMessage));
165+
}
166+
167+
private MojoExecution getMockMojoExecution(String goal) {
168+
MojoDescriptor md = new MojoDescriptor();
169+
md.setGoal(goal);
170+
171+
MojoExecution me = new MojoExecution(md);
172+
173+
PluginDescriptor pd = new PluginDescriptor();
174+
Plugin p = new Plugin();
175+
p.setGroupId("org.apache.maven.plugins");
176+
p.setArtifactId("maven-dependency-plugin");
177+
pd.setPlugin(p);
178+
md.setPluginDescriptor(pd);
179+
180+
return me;
141181
}
142182
}

0 commit comments

Comments
 (0)