Search in sources :

Example 11 with Resource

use of org.apache.maven.model.Resource in project OpenAM by OpenRock.

the class CLIDefinitionGenerator method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    for (String className : definitions) {
        try {
            Class clazz = Class.forName(className);
            Field pdtField = clazz.getDeclaredField("product");
            if (pdtField != null) {
                DefinitionClassInfo classInfo = pdtField.getAnnotation(DefinitionClassInfo.class);
                PrintStream rbOut = createResourcePrintStream(outputDir, classInfo);
                getCommonResourceStrings(rbOut, clazz);
                rbOut.println("product-name=" + classInfo.productName());
                getCommands(className, clazz, rbOut);
                rbOut.close();
            } else {
                throw new Exception("Incorrect Definiton, class=" + className + " missing product field");
            }
        } catch (Exception ex) {
            throw new MojoFailureException("An error occured while generating CLI resources", ex);
        }
    }
    Resource resource = new Resource();
    resource.setDirectory(outputDir);
    project.addResource(resource);
}
Also used : Field(java.lang.reflect.Field) PrintStream(java.io.PrintStream) MojoFailureException(org.apache.maven.plugin.MojoFailureException) Resource(org.apache.maven.model.Resource) DefinitionClassInfo(com.sun.identity.cli.annotation.DefinitionClassInfo) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 12 with Resource

use of org.apache.maven.model.Resource in project jangaroo-tools by CoreMedia.

the class JooTestMojoTest method testNoTestsAvailable.

public void testNoTestsAvailable() throws MojoExecutionException, MojoFailureException, IOException {
    File f = File.createTempFile("JooTestMojoTest", "");
    Assert.assertTrue(f.delete());
    Assert.assertTrue(f.mkdirs());
    jooTestMojo.setTestSourceDirectory(f);
    jooTestMojo.setTestResources(new ArrayList<Resource>());
    jooTestMojo.execute();
    Assert.assertTrue(f.delete());
}
Also used : Resource(org.apache.maven.model.Resource) File(java.io.File)

Example 13 with Resource

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

the class MavenProjectResourcesStub method setupResources.

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

Example 14 with Resource

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

the class AbstractSourceJarMojo method archiveProjectContent.

/**
     * @param p {@link MavenProject}
     * @param archiver {@link Archiver}
     * @throws MojoExecutionException in case of an error.
     */
protected void archiveProjectContent(MavenProject p, Archiver archiver) throws MojoExecutionException {
    if (includePom) {
        try {
            archiver.addFile(p.getFile(), p.getFile().getName());
        } catch (ArchiverException e) {
            throw new MojoExecutionException("Error adding POM file to target jar file.", e);
        }
    }
    for (String s : getSources(p)) {
        File sourceDirectory = new File(s);
        if (sourceDirectory.exists()) {
            addDirectory(archiver, sourceDirectory, getCombinedIncludes(null), getCombinedExcludes(null));
        }
    }
    // MAPI: this should be taken from the resources plugin
    for (Resource resource : getResources(p)) {
        File sourceDirectory = new File(resource.getDirectory());
        if (!sourceDirectory.exists()) {
            continue;
        }
        List<String> resourceIncludes = resource.getIncludes();
        String[] combinedIncludes = getCombinedIncludes(resourceIncludes);
        List<String> resourceExcludes = resource.getExcludes();
        String[] combinedExcludes = getCombinedExcludes(resourceExcludes);
        String targetPath = resource.getTargetPath();
        if (targetPath != null) {
            if (!targetPath.trim().endsWith("/")) {
                targetPath += "/";
            }
            addDirectory(archiver, sourceDirectory, targetPath, combinedIncludes, combinedExcludes);
        } else {
            addDirectory(archiver, sourceDirectory, combinedIncludes, combinedExcludes);
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) Resource(org.apache.maven.model.Resource) File(java.io.File)

Example 15 with Resource

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

the class MavenJDOMWriter method iterateResource.

// -- void iterateRepository(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
     * Method iterateResource
     *
     * @param counter
     * @param childTag
     * @param parentTag
     * @param list
     * @param parent
     */
protected void iterateResource(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        while (it.hasNext()) {
            Resource value = (Resource) it.next();
            Element el;
            if (elIt != null && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateResource(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Element(org.jdom.Element) Iterator(java.util.Iterator) Resource(org.apache.maven.model.Resource)

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