Skip to content

Commit d57eaff

Browse files
authored
[MPLUGIN-376] Drop legacy dependencies (#42)
Plugin used a lot of legacy code, misused Mojo test case and used old Junit 3.x TestCase, and missed some dependencies (junit mostly). Changes: * drop use of Junit 3 TestCase, use Junit4 everywhere * fix misuses of AbstractMojoTestCase when it is NOT mojo being tested * add missing junit test dep where missing * drop legacy p-c-d, sisu using exclusions/replacements * align JavaMojoDescriptorExtractorTest.java for semantic difference: current Shim returns empty list instead of null when no components (for null safety). Assers updated but semantic is same: "there are no components discovered".
1 parent 6d3d92e commit d57eaff

File tree

12 files changed

+91
-49
lines changed

12 files changed

+91
-49
lines changed

maven-plugin-plugin/pom.xml

+22-10
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@
9999
<groupId>org.apache.maven.doxia</groupId>
100100
<artifactId>doxia-sink-api</artifactId>
101101
<version>${doxiaVersion}</version>
102+
<exclusions>
103+
<exclusion>
104+
<groupId>org.codehaus.plexus</groupId>
105+
<artifactId>plexus-container-default</artifactId>
106+
</exclusion>
107+
</exclusions>
102108
</dependency>
103109
<dependency>
104110
<groupId>org.apache.maven.doxia</groupId>
@@ -120,19 +126,24 @@
120126
<dependency>
121127
<groupId>org.apache.maven</groupId>
122128
<artifactId>maven-plugin-api</artifactId>
129+
<!-- TODO: make this provided once 3.6.2+ maven-plugin-plugin is in use -->
130+
<scope>compile</scope>
123131
</dependency>
124132
<dependency>
125133
<groupId>org.apache.maven</groupId>
126134
<artifactId>maven-model</artifactId>
135+
<scope>provided</scope>
127136
</dependency>
128137
<dependency>
129138
<groupId>org.apache.maven</groupId>
130139
<artifactId>maven-repository-metadata</artifactId>
131140
<version>${mavenVersion}</version>
141+
<scope>provided</scope>
132142
</dependency>
133143
<dependency>
134144
<groupId>org.apache.maven</groupId>
135145
<artifactId>maven-artifact</artifactId>
146+
<scope>provided</scope>
136147
</dependency>
137148

138149
<!-- shared -->
@@ -148,19 +159,13 @@
148159
<artifactId>plexus-utils</artifactId>
149160
</dependency>
150161
<dependency>
151-
<groupId>org.sonatype.sisu</groupId>
152-
<artifactId>sisu-inject-plexus</artifactId>
153-
<version>1.4.2</version>
162+
<groupId>org.eclipse.sisu</groupId>
163+
<artifactId>org.eclipse.sisu.plexus</artifactId>
164+
<scope>provided</scope>
154165
</dependency>
155166
<dependency>
156167
<groupId>org.codehaus.plexus</groupId>
157168
<artifactId>plexus-velocity</artifactId>
158-
<exclusions>
159-
<exclusion>
160-
<groupId>velocity</groupId>
161-
<artifactId>velocity</artifactId>
162-
</exclusion>
163-
</exclusions>
164169
</dependency>
165170

166171
<!-- for m2e support: https://www.eclipse.org/m2e/documentation/m2e-making-maven-plugins-compat.html -->
@@ -169,7 +174,14 @@
169174
<artifactId>plexus-build-api</artifactId>
170175
<version>0.0.7</version>
171176
</dependency>
172-
177+
178+
<!-- tests -->
179+
<dependency>
180+
<groupId>junit</groupId>
181+
<artifactId>junit</artifactId>
182+
<scope>test</scope>
183+
</dependency>
184+
173185
<!-- needed for it tests -->
174186
<dependency>
175187
<groupId>org.apache.maven.plugin-tools</groupId>

maven-plugin-tools-annotations/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@
7171
</exclusion>
7272
</exclusions>
7373
</dependency>
74-
<dependency>
75-
<groupId>org.sonatype.sisu</groupId>
76-
<artifactId>sisu-inject-plexus</artifactId>
77-
<version>1.4.2</version>
78-
</dependency>
7974
<dependency>
8075
<groupId>org.codehaus.plexus</groupId>
8176
<artifactId>plexus-archiver</artifactId>

maven-plugin-tools-api/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161
<groupId>org.codehaus.plexus</groupId>
6262
<artifactId>plexus-utils</artifactId>
6363
</dependency>
64-
<dependency>
65-
<groupId>org.sonatype.sisu</groupId>
66-
<artifactId>sisu-inject-plexus</artifactId>
67-
<version>1.4.2</version>
68-
</dependency>
6964

7065
<!-- test -->
7166
<dependency>

maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
*/
2121

2222
import org.apache.maven.plugin.descriptor.PluginDescriptor;
23-
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
23+
import org.junit.Test;
24+
25+
import static org.junit.Assert.assertEquals;
2426

2527
/**
2628
* @author jdcasey
2729
*/
2830
public class PluginUtilsTest
29-
extends AbstractMojoTestCase
3031
{
32+
@Test
3133
public void testShouldTrimArtifactIdToFindPluginId()
3234
{
3335
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-artifactId-plugin" ) );
@@ -38,6 +40,7 @@ public void testShouldTrimArtifactIdToFindPluginId()
3840
assertEquals( "plugin", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-plugin-plugin" ) );
3941
}
4042

43+
@Test
4144
public void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
4245
{
4346
String testScript = "test.txt";
@@ -50,6 +53,7 @@ public void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
5053
assertEquals( 2, files.length );
5154
}
5255

56+
@Test
5357
public void testShouldFindOneScriptsWhenAnExcludeIsGiven()
5458
{
5559
String testScript = "test.txt";

maven-plugin-tools-generators/pom.xml

+12-7
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@
6262
<dependency>
6363
<groupId>org.codehaus.plexus</groupId>
6464
<artifactId>plexus-velocity</artifactId>
65-
<exclusions>
66-
<exclusion>
67-
<groupId>velocity</groupId>
68-
<artifactId>velocity</artifactId>
69-
</exclusion>
70-
</exclusions>
7165
</dependency>
7266

7367
<!-- other -->
@@ -93,11 +87,22 @@
9387
</dependency>
9488

9589
<!-- test -->
90+
<dependency>
91+
<groupId>junit</groupId>
92+
<artifactId>junit</artifactId>
93+
<scope>test</scope>
94+
</dependency>
9695
<dependency>
9796
<groupId>org.apache.maven.reporting</groupId>
9897
<artifactId>maven-reporting-impl</artifactId>
99-
<version>2.1</version>
98+
<version>3.0.0</version>
10099
<scope>test</scope>
100+
<exclusions>
101+
<exclusion>
102+
<groupId>org.codehaus.plexus</groupId>
103+
<artifactId>plexus-container-default</artifactId>
104+
</exclusion>
105+
</exclusions>
101106
</dependency>
102107
<dependency>
103108
<groupId>org.apache.maven.plugin-testing</groupId>

maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/GeneratorUtilsTest.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@
2020
*/
2121

2222
import org.apache.maven.plugin.descriptor.PluginDescriptor;
23-
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
2423
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
2524
import org.codehaus.plexus.component.repository.ComponentDependency;
2625
import org.codehaus.plexus.util.xml.CompactXMLWriter;
2726
import org.codehaus.plexus.util.xml.XMLWriter;
27+
import org.junit.Test;
2828

2929
import java.io.StringWriter;
3030
import java.util.Collections;
3131

32+
import static org.junit.Assert.assertEquals;
33+
import static org.junit.Assert.assertFalse;
34+
import static org.junit.Assert.assertTrue;
35+
3236
/**
3337
* @author jdcasey
3438
*/
3539
public class GeneratorUtilsTest
36-
extends AbstractMojoTestCase
3740
{
41+
@Test
3842
public void testShouldWriteDependencies()
3943
throws Exception
4044
{
@@ -62,6 +66,7 @@ public void testShouldWriteDependencies()
6266
assertEquals( pattern, output );
6367
}
6468

69+
@Test
6570
public void testMakeHtmlValid()
6671
{
6772
String javadoc = null;
@@ -94,6 +99,7 @@ public void testMakeHtmlValid()
9499
assertEquals( javadoc, GeneratorUtils.makeHtmlValid( javadoc ) );
95100
}
96101

102+
@Test
97103
public void testDecodeJavadocTags()
98104
{
99105
String javadoc = null;
@@ -148,6 +154,7 @@ public void testDecodeJavadocTags()
148154
assertEquals( "label", GeneratorUtils.decodeJavadocTags( javadoc ) );
149155
}
150156

157+
@Test
151158
public void testToText()
152159
throws Exception
153160
{
@@ -179,6 +186,7 @@ public void testToText()
179186
assertEquals( "Generates something for the project.", GeneratorUtils.toText( javadoc ) );
180187
}
181188

189+
@Test
182190
public void testIsMavenReport()
183191
throws Exception
184192
{
@@ -194,7 +202,7 @@ public void testIsMavenReport()
194202
String impl = "org.apache.maven.tools.plugin.generator.stubs.MavenReportStub";
195203

196204
MavenProjectStub stub = new MavenProjectStub();
197-
stub.setCompileSourceRoots( Collections.singletonList( getBasedir() + "/target/classes" ) );
205+
stub.setCompileSourceRoots( Collections.singletonList( System.getProperty( "basedir" ) + "/target/classes" ) );
198206

199207
assertTrue( GeneratorUtils.isMavenReport( impl, stub ) );
200208

maven-plugin-tools-java/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@
5858
<dependency>
5959
<groupId>org.codehaus.plexus</groupId>
6060
<artifactId>plexus-component-annotations</artifactId>
61-
<exclusions>
62-
<exclusion>
63-
<groupId>junit</groupId>
64-
<artifactId>junit</artifactId>
65-
</exclusion>
66-
</exclusions>
6761
</dependency>
6862

6963
<!-- misc -->
@@ -72,6 +66,12 @@
7266
<artifactId>qdox</artifactId>
7367
</dependency>
7468

69+
<!-- test -->
70+
<dependency>
71+
<groupId>junit</groupId>
72+
<artifactId>junit</artifactId>
73+
<scope>test</scope>
74+
</dependency>
7575
<dependency>
7676
<groupId>xmlunit</groupId>
7777
<artifactId>xmlunit</artifactId>

maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public void testAnnotationInPlugin()
222222
{
223223
List<MojoDescriptor> results = extract( "source3" );
224224

225-
assertNull( results );
225+
assertTrue( results.isEmpty() );
226226
}
227227

228228
/**
@@ -253,7 +253,7 @@ public void testMethodReferenceInEnumConstructor()
253253
{
254254
List<MojoDescriptor> results = extract( "MPLUGIN-320" );
255255

256-
assertNull( results );
256+
assertTrue( results.isEmpty() );
257257
}
258258

259259
@Test
@@ -262,7 +262,7 @@ public void testEnumWithRegexPattern()
262262
{
263263
List<MojoDescriptor> results = extract( "MPLUGIN-290" );
264264

265-
assertNull( results );
265+
assertTrue( results.isEmpty() );
266266
}
267267

268268
}

maven-script/maven-plugin-tools-model/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@
4444
<groupId>org.codehaus.plexus</groupId>
4545
<artifactId>plexus-utils</artifactId>
4646
</dependency>
47-
<dependency>
48-
<groupId>org.sonatype.sisu</groupId>
49-
<artifactId>sisu-inject-plexus</artifactId>
50-
<version>1.4.2</version>
51-
</dependency>
5247
<dependency>
5348
<groupId>junit</groupId>
5449
<artifactId>junit</artifactId>

maven-script/maven-script-ant/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ under the License.
5050
<groupId>org.codehaus.plexus</groupId>
5151
<artifactId>plexus-ant-factory</artifactId>
5252
<version>1.0-alpha-2.1</version>
53+
<exclusions>
54+
<exclusion>
55+
<groupId>org.codehaus.plexus</groupId>
56+
<artifactId>plexus-container-default</artifactId>
57+
</exclusion>
58+
</exclusions>
5359
</dependency>
5460
<dependency>
5561
<groupId>org.codehaus.plexus</groupId>

maven-script/maven-script-beanshell/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ under the License.
4040
<groupId>org.codehaus.plexus</groupId>
4141
<artifactId>plexus-bsh-factory</artifactId>
4242
<version>1.0-alpha-7</version>
43+
<exclusions>
44+
<exclusion>
45+
<groupId>org.codehaus.plexus</groupId>
46+
<artifactId>plexus-container-default</artifactId>
47+
</exclusion>
48+
</exclusions>
4349
</dependency>
4450
<dependency>
4551
<groupId>bsh</groupId>

pom.xml

+19-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@
9292
<properties>
9393
<surefire.version>2.22.2</surefire.version>
9494
<javaVersion>7</javaVersion>
95-
<pluginTestingHarnessVersion>1.3</pluginTestingHarnessVersion>
96-
<mavenVersion>3.2.2</mavenVersion>
95+
<pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
96+
<mavenVersion>3.2.5</mavenVersion>
9797
<antVersion>1.7.1</antVersion>
98+
<sisuVersion>0.3.5</sisuVersion>
9899
<mavenInvokerPluginVersion>3.2.2</mavenInvokerPluginVersion>
99100
<maven.site.path>plugin-tools-archives/plugin-tools-LATEST</maven.site.path>
100101
<asmVersion>9.1</asmVersion>
@@ -171,6 +172,11 @@
171172
</dependency>
172173

173174
<!-- plexus -->
175+
<dependency>
176+
<groupId>org.eclipse.sisu</groupId>
177+
<artifactId>org.eclipse.sisu.plexus</artifactId>
178+
<version>${sisuVersion}</version>
179+
</dependency>
174180
<dependency>
175181
<groupId>org.codehaus.plexus</groupId>
176182
<artifactId>plexus-utils</artifactId>
@@ -196,6 +202,16 @@
196202
<groupId>org.codehaus.plexus</groupId>
197203
<artifactId>plexus-velocity</artifactId>
198204
<version>1.2</version>
205+
<exclusions>
206+
<exclusion>
207+
<groupId>org.codehaus.plexus</groupId>
208+
<artifactId>plexus-container-default</artifactId>
209+
</exclusion>
210+
<exclusion>
211+
<groupId>velocity</groupId>
212+
<artifactId>velocity</artifactId>
213+
</exclusion>
214+
</exclusions>
199215
</dependency>
200216

201217
<!-- other -->
@@ -237,7 +253,7 @@
237253
<dependency>
238254
<groupId>junit</groupId>
239255
<artifactId>junit</artifactId>
240-
<version>4.13.1</version>
256+
<version>4.13.2</version>
241257
<scope>test</scope>
242258
</dependency>
243259
</dependencies>

0 commit comments

Comments
 (0)