Package org.apache.maven.model

Examples of org.apache.maven.model.Resource


    public static void mergeResourceLists( List childResources, List parentResources )
    {
        for ( Iterator i = parentResources.iterator(); i.hasNext(); )
        {
            Resource r = (Resource) i.next();
            if ( !childResources.contains( r ) )
            {
                childResources.add( r );
            }
        }
View Full Code Here


    {
        if ( resources != null )
        {
            for ( Iterator i = resources.iterator(); i.hasNext(); )
            {
                Resource resource = (Resource) i.next();
                if ( resource.isFiltering() )
                {
                    return true;
                }
            }
        }
View Full Code Here

            File outputFile = new File(dir, "template-suite.xml");
            outputFile.createNewFile();
            Writer writer = new FileWriter(outputFile);
            xstream.toXML(suite, writer);
            writer.close();
            Resource resource = new Resource();
            resource.setDirectory(outputDirectory.getAbsolutePath());
            project.addResource(resource);
        } catch (InclusionScanException e) {
            throw new MojoExecutionException("error", e);
        } catch (IOException e) {
            throw new MojoExecutionException("error", e);
View Full Code Here

            propsStream.close();
            TemplateGenerator generator = createTemplateGeneratorFactory(
                    new VelocityEngine(props)).createTemplateGenerator();
            generator.generate(packageName, suite, getParameters(), getRuntimeClass(), requestClass);
            if (generator.isGeneratingResources()) {
                Resource resource = new Resource();
                resource.setDirectory(resourcesOutputDirectory.getAbsolutePath());
                project.addResource(resource);
            }
            if (generator.isGeneratingClasses()) {
                project.addCompileSourceRoot(classesOutputDirectory.getAbsolutePath());
            }
View Full Code Here

                              File workspaceProjectBaseDir, boolean test, final String output )
        throws MojoExecutionException
    {
        for ( Iterator it = resources.iterator(); it.hasNext(); )
        {
            Resource resource = (Resource) it.next();

            getLog().debug( "Processing resource dir: " + resource.getDirectory() );

            String includePattern = null;
            String excludePattern = null;

            if ( resource.getIncludes().size() != 0 )
            {
                includePattern = StringUtils.join( resource.getIncludes().iterator(), "|" );
            }

            if ( resource.getExcludes().size() != 0 )
            {
                excludePattern = StringUtils.join( resource.getExcludes().iterator(), "|" );
            }

            // TODO: figure out how to merge if the same dir is specified twice
            // with different in/exclude patterns.

            File resourceDirectory = new File( /* basedir, */resource.getDirectory() );

            if ( !resourceDirectory.exists() || !resourceDirectory.isDirectory() )
            {
                getLog().debug( "Resource dir: " + resourceDirectory + " either missing or not a directory." );
                continue;
            }

            String resourceDir =
                IdeUtils.toRelativeAndFixSeparator( workspaceProjectBaseDir, resourceDirectory,
                                                    !workspaceProjectBaseDir.equals( basedir ) );
            String thisOutput = output;
            if ( thisOutput != null )
            {
                // sometimes thisOutput is already an absolute path
                File outputFile = new File( thisOutput );
                if ( !outputFile.isAbsolute() )
                {
                    outputFile = new File( workspaceProjectBaseDir, thisOutput );
                }
                // create output dir if it doesn't exist
                outputFile.mkdirs();

                if ( !StringUtils.isEmpty( resource.getTargetPath() ) )
                {
                    outputFile = new File( outputFile, resource.getTargetPath() );
                    // create output dir if it doesn't exist
                    outputFile.mkdirs();
                }

                getLog().debug(
                                "Making relative and fixing separator: { " + workspaceProjectBaseDir + ", " +
                                    outputFile + ", false }." );
                thisOutput = IdeUtils.toRelativeAndFixSeparator( workspaceProjectBaseDir, outputFile, false );
            }

            getLog().debug(
                            "Adding eclipse source dir: { " + resourceDir + ", " + thisOutput + ", true, " + test +
                                ", " + includePattern + ", " + excludePattern + " }." );

            directories.add( new EclipseSourceDir( resourceDir, thisOutput, true, test, includePattern, excludePattern,
                                                   resource.isFiltering() ) );
        }
    }
View Full Code Here

     */
    private boolean areSourcesStale() throws MojoExecutionException {
        List<Resource> resources = new ArrayList<Resource>();
        for (String root: (List<String>)project.getCompileSourceRoots()) {
            if (new File(root).exists()) {
                Resource resource = new Resource();
                resource.setDirectory(root);
                resource.addInclude("*.java");
                resources.add(resource);
            }
        }
        return areStale(resources, project.getBuild().getOutputDirectory());
    }
View Full Code Here

     */
    private boolean areTestSourcesStale() throws MojoExecutionException {
        List<Resource> resources = new ArrayList<Resource>();
        for (String root: (List<String>)project.getTestCompileSourceRoots()) {
            if (new File(root).exists()) {
                Resource resource = new Resource();
                resource.setDirectory(root);
                resources.add(resource);
            }
        }
        return areStale(resources, project.getBuild().getTestOutputDirectory());
    }
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

        projectBuilder.calculateConcreteState( project, config );

        Build build = project.getBuild();

        Resource r = new Resource();
        r.setDirectory( "myDir" );

        build.addResource( r );

        List resources = build.getResources();
        assertNotNull( "Concrete resources should not be null.", resources );
View Full Code Here

        if ( resources != null )
        {
            for ( Iterator it = resources.iterator(); it.hasNext(); )
            {
                Resource resource = (Resource) it.next();
                if ( new File( directory ).getAbsolutePath().equals(
                                                                     new File( resource.getDirectory() ).getAbsolutePath() ) )
                {
                    found = true;
                    break;
                }
            }
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.