Examples of MavenProjectResourcesStub


Examples of org.apache.maven.plugin.resources.stub.MavenProjectResourcesStub

    public void testResourceInclude()
        throws Exception
    {
        File testPom = new File( getBasedir(), defaultPomFilePath );
        ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
        MavenProjectResourcesStub project = new MavenProjectResourcesStub( "resourceInclude" );
        List resources = project.getBuild().getResources();

        assertNotNull( mojo );

        project.addFile( "file1.include" );
        project.addFile( "file2.exclude" );
        project.addFile( "file3.nottest" );
        project.addFile( "file4.txt" );
        project.addFile( "package/file1.include" );
        project.addFile( "package/file2.exclude" );
        project.addFile( "package/file3.nottest" );
        project.addFile( "package/file4.txt" );
        project.addFile( "notpackage/file1.include" );
        project.addFile( "notpackage/file2.exclude" );
        project.addFile( "notpackage/file3.nottest" );
        project.addFile( "notpackage/file4.txt" );
        project.addFile( "package/test/file1.txt" );
        project.addFile( "package/nottest/file2.txt" );
        project.addFile( "notpackage/test/file1.txt" );
        project.addFile( "notpackage/nottest/file.txt" );
        project.setupBuildEnvironment();

        project.addInclude( "*.include" );
        project.addInclude( "**/test" );
        project.addInclude( "**/test/file*" );
        project.addInclude( "**/package/*.include" );

        setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
        setVariableValueToObject( mojo, "project", project );
        setVariableValueToObject( mojo, "resources", resources );
        setVariableValueToObject( mojo, "buildFilters", new LinkedList() );
        setVariableValueToObject( mojo, "useBuildFilters", Boolean.TRUE );
        mojo.execute();

        String resourcesDir = project.getOutputDirectory();

        assertTrue( FileUtils.fileExists( resourcesDir + "/package/test" ) );
        assertTrue( FileUtils.fileExists( resourcesDir + "/file1.include" ) );
        assertTrue( FileUtils.fileExists( resourcesDir + "/package/file1.include" ) );
        assertFalse( FileUtils.fileExists( resourcesDir + "/notpackage/file1.include" ) );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.