Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.Mojo


    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"));
    }
View Full Code Here


    }

    public void testAttachedMojo()
        throws Exception
    {
        Mojo mojo = lookupMojo( "attached", basedir + "/src/test/plugin-configs/attached/min-plugin-config.xml" );

        mojo.execute();

        assertTrue( "Test an archive was created", ArchiverManagerStub.archiverStub.getDestFile().exists() );
    }
View Full Code Here

        List requiredDependencies = new ArrayList();
       
        requiredDependencies.add( "dependencies/test.jar" );
        requiredDependencies.add( "dependencies/test2.jar" );
       
        Mojo mojo = run( pluginConfig, "directory-inline" );
        assertFilesAdded( mojo, requiredDependencies );
    }
View Full Code Here

   
    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 );
    }
View Full Code Here

        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;
    }
View Full Code Here

    }

    public void testAttachedMojoDependencySet()
        throws Exception
    {
        Mojo mojo = lookupMojo( "attached", basedir + "/src/test/plugin-configs/attached/depSet-plugin-config.xml" );

        mojo.execute();

        MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
        Set artifactSet = project.getArtifacts();

        Map archiveMap = ArchiverManagerStub.archiverStub.getFiles();
View Full Code Here

    public void testReportWithWrongUrl()
        throws Exception
    {
        File pluginXmlFile = new File( getBasedir(), "src/test/resources/plugin-configs/"
                + "scm-wrong-url-plugin-config.xml" );
        Mojo mojo = lookupMojo( "scm", pluginXmlFile );
        assertNotNull( "Mojo found.", mojo );

        setVariableValueToObject( mojo, "anonymousConnection", "scm:svn" );
        try
        {
            mojo.execute();
            assertTrue( "IllegalArgumentException NOT catched", false );
        }
        catch ( IllegalArgumentException e )
        {
            assertTrue( "IllegalArgumentException catched", true );
        }

        tearDown();
        setUp();

        mojo = lookupMojo( "scm", pluginXmlFile );
        assertNotNull( "Mojo found.", mojo );
        setVariableValueToObject( mojo, "anonymousConnection", "scm:svn:http" );
        try
        {
            mojo.execute();
            assertTrue( "IllegalArgumentException NOT catched", false );
        }
        catch ( Exception e )
        {
            assertTrue( "IllegalArgumentException catched", true );
        }

        tearDown();
        setUp();

        mojo = lookupMojo( "scm", pluginXmlFile );
        assertNotNull( "Mojo found.", mojo );
        setVariableValueToObject( mojo, "anonymousConnection", "scm" );
        try
        {
            mojo.execute();
            assertTrue( "IllegalArgumentException NOT catched", false );
        }
        catch ( Exception e )
        {
            assertTrue( "IllegalArgumentException catched", true );
View Full Code Here

    public void testInvalidFormat()
        throws Exception
    {
        File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );

        Mojo mojo = lookupMojo( "check", pluginXmlFile );

        assertNotNull( "Mojo found.", mojo );

        mojoSetup( mojo );
       
        setVariableValueToObject( mojo, "outputFileFormat", "plain" );

        try
        {
            mojo.execute();

            fail( "Must throw an exception invalid format: plain" );
        }
        catch ( MojoExecutionException e )
        {
View Full Code Here

    public void testNoOutputFile()
        throws Exception
    {
        File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );

        Mojo mojo = lookupMojo( "check", pluginXmlFile );

        assertNotNull( "Mojo found.", mojo );

        mojoSetup( mojo );
       
        setVariableValueToObject( mojo, "outputFile", new File( "target/NoSuchFile.xml" ) );

        mojo.execute();
    }
View Full Code Here

    public void testNoFail()
        throws Exception
    {
        File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/check-plugin-config.xml" );

        Mojo mojo = lookupMojo( "check", pluginXmlFile );

        assertNotNull( "Mojo found.", mojo );

        mojoSetup( mojo );
       
        setVariableValueToObject( mojo, "failOnViolation", Boolean.FALSE );

        mojo.execute();
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.Mojo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.