Search in sources :

Example 1 with Mojo

use of org.apache.maven.plugin.Mojo in project byte-buddy by raphw.

the class ByteBuddyMojoTest method execute.

private void execute(String goal, String target) throws Exception {
    Mojo mojo = mojoRule.lookupMojo(goal, new File("src/test/resources/net/bytebuddy/test/" + target + ".pom.xml"));
    if (goal.equals("transform")) {
        mojoRule.setVariableValueToObject(mojo, "outputDirectory", project.getAbsolutePath());
        mojoRule.setVariableValueToObject(mojo, "compileClasspathElements", Collections.emptyList());
    } else if (goal.equals("transform-test")) {
        mojoRule.setVariableValueToObject(mojo, "testOutputDirectory", project.getAbsolutePath());
        mojoRule.setVariableValueToObject(mojo, "testClasspathElements", Collections.emptyList());
    } else {
        throw new AssertionError("Unknown goal: " + goal);
    }
    mojoRule.setVariableValueToObject(mojo, "repositorySystem", repositorySystem);
    mojoRule.setVariableValueToObject(mojo, "groupId", FOO);
    mojoRule.setVariableValueToObject(mojo, "artifactId", BAR);
    mojoRule.setVariableValueToObject(mojo, "version", QUX);
    mojo.setLog(new SilentLog());
    mojo.execute();
}
Also used : Mojo(org.apache.maven.plugin.Mojo) SilentLog(org.apache.maven.plugin.testing.SilentLog) File(java.io.File)

Example 2 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class TestSkip method doConfigTest.

private void doConfigTest(String mojoName, String configFile) throws Exception {
    File testPom = new File(getBasedir(), "target/test-classes/unit/skip-test/" + configFile);
    Mojo mojo = lookupMojo(mojoName, testPom);
    assertNotNull(mojo);
    CapturingLog log = new CapturingLog();
    mojo.setLog(log);
    mojo.execute();
    assertTrue(log.getContent().contains("Skipping plugin execution"));
}
Also used : Mojo(org.apache.maven.plugin.Mojo) File(java.io.File)

Example 3 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class BasicAbstractAssemblyMojoFeaturesTest method run.

private Mojo run(String pluginConfig, String mojoName) throws Exception {
    String pluginConfigResource = "basicAbstractAssemblyMojoFeaturesTest/" + pluginConfig;
    File pluginConfigFile = new File(getBasedir(), "src/test/plugin-configs/" + pluginConfigResource);
    assertTrue("Cannot find plugin-configuration: \'" + pluginConfigResource + "\' in context-classloader\'s classpath.", pluginConfigFile.exists());
    // TODO: Need to replace this with test-only mojos...
    Mojo mojo = (Mojo) lookupMojo(mojoName, pluginConfigFile.getAbsolutePath());
    FileLoggingArchiverManagerStub archiverManager = (FileLoggingArchiverManagerStub) getVariableValueFromObject(mojo, "archiverManager");
    archiverManager.clearArchiver();
    mojo.execute();
    return mojo;
}
Also used : Mojo(org.apache.maven.plugin.Mojo) File(java.io.File)

Example 4 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class BasicAbstractAssemblyMojoFeaturesTest method testOutputFileNameMapping.

public void testOutputFileNameMapping() throws Exception {
    String pluginConfig = "outputFileNameMapping-pluginConfig.xml";
    List requiredDependencies = new ArrayList();
    requiredDependencies.add("dependencies/test.jar");
    requiredDependencies.add("dependencies/test2.jar");
    Mojo mojo = run(pluginConfig, "directory-inline");
    assertFilesAdded(mojo, requiredDependencies);
}
Also used : Mojo(org.apache.maven.plugin.Mojo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with Mojo

use of org.apache.maven.plugin.Mojo in project maven-plugins by apache.

the class BasicAbstractAssemblyMojoFeaturesTest method testModuleSetSourceIncludedBinariesNotIncluded.

public void testModuleSetSourceIncludedBinariesNotIncluded() throws Exception {
    String pluginConfig = "moduleSetSourceIncludedBinariesNotIncluded-pluginConfig.xml";
    Mojo mojo = run(pluginConfig, "attached");
    List required = Collections.singletonList("sources/module1/src/main/java/org/test/module1/App.java");
    assertFilesAdded(mojo, required);
}
Also used : Mojo(org.apache.maven.plugin.Mojo) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Mojo (org.apache.maven.plugin.Mojo)10 File (java.io.File)8 CheckstyleViolationCheckMojo (org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1