Package org.apache.maven.model

Examples of org.apache.maven.model.FileSet


    {
        final String[] emptyStrArray = {};

        for (Resource resource : resources)
        {
            FileSet fileSet = new FileSet();
            fileSet.setDirectory(resource.getDirectory());

            for (Object include : resource.getIncludes())
                fileSet.addInclude((String) include);

            for (Object exclude : resource.getExcludes())
                fileSet.addExclude((String) exclude);

            File resourceDirectory = new File(fileSet.getDirectory());
            if (!resourceDirectory.isAbsolute())
                resourceDirectory = new File(resourceDirectory.getPath());

            if (!resourceDirectory.exists())
            {
                log.info("Additional resource directory does not exist: " + resourceDirectory);
                continue;
            }

            DirectoryScanner scanner = new DirectoryScanner();

            scanner.setBasedir(resourceDirectory);
            if (fileSet.getIncludes() != null && !fileSet.getIncludes().isEmpty())
                //noinspection unchecked
                scanner.setIncludes((String[]) fileSet.getIncludes().toArray(emptyStrArray));
            else
                scanner.setIncludes(DEFAULT_INCLUDES);

            if (fileSet.getExcludes() != null && !fileSet.getExcludes().isEmpty())
                //noinspection unchecked
                scanner.setExcludes((String[]) fileSet.getExcludes().toArray(emptyStrArray));

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

            List includedFiles = Arrays.asList(scanner.getIncludedFiles());
View Full Code Here


    private String[] findArtifacts(String path) throws MojoExecutionException
    {
        DirectoryScanner scanner = new DirectoryScanner();

        FileSet fileSet = new FileSet();
        fileSet.setDirectory(path);

        if (policy.toLowerCase().equals("snapshot"))
        {
            prepareInclusionSet(fileSet);
            // fileSet.addInclude(SNAPSHOT_JARS);
            // fileSet.addInclude(SNAPSHOT_WARS);
            prepareExclusionSet(fileSet);
        }
        else
        {
            prepareInclusionSet(fileSet);
            prepareExclusionSet(fileSet);

            fileSet.addExclude(SNAPSHOT_JARS);
            fileSet.addExclude(SNAPSHOT_WARS);
        }

        // Include default artifact types:
        // fileSet.addInclude(INCLUDES_JARS);
        // fileSet.addInclude(INCLUDES_WARS);

        File resourceDirectory = new File(fileSet.getDirectory());
        String[] finalIncludes = new String[fileSet.getIncludes().size()];
        String[] finalExcludes = new String[fileSet.getExcludes().size()];

        finalIncludes = fileSet.getIncludes().toArray(finalIncludes);
        finalExcludes = fileSet.getExcludes().toArray(finalExcludes);

        System.out.println("Includes: " + Arrays.toString(finalIncludes));
        System.out.println("Excludes: " + Arrays.toString(finalExcludes));

        scanner.setBasedir(resourceDirectory);
        scanner.setIncludes(finalIncludes);

        if (fileSet.getExcludes() != null && !fileSet.getExcludes().isEmpty())
            scanner.setExcludes(finalExcludes);

        scanner.addDefaultExcludes();
        scanner.scan();
View Full Code Here

     */
    public List<File> getFiles() throws IOException {
      if(null==files){
            files = new ArrayList<File>();
            files.addAll(orderedFiles);
            FileSet set = getFileSet();
            if (set != null) {
                List<File> fileSetFiles = FileUtilities.getFilesFromFileSet(set);
                fileSetFiles.removeAll(orderedFiles);
            files.addAll(fileSetFiles);
            }
View Full Code Here

     * @return FileSet
     */
    private FileSet parseFileSet( String tagName, XmlPullParser parser, boolean strict )
        throws IOException, XmlPullParserException
    {
        FileSet fileSet = new FileSet();
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( checkFieldWithDuplicate( parser, "directory", null, parsed ) )
            {
                fileSet.setDirectory( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
            {
                java.util.List includes = new java.util.ArrayList/*<String>*/();
                fileSet.setIncludes( includes );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "include" ) )
                    {
                        includes.add( getTrimmedValue( parser.nextText() ) );
                    }
                    else if ( strict )
                    {
                        throw new XmlPullParserException( "Unrecognised association: '" + parser.getName() + "'", parser, null );
                    }
                    else
                    {
                        // swallow up to end tag since this is not valid
                        while ( parser.next() != XmlPullParser.END_TAG ) {}
                    }
                }
            }
            else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
            {
                java.util.List excludes = new java.util.ArrayList/*<String>*/();
                fileSet.setExcludes( excludes );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "exclude" ) )
                    {
                        excludes.add( getTrimmedValue( parser.nextText() ) );
View Full Code Here

    protected void buildFileMap()
    {
        for ( int i = 0; i < filesets.length; i++ )
        {
            FileSet fs = filesets[ i ];
            DirectoryScanner ds = new DirectoryScanner();
            ds.setBasedir( fs.getDirectory() );
            if ( fs.getIncludes().size() > 0 )
            {
                ds.setIncludes( (String[]) fs.getIncludes().toArray( new String[0] ) );
            }
            if ( fs.getExcludes().size() > 0 )
            {
                ds.setExcludes( (String[]) fs.getExcludes().toArray( new String[0] ) );
            }
            ds.scan();
            String[] srcFiles = ds.getIncludedFiles();
            buildFileMap( new File( fs.getDirectory() ), srcFiles );
        }
    }
View Full Code Here

        }
    }

    protected FileSet[] createDefaultFileset()
    {
        FileSet[] defaultFileSet = new FileSet[] {new FileSet()};
        List defaultPatternList = new ArrayList();
       
        defaultPatternList.add(defaultIncludes);
        defaultFileSet[0].setIncludes(defaultPatternList);
        defaultFileSet[0].setDirectory(baseDir);
View Full Code Here

     * @param parser
     */
    private FileSet parseFileSet(String tagName, XmlPullParser parser, boolean strict, String encoding)
        throws IOException, XmlPullParserException
    {
        FileSet fileSet = new FileSet();
        fileSet.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( parser.getName().equals( "directory" )  )
            {
                if ( parsed.contains( "directory" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "directory" );
                fileSet.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();
                fileSet.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();
                fileSet.setExcludes( excludes );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "exclude" ) )
                    {
                        excludes.add( getTrimmedValue( parser.nextText()) );
View Full Code Here

    protected List<String> getTestClasses()
    {
        getLog().debug( "Scanning for tests at " + testCompileSourceRoots + " for " + includeTestFiles + " but "
                            + excludeTestFiles );

        FileSet fs = new FileSet();
        fs.setIncludes( includeTestFiles );
        fs.setExcludes( excludeTestFiles );
        List<String> testClasses = filterClasses( asList( fs ), files( testCompileSourceRoots ) );

        getLog().debug( "Test classes: " + testClasses );

        return testClasses;
View Full Code Here

        }

        List<FileSet> sets = new ArrayList<FileSet>();
        for ( File file : files )
        {
            FileSet fs = new FileSet();
            fs.setDirectory( PathUtil.path( file ) );
            fs.addInclude( "**/*.as" );
            fs.addInclude( "**/*.mxml" );
            sets.add( fs );
        }

        return sets;
    }
View Full Code Here

     * @param element
     */
    private FileSet parseFileSet(String tagName, Element element, boolean strict, String encoding)
        throws IOException, DocumentException
    {
        FileSet fileSet = new FileSet();
        fileSet.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
        {
            Node node = (Node) i.next();
            if ( node.getNodeType() != Node.ELEMENT_NODE )
            {
            }
            else
            {
                Element childElement = (Element) node;
                if ( childElement.getName().equals( "directory" )  )
                {
                    if ( parsed.contains( "directory" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "directory" );
                    fileSet.setDirectory( getTrimmedValue( childElement.getText() ) );
                }
                else if ( childElement.getName().equals( "includes" )  )
                {
                    if ( parsed.contains( "includes" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "includes" );
                    java.util.List includes = new java.util.ArrayList();
                    fileSet.setIncludes( includes );
                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
                    {
                        Node n = (Node) j.next();
                        if ( n.getNodeType() != Node.ELEMENT_NODE )
                        {
                        }
                        else
                        {
                            Element listElement = (Element) n;
                            if ( listElement.getName().equals( "include" ) )
                            {
                                includes.add( getTrimmedValue( listElement.getText() ) );
                            }
                            else
                            {
                            }
                        }
                    }
                }
                else if ( childElement.getName().equals( "excludes" )  )
                {
                    if ( parsed.contains( "excludes" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "excludes" );
                    java.util.List excludes = new java.util.ArrayList();
                    fileSet.setExcludes( excludes );
                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
                    {
                        Node n = (Node) j.next();
                        if ( n.getNodeType() != Node.ELEMENT_NODE )
                        {
View Full Code Here

TOP

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

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.