Search in sources :

Example 51 with Resource

use of org.apache.maven.model.Resource in project maven-plugins by apache.

the class MavenProjectResourcesStub method setupTestResources.

private void setupTestResources() {
    Resource resource = new Resource();
    // see MavenProjectBasicStub for details 
    // of getBasedir      
    // setup default test resources         
    resource.setDirectory(getBasedir().getPath() + "/src/test/resources");
    resource.setFiltering(false);
    resource.setTargetPath(null);
    build.addTestResource(resource);
}
Also used : Resource(org.apache.maven.model.Resource)

Example 52 with Resource

use of org.apache.maven.model.Resource in project maven-plugins by apache.

the class RarMojo method resourceHandling.

private void resourceHandling() throws MojoExecutionException {
    Resource resource = new Resource();
    resource.setDirectory(rarSourceDirectory.getAbsolutePath());
    resource.setTargetPath(getBuildDir().getAbsolutePath());
    resource.setFiltering(filterRarSourceDirectory);
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(resource);
    if (rarResources != null && !rarResources.isEmpty()) {
        resources.addAll(rarResources);
    }
    MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(resources, getBuildDir(), project, encoding, filters, Collections.<String>emptyList(), session);
    mavenResourcesExecution.setEscapeWindowsPaths(escapeWindowsPaths);
    // never include project build filters in this call, since we've already accounted for the POM build filters
    // above, in getCombinedFiltersList().
    mavenResourcesExecution.setInjectProjectBuildFilters(false);
    mavenResourcesExecution.setEscapeString(escapeString);
    mavenResourcesExecution.setOverwrite(overwrite);
    mavenResourcesExecution.setIncludeEmptyDirs(includeEmptyDirs);
    mavenResourcesExecution.setSupportMultiLineFiltering(supportMultiLineFiltering);
    mavenResourcesExecution.setDelimiters(delimiters, useDefaultDelimiters);
    if (nonFilteredFileExtensions != null) {
        mavenResourcesExecution.setNonFilteredFileExtensions(nonFilteredFileExtensions);
    }
    try {
        mavenResourcesFiltering.filterResources(mavenResourcesExecution);
    } catch (MavenFilteringException e) {
        throw new MojoExecutionException("Error copying RAR resources", e);
    }
}
Also used : MavenResourcesExecution(org.apache.maven.shared.filtering.MavenResourcesExecution) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenFilteringException(org.apache.maven.shared.filtering.MavenFilteringException) Resource(org.apache.maven.model.Resource) ArrayList(java.util.ArrayList)

Example 53 with Resource

use of org.apache.maven.model.Resource in project aries by apache.

the class ResourceInitializer method generateResourceEntry.

static String generateResourceEntry(MavenProject project) {
    String buildDir = project.getBuild().getDirectory();
    String generatedBaseDir = buildDir + "/generated-sources/blueprint";
    Resource resource = new Resource();
    resource.setDirectory(generatedBaseDir);
    project.addResource(resource);
    return generatedBaseDir;
}
Also used : Resource(org.apache.maven.model.Resource)

Example 54 with Resource

use of org.apache.maven.model.Resource in project maven-plugins by apache.

the class MavenProjectResourcesStub method setupTestResources.

private void setupTestResources() {
    Resource resource = new Resource();
    // see MavenProjectBasicStub for details
    // of getBasedir
    // setup default test resources
    resource.setDirectory(getBasedir().getPath() + "/src/test/resources");
    resource.setFiltering(false);
    resource.setTargetPath(null);
    build.addTestResource(resource);
}
Also used : Resource(org.apache.maven.model.Resource)

Example 55 with Resource

use of org.apache.maven.model.Resource in project maven-plugins by apache.

the class DefaultCheckstyleExecutor method addSourceDirectory.

protected void addSourceDirectory(CheckstyleCheckerListener sinkListener, Collection<File> sourceDirectories, Collection<File> testSourceDirectories, List<Resource> resources, CheckstyleExecutorRequest request) {
    if (sourceDirectories != null) {
        for (File sourceDirectory : sourceDirectories) {
            if (sourceDirectory.exists()) {
                sinkListener.addSourceDirectory(sourceDirectory);
            }
        }
    }
    if (request.isIncludeTestSourceDirectory() && (testSourceDirectories != null)) {
        for (File testSourceDirectory : testSourceDirectories) {
            if (testSourceDirectory.isDirectory()) {
                sinkListener.addSourceDirectory(testSourceDirectory);
            }
        }
    }
    if (resources != null) {
        for (Resource resource : resources) {
            if (resource.getDirectory() != null) {
                File resourcesDirectory = new File(resource.getDirectory());
                if (resourcesDirectory.exists() && resourcesDirectory.isDirectory()) {
                    sinkListener.addSourceDirectory(resourcesDirectory);
                    getLogger().debug("Added '" + resourcesDirectory.getAbsolutePath() + "' as a source directory.");
                }
            }
        }
    }
}
Also used : Resource(org.apache.maven.model.Resource) File(java.io.File)

Aggregations

Resource (org.apache.maven.model.Resource)65 File (java.io.File)49 MavenProjectResourcesStub (org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub)17 ArrayList (java.util.ArrayList)16 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)15 IOException (java.io.IOException)11 Properties (java.util.Properties)8 MojoFailureException (org.apache.maven.plugin.MojoFailureException)8 FileInputStream (java.io.FileInputStream)7 List (java.util.List)6 InputStream (java.io.InputStream)5 OutputStream (java.io.OutputStream)5 URL (java.net.URL)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 URLClassLoader (java.net.URLClassLoader)3 Iterator (java.util.Iterator)3 FileOutputStream (java.io.FileOutputStream)2 MalformedURLException (java.net.MalformedURLException)2 HashMap (java.util.HashMap)2