Package org.apache.maven.model

Examples of org.apache.maven.model.Resource


            Iterator<?> resourceItr = build.getResources().iterator();

            while ( resourceItr.hasNext() )
            {
                Resource resource = (Resource) resourceItr.next();

                String resourceDirectory = resource.getDirectory();

                resourceDirectory = StringUtils.replace( resourceDirectory, "\\", "/" );

                FileUtils.mkdir( getOutputDirectory( outputDirectory, resourceDirectory ) );
            }
        }
        // create test source directory if specified in POM
        if ( foundBuildElement && null != build.getTestSourceDirectory() )
        {
            getLogger().debug( "Overriding default test directory " );

            overrideTestSrcDir = true;

            String testDirectory = build.getTestSourceDirectory();

            testDirectory = StringUtils.replace( testDirectory, "\\", "/" );

            FileUtils.mkdir( getOutputDirectory( outputDirectory, testDirectory ) );
        }

        // create test resource directory if specified in POM
        if ( foundBuildElement && build.getTestResources().size() > 0 )
        {
            getLogger().debug( "Overriding default test resource directory " );

            overrideTestResourceDir = true;

            Iterator<?> testResourceItr = build.getTestResources().iterator();

            while ( testResourceItr.hasNext() )
            {
                Resource resource = (Resource) testResourceItr.next();

                String testResourceDirectory = resource.getDirectory();

                testResourceDirectory = StringUtils.replace( testResourceDirectory, "\\", "/" );

                FileUtils.mkdir( getOutputDirectory( outputDirectory, testResourceDirectory ) );
            }
View Full Code Here


    public void execute() throws MojoExecutionException
    {
        super.execute();
        File absoluteGeneratedPath = new File( getProject().getBasedir(), getGenerated() );
        getProject().addCompileSourceRoot( absoluteGeneratedPath.getPath() );
        Resource resource = new Resource();
        resource.setFiltering( isResourceFiltering() );
        if ( getResourceTargetPath() != null )
        {
            resource.setTargetPath( getResourceTargetPath() );
        }
        resource.setDirectory( absoluteGeneratedPath.getPath() );
        resource.addExclude( "**/*.java" );
        getProject().addResource( resource );
    }
View Full Code Here

        else
        {
            super.execute();
            File absoluteGeneratedPath = new File( getProject().getBasedir(), getGenerated() );
            getProject().addTestCompileSourceRoot( absoluteGeneratedPath.getPath() );
            Resource resource = new Resource();
            resource.setFiltering( isResourceFiltering() );
            if ( getResourceTargetPath() != null )
            {
                resource.setTargetPath( getResourceTargetPath() );
            }
            resource.setDirectory( absoluteGeneratedPath.getPath() );
            resource.addExclude( "**/*.java" );
            getProject().addTestResource( resource );
        }
    }
View Full Code Here

        List resources = project.getResources();
        if (resources != null) {
            getLog().info("Copying resources");
            for (Object obj : resources) {
                if (obj instanceof Resource) {
                    Resource resource = (Resource) obj;
                    try {
                        File resourceFolder = new File(resource.getDirectory());
                        if (resourceFolder.exists()) {
                            getLog().info("   " + resource.getDirectory());
                            FileManagementUtil.copyDirectory(resourceFolder, REPO_GEN_LOCATION);
                        }
                    } catch (IOException e) {
                        throw new MojoExecutionException("Unable copy resources: " + resource.getDirectory(), e);
                    }
                }
            }
        }
    }
View Full Code Here

        if ( notEmpty( v3Resources ) )
        {
            for ( Iterator it = v3Resources.iterator(); it.hasNext(); )
            {
                org.apache.maven.model.v3_0_0.Resource v3Resource = (org.apache.maven.model.v3_0_0.Resource) it.next();
                Resource resource = new Resource();

                if ( v3Resource.getDirectory() == null )
                {
                    resource.setDirectory( "." );
                }
                else
                {
                    resource.setDirectory( v3Resource.getDirectory() );
                }

                List excludes = new ArrayList( v3Resource.getExcludes() );

                resource.setExcludes( excludes );

                resource.setIncludes( v3Resource.getIncludes() );
                resource.setTargetPath( v3Resource.getTargetPath() );

                resources.add( resource );
            }
        }
View Full Code Here

        org.apache.maven.model.v3_0_0.Resource v3Resource = new org.apache.maven.model.v3_0_0.Resource();
        v3Resource.setIncludes( Arrays.asList( new String[]{"**/*.properties"} ) );
        v3Model.getBuild().addResource( v3Resource );

        Model result = translator.translate( v3Model );
        Resource resource = (Resource) result.getBuild().getResources().get( 0 );
        Assert.assertEquals( "check directory of v3Resource", ".", resource.getDirectory() );
    }
View Full Code Here

            if ( resources != null )
      {
        Iterator it = resources.iterator();
        while ( it.hasNext() )
        {
          Resource resource = (Resource) it.next();
                    String relativePath =
                        IdeUtils.toRelativeAndFixSeparator( basedir, new File( resource.getDirectory() ), false );
          coreSettings.put( PROP_JDT_CORE_COMPILER_ENCODING + relativePath, encoding );
        }
      }
      List testResources = config.getProject().getTestResources();
            if ( testResources != null )
      {
        Iterator it = testResources.iterator();
        while ( it.hasNext() )
        {
          Resource resource = (Resource) it.next();
                    String relativePath =
                        IdeUtils.toRelativeAndFixSeparator( basedir, new File( resource.getDirectory() ), false );
          coreSettings.put( PROP_JDT_CORE_COMPILER_ENCODING + relativePath, encoding );
        }
      }
        }
View Full Code Here

            String metainfDir = generatedResourceDir + File.separatorChar + "META-INF";

            new File( metainfDir ).mkdirs();

            final Resource resource = new Resource();

            getLog().debug( "Adding " + this.generatedResourceDirName + " to resources" );

            resource.setDirectory( generatedResourceDir );

            this.executedProject.addResource( resource );
        }

        if ( Constants.PROJECT_PACKAGING_WAR.equals( packaging ) )
View Full Code Here

                                    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() );

            List excludes = new ArrayList( resource.getExcludes() );
            // automatically exclude java files: eclipse doesn't have the concept of resource directory so it will
            // try to compile any java file found in maven resource dirs
            excludes.add( JAVA_FILE_PATTERN );

            // 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 resourcePath =
                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 );
            }

            EclipseSourceDir resourceDir =
                new EclipseSourceDir( resourcePath, thisOutput, true, test, resource.getIncludes(), excludes,
                                      resource.isFiltering() );

            if ( !directories.add( resourceDir ) )
            {
                EclipseSourceDir originalDir = (EclipseSourceDir) get( directories, resourceDir );

View Full Code Here

     * @return Resource
     */
    private Resource parseResource( String tagName, XmlPullParser parser, boolean strict )
        throws IOException, XmlPullParserException
    {
        Resource resource = new Resource();
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( checkFieldWithDuplicate( parser, "targetPath", null, parsed ) )
            {
                resource.setTargetPath( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "filtering", null, parsed ) )
            {
                resource.setFiltering( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "mergeId", null, parsed ) )
            {
                resource.setMergeId( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "directory", null, parsed ) )
            {
                resource.setDirectory( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
            {
                java.util.List includes = new java.util.ArrayList/*<String>*/();
                resource.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>*/();
                resource.setExcludes( excludes );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "exclude" ) )
                    {
                        excludes.add( getTrimmedValue( parser.nextText() ) );
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.