Skip to content

Commit

Permalink
[MDEP-903] Upgrade to Doxia 2.0.0 Milestone Stack
Browse files Browse the repository at this point in the history
This closes #314
  • Loading branch information
michael-o committed Aug 18, 2024
1 parent 1115ecb commit 50397c4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 63 deletions.
57 changes: 9 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,17 @@ under the License.
</distributionManagement>

<properties>
<mavenVersion>3.6.3</mavenVersion>
<javaVersion>8</javaVersion>

<mavenVersion>3.6.3</mavenVersion>
<resolverVersion>1.4.1</resolverVersion>
<slf4jVersion>1.7.36</slf4jVersion>
<jettyVersion>9.4.55.v20240627</jettyVersion>
<mockito.version>4.11.0</mockito.version>
<plexus-archiver.version>4.10.0</plexus-archiver.version>
<pluginTestingVersion>3.3.0</pluginTestingVersion>
<resolverVersion>1.4.1</resolverVersion>
<slf4jVersion>1.7.36</slf4jVersion>

<project.build.outputTimestamp>2024-06-18T07:04:19Z</project.build.outputTimestamp>
</properties>

<dependencyManagement>
<dependencies>
<!-- override the version from maven-reporting-impl -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- maven -->
<dependency>
Expand Down Expand Up @@ -156,49 +143,23 @@ under the License.
<scope>provided</scope>
</dependency>

<!-- reporting -->
<!-- doxia -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
<version>1.12.0</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
<version>2.0.0-M12</version>
</dependency>

<!-- reporting -->
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>3.1.1</version>
<version>4.0.0-M12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>3.2.0</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
</exclusion>
</exclusions>
<version>4.0.0-M15</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
6 changes: 3 additions & 3 deletions src/it/projects/analyze-report/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* 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
Expand All @@ -19,7 +19,7 @@

import java.io.*;

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

if ( !htmlFile.isFile() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* 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
Expand All @@ -24,7 +24,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

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

if ( !htmlFile.isFile() )
{
Expand All @@ -37,7 +37,7 @@ if ( htmlFile.length() == 0 )

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

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

if( entry.isEmpty() )
{
Expand All @@ -50,7 +50,7 @@ else if ( entry.size() != 1 )
}

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

String groupId = groupIdElement.text();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
@Mojo(name = "analyze-report", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class AnalyzeReportMojo extends AbstractMavenReport {
public class AnalyzeReport extends AbstractMavenReport {
// fields -----------------------------------------------------------------

/**
Expand Down Expand Up @@ -124,13 +124,11 @@ public void executeReport(Locale locale) throws MavenReportException {
@Override
public boolean canGenerateReport() {
if (skip) {
getLog().info("Skipping plugin execution");
return false;
}

// Step 0: Checking pom availability
if ("pom".equals(project.getPackaging())) {
getLog().info("Skipping pom project");
return false;
}

Expand Down
48 changes: 44 additions & 4 deletions src/test/java/org/apache/maven/plugins/dependency/TestSkip.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
import java.io.File;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -56,7 +60,7 @@ public void testSkipAnalyzeOnly() throws Exception {
}

public void testSkipAnalyzeReport() throws Exception {
doSpecialTest("analyze-report");
doSpecialTest("analyze-report", true);
}

public void testSkipAnalyzeDuplicate() throws Exception {
Expand Down Expand Up @@ -124,19 +128,55 @@ protected void doTest(String mojoName) throws Exception {
}

protected void doSpecialTest(String mojoName) throws Exception {
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml");
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", false);
}

protected void doSpecialTest(String mojoName, boolean addMojoExecution) throws Exception {
doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", addMojoExecution);
}

private void doConfigTest(String mojoName, String configFile) throws Exception {
doConfigTest(mojoName, configFile, false);
}

private void doConfigTest(String mojoName, String configFile, boolean addMojoExecution) throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/skip-test/" + configFile);
Mojo mojo = lookupMojo(mojoName, testPom);
assertNotNull(mojo);
assertNotNull("Mojo not found.", mojo);

if (addMojoExecution) {
setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution(mojoName));
}
Log log = mock(Log.class);
mojo.setLog(log);
mojo.execute();

ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(log, atLeastOnce()).info(captor.capture());
assertTrue(captor.getValue().contains("Skipping plugin execution"));
String skipMessage;
if (addMojoExecution) {
MojoExecution me = getMockMojoExecution(mojoName);
String reportMojoInfo = me.getPlugin().getId() + ":" + me.getGoal();
skipMessage = "Skipping " + reportMojoInfo + " report goal";
} else {
skipMessage = "Skipping plugin execution";
}
assertTrue(captor.getValue().contains(skipMessage));
}

private MojoExecution getMockMojoExecution(String goal) {
MojoDescriptor md = new MojoDescriptor();
md.setGoal(goal);

MojoExecution me = new MojoExecution(md);

PluginDescriptor pd = new PluginDescriptor();
Plugin p = new Plugin();
p.setGroupId("org.apache.maven.plugins");
p.setArtifactId("maven-dependency-plugin");
pd.setPlugin(p);
md.setPluginDescriptor(pd);

return me;
}
}

0 comments on commit 50397c4

Please sign in to comment.