@@ -87,16 +87,14 @@ public void test2xStylePlugin()
87
87
{
88
88
String pluginXml = "META-INF/maven/plugin-2.1.xml" ;
89
89
90
- List <String > messages = run ( pluginXml , true );
90
+ List <String > messages = run ( pluginXml );
91
91
92
- assertPresence ( messages , "Unpacked Ant build scripts (in Maven build directory)." , false );
93
- assertPresence ( messages , "Maven parameter expression evaluator for Ant properties." , false );
94
- assertPresence ( messages , "Maven standard project-based classpath references." , false );
95
- assertPresence ( messages , "Maven standard plugin-based classpath references." , false );
96
- assertPresence ( messages ,
97
- "Maven project, session, mojo-execution, or path-translation parameter information is" , false );
98
- assertPresence ( messages , "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" ,
99
- false );
92
+ assertPresence ( messages , "Unpacked Ant build scripts (in Maven build directory)." );
93
+ assertPresence ( messages , "Maven parameter expression evaluator for Ant properties." );
94
+ assertPresence ( messages , "Maven standard project-based classpath references." );
95
+ assertPresence ( messages , "Maven standard plugin-based classpath references." );
96
+ assertPresence ( messages , "Maven project, session, mojo-execution, or path-translation parameter information is" );
97
+ assertPresence ( messages , "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" );
100
98
101
99
ArgumentCaptor <BuildEvent > buildEvent = ArgumentCaptor .forClass (BuildEvent .class );
102
100
verify ( buildListener , atLeastOnce () ).messageLogged ( buildEvent .capture () );
@@ -106,52 +104,19 @@ public void test2xStylePlugin()
106
104
assertThat ( buildEvent .getValue ().getMessage (), endsWith ( ".test.jar" ) );
107
105
}
108
106
109
- @ Test
110
- public void test20StylePlugin ()
111
- throws PlexusConfigurationException , IOException , ComponentInstantiationException , MojoExecutionException ,
112
- ComponentConfigurationException , ArchiverException , URISyntaxException
113
- {
114
- String pluginXml = "META-INF/maven/plugin-2.0.xml" ;
115
-
116
- List <String > messages = run ( pluginXml , false );
117
-
118
- assertPresence ( messages , "Unpacked Ant build scripts (in Maven build directory)." , true );
119
- assertPresence ( messages , "Maven parameter expression evaluator for Ant properties." , true );
120
- assertPresence ( messages , "Maven standard project-based classpath references." , true );
121
- assertPresence ( messages , "Maven standard plugin-based classpath references." , true );
122
- assertPresence ( messages ,
123
- "Maven project, session, mojo-execution, or path-translation parameter information is" , true );
124
- assertPresence ( messages , "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" , true );
125
-
126
- ArgumentCaptor <BuildEvent > buildEvent = ArgumentCaptor .forClass (BuildEvent .class );
127
- verify ( buildListener , atLeastOnce () ).messageLogged ( buildEvent .capture () );
128
-
129
- // last message
130
- assertThat ( buildEvent .getValue ().getMessage (), startsWith ( "plugin classpath is: " ) );
131
- assertThat ( buildEvent .getValue ().getMessage (), endsWith ( "path-is-missing" ) );
132
- }
133
-
134
- private void assertPresence ( List <String > messages , String test , boolean shouldBePresent )
107
+ private void assertPresence ( List <String > messages , String test )
135
108
{
136
109
for ( String message : messages )
137
110
{
138
111
if ( message .contains ( test ) )
139
112
{
140
- if ( !shouldBePresent )
141
- {
142
- fail ( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
143
- }
113
+ fail ( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
144
114
return ;
145
115
}
146
116
}
147
-
148
- if ( shouldBePresent )
149
- {
150
- fail ( "Test string: '" + test + "' was NOT found in output, but SHOULD BE THERE." );
151
- }
152
117
}
153
118
154
- private List <String > run ( String pluginXml , boolean includeImplied )
119
+ private List <String > run ( String pluginXml )
155
120
throws PlexusConfigurationException , IOException , ComponentInstantiationException , MojoExecutionException ,
156
121
ComponentConfigurationException , ArchiverException , URISyntaxException
157
122
{
@@ -185,43 +150,40 @@ private List<String> run( String pluginXml, boolean includeImplied )
185
150
Artifact artifact = mock ( Artifact .class );
186
151
PathTranslator pt = mock ( PathTranslator .class );
187
152
188
- if ( includeImplied )
189
- {
190
- File pluginXmlFile = Paths .get ( resource .toURI () ).toFile ();
153
+ File pluginXmlFile = Paths .get ( resource .toURI () ).toFile ();
191
154
192
- File jarFile = File .createTempFile ( "AntMojoWrapperTest." , ".test.jar" );
193
- jarFile .deleteOnExit ();
155
+ File jarFile = File .createTempFile ( "AntMojoWrapperTest." , ".test.jar" );
156
+ jarFile .deleteOnExit ();
194
157
195
- JarArchiver archiver = new JarArchiver ();
196
- archiver .enableLogging ( new ConsoleLogger ( Logger .LEVEL_ERROR , "archiver" ) );
197
- archiver .setDestFile ( jarFile );
198
- archiver .addFile ( pluginXmlFile , pluginXml );
199
- archiver .createArchive ();
158
+ JarArchiver archiver = new JarArchiver ();
159
+ archiver .enableLogging ( new ConsoleLogger ( Logger .LEVEL_ERROR , "archiver" ) );
160
+ archiver .setDestFile ( jarFile );
161
+ archiver .addFile ( pluginXmlFile , pluginXml );
162
+ archiver .createArchive ();
200
163
201
- when ( artifact .getFile () ).thenReturn ( jarFile );
164
+ when ( artifact .getFile () ).thenReturn ( jarFile );
202
165
203
- Model model = new Model ();
166
+ Model model = new Model ();
204
167
205
- Build build = new Build ();
206
- build .setDirectory ( "target" );
168
+ Build build = new Build ();
169
+ build .setDirectory ( "target" );
207
170
208
- model .setBuild ( build );
171
+ model .setBuild ( build );
209
172
210
- MavenProject project = new MavenProject ( model );
211
- project .setFile ( new File ( "pom.xml" ).getAbsoluteFile () );
173
+ MavenProject project = new MavenProject ( model );
174
+ project .setFile ( new File ( "pom.xml" ).getAbsoluteFile () );
212
175
213
- pd .setPluginArtifact ( artifact );
214
- pd .setArtifacts ( Collections .singletonList ( artifact ) );
176
+ pd .setPluginArtifact ( artifact );
177
+ pd .setArtifacts ( Collections .singletonList ( artifact ) );
215
178
216
- config .put ( "project" , project );
217
- config .put ( "session" , new MavenSession ( null , null , null , null , null , null , null , null , null , null ) );
218
- config .put ( "mojoExecution" , new MojoExecution ( md ) );
179
+ config .put ( "project" , project );
180
+ config .put ( "session" , new MavenSession ( null , null , null , null , null , null , null , null , null , null ) );
181
+ config .put ( "mojoExecution" , new MojoExecution ( md ) );
219
182
220
- ComponentRequirement cr = new ComponentRequirement ();
221
- cr .setRole ( PathTranslator .class .getName () );
183
+ ComponentRequirement cr = new ComponentRequirement ();
184
+ cr .setRole ( PathTranslator .class .getName () );
222
185
223
- wrapper .addComponentRequirement ( cr , pt );
224
- }
186
+ wrapper .addComponentRequirement ( cr , pt );
225
187
226
188
wrapper .setComponentConfiguration ( config );
227
189
@@ -251,15 +213,15 @@ private List<String> run( String pluginXml, boolean includeImplied )
251
213
messages .addAll ( tbl .messages );
252
214
}
253
215
254
- messages .add ( new String ( baos .toByteArray () ) );
216
+ messages .add ( baos .toString ( ) );
255
217
256
218
return messages ;
257
219
}
258
220
259
221
private static final class TestBuildListener
260
222
implements BuildListener
261
223
{
262
- private List <String > messages = new ArrayList <>();
224
+ private final List <String > messages = new ArrayList <>();
263
225
264
226
public void buildFinished ( BuildEvent arg0 )
265
227
{
0 commit comments