Package org.apache.maven.project

Examples of org.apache.maven.project.Resource


    }

    public void compileSchemas() throws Exception {
        List schemas = new ArrayList();
        File base = new File(sourceDir);
        Resource resource = new Resource();
        resource.setDirectory(sourceDir);
        resource.setTargetPath(baseSchemaLocation);
        for (StringTokenizer st = new StringTokenizer(sourceSchemas, ","); st.hasMoreTokens();) {
            String schemaName = st.nextToken();
            schemas.add(new File(base, schemaName));
            resource.addInclude(schemaName);
        }
        resources.add(resource);
        if (buildSchemas) {
            List configs = new ArrayList();
View Full Code Here


        //        </j:if>
        //      </j:forEach>

        for ( Iterator iter = resources.iterator(); iter.hasNext(); )
        {
            Resource resource = (Resource) iter.next();
            String directoryName = resource.getDirectory();
            if ( directoryName == null )
            {
                continue;
            }
            File directory = new File( directoryName );
            if ( directory.exists() && directory.isDirectory() && directory.canRead() )
            {
                StringBuffer targetDirectoryBuffer = new StringBuffer( todir );
                String targetPath = resource.getTargetPath();
                if ( targetPath != null && !"".equals( targetPath.trim() ) )
                {
                    targetDirectoryBuffer.append( '/' ).append( targetPath );
                }
                File targetDirectory = new File( targetDirectoryBuffer.toString() );
                // copy to targetDirectory....
                org.apache.tools.ant.taskdefs.Copy copyTask = new org.apache.tools.ant.taskdefs.Copy();
                copyTask.setProject( getMavenContext().getAntProject() );
                copyTask.setTodir( targetDirectory );
                copyTask.setPreserveLastModified( true );
                copyTask.setFiltering( resource.isFiltering() );
                copyTask.setOverwrite( resource.isFiltering() );
                FileSet fileSet = new FileSet();
                fileSet.setDir( directory );
                if ( resource.getIncludes().isEmpty() )
                {
                    PatternSet.NameEntry entry = fileSet.createInclude();
                    entry.setName( "**/**" );
                }
                // add includes
                for ( Iterator incIter = resource.getIncludes().iterator(); incIter.hasNext(); )
                {
                    String include = (String) incIter.next();
                    PatternSet.NameEntry entry = fileSet.createInclude();
                    entry.setName( include );
                }
                // add excludes
                for ( Iterator incIter = resource.getExcludes().iterator(); incIter.hasNext(); )
                {
                    String exclude = (String) incIter.next();
                    PatternSet.NameEntry entry = fileSet.createExclude();
                    entry.setName( exclude );
                }
View Full Code Here

        //        </j:if>
        //      </j:forEach>

        for ( Iterator iter = resources.iterator(); iter.hasNext(); )
        {
            Resource resource = (Resource) iter.next();
            String directoryName = resource.getDirectory();
            if ( directoryName == null )
            {
                continue;
            }
            File directory = new File( directoryName );
            if ( directory.exists() && directory.isDirectory() && directory.canRead() )
            {
                StringBuffer targetDirectoryBuffer = new StringBuffer( todir );
                String targetPath = resource.getTargetPath();
                if ( ( targetPath != null ) && !"".equals( targetPath.trim() ) )
                {
                    targetDirectoryBuffer.append( '/' ).append( targetPath );
                }
                File targetDirectory = new File( targetDirectoryBuffer.toString() );
                // copy to targetDirectory....
                org.apache.tools.ant.taskdefs.Copy copyTask = new org.apache.tools.ant.taskdefs.Copy();
                copyTask.setProject( getMavenContext().getAntProject() );
                copyTask.setTodir( targetDirectory );
                copyTask.setPreserveLastModified( true );
                copyTask.setFiltering( resource.isFiltering() );
                copyTask.setOverwrite( resource.isFiltering() );
                FileSet fileSet = new FileSet();
                fileSet.setDir( directory );
                if ( resource.getIncludes().isEmpty() )
                {
                    PatternSet.NameEntry entry = fileSet.createInclude();
                    entry.setName( "**/**" );
                }
                // add includes
                for ( Iterator incIter = resource.getIncludes().iterator(); incIter.hasNext(); )
                {
                    String include = (String) incIter.next();
                    PatternSet.NameEntry entry = fileSet.createInclude();
                    entry.setName( include );
                }
                // add excludes
                for ( Iterator incIter = resource.getExcludes().iterator(); incIter.hasNext(); )
                {
                    String exclude = (String) incIter.next();
                    PatternSet.NameEntry entry = fileSet.createExclude();
                    entry.setName( exclude );
                }
View Full Code Here

            {
                Element listElement = element;
                listElement = element.addElement( "resources" );
                for ( Iterator iter = build.getResources().iterator(); iter.hasNext(); )
                {
                    Resource o = (Resource) iter.next();
                    writeResource( o, "resource", listElement );
                }
            }
        }
    } //-- void writeBuild(Build, String, Element)
View Full Code Here

            {
                Element listElement = element;
                listElement = element.addElement( "resources" );
                for ( Iterator iter = buildBase.getResources().iterator(); iter.hasNext(); )
                {
                    Resource o = (Resource) iter.next();
                    writeResource( o, "resource", listElement );
                }
            }
        }
    } //-- void writeBuildBase(BuildBase, String, Element)
View Full Code Here

            {
                Element listElement = element;
                listElement = element.addElement( "resources" );
                for ( Iterator iter = unitTest.getResources().iterator(); iter.hasNext(); )
                {
                    Resource o = (Resource) iter.next();
                    writeResource( o, "resource", listElement );
                }
            }
            if ( unitTest.getIncludes() != null && unitTest.getIncludes().size() > 0 )
            {
View Full Code Here

     * @param parser
     */
    private Resource parseResource(String tagName, XmlPullParser parser, boolean strict, String encoding)
        throws IOException, XmlPullParserException
    {
        Resource resource = new Resource();
        resource.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( parser.getName().equals( "targetPath" )  )
            {
                if ( parsed.contains( "targetPath" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "targetPath" );
                resource.setTargetPath( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "filtering" )  )
            {
                if ( parsed.contains( "filtering" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "filtering" );
                resource.setFiltering( getBooleanValue( getTrimmedValue( parser.nextText()), "filtering", parser ) );
            }
            else if ( parser.getName().equals( "directory" )  )
            {
                if ( parsed.contains( "directory" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "directory" );
                resource.setDirectory( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "includes" )  )
            {
                if ( parsed.contains( "includes" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "includes" );
                java.util.List includes = new java.util.ArrayList();
                resource.setIncludes( includes );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "include" ) )
                    {
                        includes.add( getTrimmedValue( parser.nextText()) );
                    }
                    else
                    {
                        parser.nextText();
                    }
                }
            }
            else if ( parser.getName().equals( "excludes" )  )
            {
                if ( parsed.contains( "excludes" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "excludes" );
                java.util.List excludes = new java.util.ArrayList();
                resource.setExcludes( excludes );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "exclude" ) )
                    {
                        excludes.add( getTrimmedValue( parser.nextText()) );
View Full Code Here

            if ( build.getResources() != null && build.getResources().size() > 0 )
            {
                serializer.startTag( NAMESPACE, "resources" );
                for ( Iterator iter = build.getResources().iterator(); iter.hasNext(); )
                {
                    Resource o = (Resource) iter.next();
                    writeResource( o, "resource", serializer );
                }
                serializer.endTag( NAMESPACE, "resources" );
            }
            serializer.endTag( NAMESPACE, tagName );
View Full Code Here

            if ( buildBase.getResources() != null && buildBase.getResources().size() > 0 )
            {
                serializer.startTag( NAMESPACE, "resources" );
                for ( Iterator iter = buildBase.getResources().iterator(); iter.hasNext(); )
                {
                    Resource o = (Resource) iter.next();
                    writeResource( o, "resource", serializer );
                }
                serializer.endTag( NAMESPACE, "resources" );
            }
            serializer.endTag( NAMESPACE, tagName );
View Full Code Here

            if ( unitTest.getResources() != null && unitTest.getResources().size() > 0 )
            {
                serializer.startTag( NAMESPACE, "resources" );
                for ( Iterator iter = unitTest.getResources().iterator(); iter.hasNext(); )
                {
                    Resource o = (Resource) iter.next();
                    writeResource( o, "resource", serializer );
                }
                serializer.endTag( NAMESPACE, "resources" );
            }
            if ( unitTest.getIncludes() != null && unitTest.getIncludes().size() > 0 )
View Full Code Here

TOP

Related Classes of org.apache.maven.project.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.