Search in sources :

Example 1 with Internal

use of org.gradle.api.tasks.Internal in project gradle by gradle.

the class JettyRun method getDependencyFiles.

@Internal
private Set<File> getDependencyFiles() {
    List<Resource> overlays = new ArrayList<Resource>();
    Set<File> dependencies = getClasspath().getFiles();
    LOGGER.debug("Adding dependencies {} for WEB-INF/lib ", dependencies);
    //            }
    if (!overlays.isEmpty()) {
        try {
            Resource resource = getWebAppConfig().getBaseResource();
            ResourceCollection rc = new ResourceCollection();
            if (resource == null) {
                // nothing configured, so we automagically enable the overlays
                int size = overlays.size() + 1;
                Resource[] resources = new Resource[size];
                resources[0] = Resource.newResource(getWebAppSourceDirectory().toURI().toURL());
                for (int i = 1; i < size; i++) {
                    resources[i] = overlays.get(i - 1);
                    LOGGER.info("Adding overlay: " + resources[i]);
                }
                rc.setResources(resources);
            } else {
                if (resource instanceof ResourceCollection) {
                    // there was a preconfigured ResourceCollection ... append the artifact wars
                    Resource[] old = ((ResourceCollection) resource).getResources();
                    int size = old.length + overlays.size();
                    Resource[] resources = new Resource[size];
                    System.arraycopy(old, 0, resources, 0, old.length);
                    for (int i = old.length; i < size; i++) {
                        resources[i] = overlays.get(i - old.length);
                        LOGGER.info("Adding overlay: " + resources[i]);
                    }
                    rc.setResources(resources);
                } else {
                    // baseResource was already configured w/c could be src/main/webapp
                    if (!resource.isDirectory() && String.valueOf(resource.getFile()).endsWith(".war")) {
                        // its a war
                        resource = Resource.newResource("jar:" + resource.getURL().toString() + "!/");
                    }
                    int size = overlays.size() + 1;
                    Resource[] resources = new Resource[size];
                    resources[0] = resource;
                    for (int i = 1; i < size; i++) {
                        resources[i] = overlays.get(i - 1);
                        LOGGER.info("Adding overlay: " + resources[i]);
                    }
                    rc.setResources(resources);
                }
            }
            getWebAppConfig().setBaseResource(rc);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return dependencies;
}
Also used : ArrayList(java.util.ArrayList) Resource(org.mortbay.resource.Resource) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) IOException(java.io.IOException) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ResourceCollection(org.mortbay.resource.ResourceCollection) Internal(org.gradle.api.tasks.Internal)

Example 2 with Internal

use of org.gradle.api.tasks.Internal in project gradle by gradle.

the class Groovydoc method getAntGroovydoc.

@Internal
public AntGroovydoc getAntGroovydoc() {
    if (antGroovydoc == null) {
        IsolatedAntBuilder antBuilder = getServices().get(IsolatedAntBuilder.class);
        ClassPathRegistry classPathRegistry = getServices().get(ClassPathRegistry.class);
        antGroovydoc = new AntGroovydoc(antBuilder, classPathRegistry);
    }
    return antGroovydoc;
}
Also used : IsolatedAntBuilder(org.gradle.api.internal.project.IsolatedAntBuilder) ClassPathRegistry(org.gradle.api.internal.ClassPathRegistry) AntGroovydoc(org.gradle.api.internal.tasks.AntGroovydoc) Internal(org.gradle.api.tasks.Internal)

Aggregations

Internal (org.gradle.api.tasks.Internal)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 ClassPathRegistry (org.gradle.api.internal.ClassPathRegistry)1 IsolatedAntBuilder (org.gradle.api.internal.project.IsolatedAntBuilder)1 AntGroovydoc (org.gradle.api.internal.tasks.AntGroovydoc)1 InputFile (org.gradle.api.tasks.InputFile)1 Resource (org.mortbay.resource.Resource)1 ResourceCollection (org.mortbay.resource.ResourceCollection)1