Package org.apache.maven.model

Examples of org.apache.maven.model.Resource


        final String ourRsrcPath = this.outputDirectory.getAbsolutePath();
        boolean found = false;
        @SuppressWarnings("unchecked")
        final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
        while (!found && rsrcIterator.hasNext()) {
            final Resource rsrc = rsrcIterator.next();
            found = rsrc.getDirectory().equals(ourRsrcPath);
        }
        if (!found) {
            final Resource resource = new Resource();
            resource.setDirectory(this.outputDirectory.getAbsolutePath());
            this.project.addResource(resource);
        }

    }
View Full Code Here


            // also scan for any "packageinfo" files lurking in the source folders
            List packageInfoIncludes = Collections.singletonList( "**/packageinfo" );
            for ( Iterator i = currentProject.getCompileSourceRoots().iterator(); i.hasNext(); )
            {
                String sourceRoot = ( String ) i.next();
                Resource packageInfoResource = new Resource();
                packageInfoResource.setDirectory( sourceRoot );
                packageInfoResource.setIncludes( packageInfoIncludes );
                resources.add( packageInfoResource );
            }
        }

        return resources;
View Full Code Here

        final String basePath = currentProject.getBasedir().getAbsolutePath();

        Set pathSet = new LinkedHashSet();
        for ( Iterator i = getMavenResources( currentProject, test ).iterator(); i.hasNext(); )
        {
            Resource resource = ( Resource ) i.next();

            final String sourcePath = resource.getDirectory();
            final String targetPath = resource.getTargetPath();

            // ignore empty or non-local resources
            if ( new File( sourcePath ).exists() && ( ( targetPath == null ) || ( targetPath.indexOf( ".." ) < 0 ) ) )
            {
                DirectoryScanner scanner = new DirectoryScanner();

                scanner.setBasedir( sourcePath );
                if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
                {
                    scanner.setIncludes( ( String[] ) resource.getIncludes().toArray( EMPTY_STRING_ARRAY ) );
                }
                else
                {
                    scanner.setIncludes( DEFAULT_INCLUDES );
                }

                if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() )
                {
                    scanner.setExcludes( ( String[] ) resource.getExcludes().toArray( EMPTY_STRING_ARRAY ) );
                }

                scanner.addDefaultExcludes();
                scanner.scan();

                List includedFiles = Arrays.asList( scanner.getIncludedFiles() );

                for ( Iterator j = includedFiles.iterator(); j.hasNext(); )
                {
                    String name = ( String ) j.next();
                    String path = sourcePath + '/' + name;

                    // make relative to project
                    if ( path.startsWith( basePath ) )
                    {
                        if ( path.length() == basePath.length() )
                        {
                            path = ".";
                        }
                        else
                        {
                            path = path.substring( basePath.length() + 1 );
                        }
                    }

                    // replace windows backslash with a slash
                    // this is a workaround for a problem with bnd 0.0.189
                    if ( File.separatorChar != '/' )
                    {
                        name = name.replace( File.separatorChar, '/' );
                        path = path.replace( File.separatorChar, '/' );
                    }

                    // copy to correct place
                    path = name + '=' + path;
                    if ( targetPath != null )
                    {
                        path = targetPath + '/' + path;
                    }

                    // use Bnd filtering?
                    if ( resource.isFiltering() )
                    {
                        path = '{' + path + '}';
                    }

                    pathSet.add( path );
View Full Code Here

            }
        };
        project.setGroupId( "group" );
        project.setArtifactId( "artifact" );
        project.setVersion( "1.1.0.0" );
        Resource r = new Resource();
        r.setDirectory( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
        r.setIncludes( Arrays.asList( "**/*.*" ) );
        project.addResource( r );
        project.addCompileSourceRoot( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );

        ManifestPlugin plugin = new ManifestPlugin();
        plugin.setBuildDirectory( "target/tmp/basedir/target" );
View Full Code Here

     */
    public static URI findObrXml( Collection resources )
    {
        for ( Iterator i = resources.iterator(); i.hasNext(); )
        {
            Resource resource = ( Resource ) i.next();
            File obrFile = new File( resource.getDirectory(), OBR_XML );
            if ( obrFile.exists() )
            {
                return obrFile.toURI();
            }
        }
View Full Code Here

        {
            return obrFile.toURI();
        }
        for ( Iterator i = project.getResources().iterator(); i.hasNext(); )
        {
            Resource resource = ( Resource ) i.next();
            obrFile = new File( resource.getDirectory(), OBR_XML );
            if ( obrFile.exists() )
            {
                return obrFile.toURI();
            }
        }
View Full Code Here

            try {
                PluginXmlUtil.writePluginMetadata(metadata, out);
            } finally {
                out.close();
            }
            Resource resource = new Resource();
            resource.setDirectory(targetDir.getPath());
            resource.addInclude(pluginMetadataFileName);
            getProject().getResources().add(resource);
        } catch (Exception e) {
            throw new MojoExecutionException("Could not create plugin metadata", e);
        }
    }
View Full Code Here

        Model model = new Model();

        Build build = new Build();
        build.setSourceDirectory( "correct" );

        Resource res = new Resource();
        res.setDirectory( "${project.build.sourceDirectory}" );

        build.addResource( res );

        Resource res2 = new Resource();
        res2.setDirectory( "${pom.build.sourceDirectory}" );

        build.addResource( res2 );

        Resource res3 = new Resource();
        res3.setDirectory( "${build.sourceDirectory}" );

        build.addResource( res3 );

        model.setBuild( build );
View Full Code Here

        assertEquals( basedirFile.getCanonicalPath(), testSourceDirectoryFile.getCanonicalPath().substring( 0, getBasedir().length() ) );

        Build build = project.getBuild();

        Resource resource = (Resource) build.getResources().get( 0 );

        assertTrue( resource.getDirectory().startsWith( getBasedir() ) );
    }
View Full Code Here

    public Resource prepareResources() throws TomcatConfigurationException
    {
        // noinspection unchecked
        includesList.add("*.war");

        Resource resource = new Resource();
        resource.setDirectory(getProjectBuildOutputDirectory());
        resource.setTargetPath(getTomcatConfiguration().getWebappsPath());
        //noinspection unchecked
        resource.setIncludes(includesList);
        //noinspection unchecked
        resource.setExcludes(excludesList);

        return resource;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.model.Resource

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.