Search in sources :

Example 1 with DefaultBuildContext

use of org.sonatype.plexus.build.incremental.DefaultBuildContext in project querydsl by querydsl.

the class CompileMojoTest method test.

@Test
public void test() throws Exception {
    new File("target/compile-mojo").mkdir();
    MavenProject mavenProject = new MavenProject();
    mavenProject.getBuild().setOutputDirectory("target/compile-mojo");
    CompileMojo mojo = new CompileMojo();
    mojo.setBuildContext(new DefaultBuildContext());
    mojo.setProject(mavenProject);
    mojo.setSourceFolder(new File("src/test/java"));
    mojo.execute();
}
Also used : DefaultBuildContext(org.sonatype.plexus.build.incremental.DefaultBuildContext) MavenProject(org.apache.maven.project.MavenProject) File(java.io.File) Test(org.junit.Test)

Example 2 with DefaultBuildContext

use of org.sonatype.plexus.build.incremental.DefaultBuildContext in project sling by apache.

the class ValidateMojoTest method getMojo.

private ValidateMojo getMojo(File baseDir, String pomFile) throws Exception {
    SilentLog log = new SilentLog();
    DefaultBuildContext buildContext = new DefaultBuildContext();
    File pom = new File(baseDir, pomFile);
    ValidateMojo validateMojo = new ValidateMojo();
    mojoRule.configureMojo(validateMojo, mojoRule.extractPluginConfiguration("htl-maven-plugin", pom));
    MavenProject mavenProject = new ProjectStub(pom);
    mojoRule.setVariableValueToObject(validateMojo, "project", mavenProject);
    validateMojo.setLog(log);
    buildContext.enableLogging(log);
    validateMojo.setBuildContext(buildContext);
    return validateMojo;
}
Also used : DefaultBuildContext(org.sonatype.plexus.build.incremental.DefaultBuildContext) MavenProject(org.apache.maven.project.MavenProject) SilentLog(org.apache.maven.plugin.testing.SilentLog) File(java.io.File)

Example 3 with DefaultBuildContext

use of org.sonatype.plexus.build.incremental.DefaultBuildContext in project hibernate-orm by hibernate.

the class MavenEnhancePluginTest method testEnhancePlugin.

@Test
public void testEnhancePlugin() throws Exception {
    File baseDir = new File("target/classes/test");
    URL[] baseURLs = { baseDir.toURI().toURL() };
    MavenEnhancePlugin plugin = new MavenEnhancePlugin();
    Map<String, Object> pluginContext = new HashMap<>();
    pluginContext.put("project", new MavenProject());
    setVariableValueToObject(plugin, "pluginContext", pluginContext);
    setVariableValueToObject(plugin, "buildContext", new DefaultBuildContext());
    setVariableValueToObject(plugin, "base", baseDir.getAbsolutePath());
    setVariableValueToObject(plugin, "dir", baseDir.getAbsolutePath());
    setVariableValueToObject(plugin, "failOnError", true);
    setVariableValueToObject(plugin, "enableLazyInitialization", true);
    setVariableValueToObject(plugin, "enableDirtyTracking", true);
    setVariableValueToObject(plugin, "enableAssociationManagement", true);
    setVariableValueToObject(plugin, "enableExtendedEnhancement", false);
    plugin.execute();
    try (URLClassLoader classLoader = new URLClassLoader(baseURLs, getClass().getClassLoader())) {
        Assert.assertTrue(declaresManaged(classLoader.loadClass(ParentEntity.class.getName())));
        Assert.assertTrue(declaresManaged(classLoader.loadClass(ChildEntity.class.getName())));
        Assert.assertTrue(declaresManaged(classLoader.loadClass(TestEntity.class.getName())));
    }
}
Also used : HashMap(java.util.HashMap) URL(java.net.URL) DefaultBuildContext(org.sonatype.plexus.build.incremental.DefaultBuildContext) MavenProject(org.apache.maven.project.MavenProject) URLClassLoader(java.net.URLClassLoader) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)3 MavenProject (org.apache.maven.project.MavenProject)3 DefaultBuildContext (org.sonatype.plexus.build.incremental.DefaultBuildContext)3 Test (org.junit.Test)2 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 HashMap (java.util.HashMap)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1