Skip to content

Commit

Permalink
Making createMojo generic (was previously restricted to SetMojo)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmoniuk committed Aug 28, 2022
1 parent 22ef02f commit 9d954ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/test/java/org/codehaus/mojo/versions/SetMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureExcepti
@Test
public void testVersionlessDependency() throws Exception
{
SetMojo myMojo = createMojo( "set", "src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml" );
SetMojo myMojo =
(SetMojo) createMojo( "set", "src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml" );
myMojo.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.codehaus.mojo.versions.SetMojo;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

Expand Down Expand Up @@ -58,11 +58,11 @@ public abstract class BaseMojoTestCase extends AbstractMojoTestCase
* @return a Mojo instance
* @throws Exception thrown if mojo lookup fails
*/
protected SetMojo createMojo( String goal, String pomFilePath ) throws Exception
protected Mojo createMojo( String goal, String pomFilePath ) throws Exception
{
File pomFile = new File( pomFilePath );
SetMojo mojo = (SetMojo) lookupMojo( goal, pomFile );
mojo.setProject( new TestProjectStub( pomFile ) );
Mojo mojo = lookupMojo( goal, pomFile );
setVariableValueToObject( mojo, "project", new TestProjectStub( pomFile ) );
return mojo;
}

Expand Down

0 comments on commit 9d954ec

Please sign in to comment.