Skip to content
Browse files

Use a checksum to allow dependencies to be resolved once remotely and…

… then offline until BuildConfig or application.properties is modified again
  • Loading branch information...
1 parent 3e54572 commit e8a528a2570f92bcf21db7ce6d422a8aabb2d159 @graemerocher graemerocher committed Nov 25, 2010
View
1 .classpath
@@ -79,5 +79,6 @@
<classpathentry kind="lib" path="lib/groovy-all-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/concurrentlinkedhashmap-lru-1.0_jdk5.jar"/>
<classpathentry kind="lib" path="lib/h2-1.2.144.jar"/>
+ <classpathentry kind="lib" path="lib/jsr166y-070108.jar"/>
<classpathentry kind="output" path="target/eclipse/bin-output"/>
</classpath>
View
1 conf/groovy-starter.conf
@@ -12,6 +12,7 @@
load ${grails.home}/dist/grails-bootstrap-${grails.version}.jar
load ${grails.home}/lib/groovy-all-1.7.5.jar
load ${grails.home}/lib/gpars-0.9.jar
+ load ${grails.home}/lib/jsr166y-070108.jar
load ${grails.home}/lib/ivy-2.2.0.jar
load ${grails.home}/lib/gant_groovy1.7-1.9.2.jar
load ${grails.home}/lib/ant-1.7.1.jar
View
3 maven/grails-osgi.mf
@@ -34,4 +34,5 @@ Import-Template:
javax.xml.transform.*;version="0",
org.w3c.dom.*;version="0",
org.xml.sax.*;version="0",
- org.springframework.*;version="${spring.version:[=.=.=, +1.0.0)}"
+ org.springframework.*;version="${spring.version:[=.=.=, +1.0.0)}",
+ jsr166y.forkjoin.*;version="070108"
View
162 src/java/grails/util/BuildSettings.groovy
@@ -18,10 +18,13 @@ package grails.util
import grails.util.Metadata
import groovyx.gpars.Asynchronizer
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.regex.Pattern
import org.apache.ivy.plugins.repository.TransferListener
import org.apache.ivy.plugins.repository.TransferEvent
+import org.apache.ivy.util.ChecksumHelper;
import org.apache.ivy.util.DefaultMessageLogger
import org.apache.ivy.util.Message
@@ -268,9 +271,17 @@ class BuildSettings extends AbstractBuildSettings {
* Setting for whether or not to enable verbose compilation, can be overridden via -verboseCompile(=[true|false])?
*/
boolean verboseCompile = false
+
+ /**
+ * Return whether the BuildConfig has been modified
+ */
+ boolean modified = false
+
private List<File> compileDependencies = []
private boolean defaultCompileDepsAdded = false
+
+
/** List containing the compile-time dependencies of the app as File instances. */
List<File> getCompileDependencies() {
@@ -295,6 +306,8 @@ class BuildSettings extends AbstractBuildSettings {
.allArtifactsReports
.localFile + applicationJars
Message.debug("Resolved jars for [compile]: ${{->jarFiles.join('\n')}}")
+ resolveCache['compile'] = jarFiles
+ storeCache()
return jarFiles
}()
@@ -324,6 +337,8 @@ class BuildSettings extends AbstractBuildSettings {
.allArtifactsReports
.localFile + applicationJars
Message.debug("Resolved jars for [test]: ${{->jarFiles.join('\n')}}")
+ resolveCache['test'] = jarFiles
+ storeCache()
return jarFiles
}()
@@ -353,11 +368,32 @@ class BuildSettings extends AbstractBuildSettings {
.allArtifactsReports
.localFile + applicationJars
Message.debug("Resolved jars for [runtime]: ${{->jarFiles.join('\n')}}")
+ resolveCache['runtime'] = jarFiles
+ storeCache()
return jarFiles
}()
+ private List<File> providedDependencies = []
+ private boolean defaultProvidedDepsAdded = false
+
+ /** List containing the runtime dependencies of the app as File instances. */
+ List<File> getProvidedDependencies() {
+ if (!defaultProvidedDepsAdded) {
+ providedDependencies += defaultProvidedDependencies
+ defaultProvidedDepsAdded = true
+ }
+ return providedDependencies
+ }
+
+ /**
+ * Sets the runtime dependencies for the project
+ */
+ void setProvidedDependencies(List<File> deps) {
+ providedDependencies = deps
+ }
+
/** List containing the dependencies needed at development time, but provided by the container at runtime **/
- @Lazy List<File> providedDependencies = {
+ @Lazy List<File> defaultProvidedDependencies = {
if (dependenciesExternallyConfigured) {
return []
}
@@ -367,13 +403,34 @@ class BuildSettings extends AbstractBuildSettings {
.localFile
Message.debug("Resolved jars for [provided]: ${{->jarFiles.join('\n')}}")
+ resolveCache['provided'] = jarFiles
+ storeCache()
+
return jarFiles
}()
+ private List<File> buildDependencies = []
+ private boolean defaultBuildDepsAdded = false
+
+ /** List containing the runtime dependencies of the app as File instances. */
+ List<File> getBuildDependencies() {
+ if (!defaultBuildDepsAdded) {
+ buildDependencies += defaultDuildDependencies
+ defaultBuildDepsAdded = true
+ }
+ return buildDependencies
+ }
+
+ /**
+ * Sets the runtime dependencies for the project
+ */
+ void setBuildDependencies(List<File> deps) {
+ buildDependencies = deps
+ }
/**
* List containing the dependencies required for the build system only
*/
- @Lazy List<File> buildDependencies = {
+ @Lazy List<File> defaultDuildDependencies = {
if (dependenciesExternallyConfigured) {
return []
}
@@ -383,6 +440,9 @@ class BuildSettings extends AbstractBuildSettings {
.localFile + applicationJars
Message.debug("Resolved jars for [build]: ${{->jarFiles.join('\n')}}")
+ resolveCache['build'] = jarFiles
+ storeCache()
+
return jarFiles
}()
@@ -419,6 +479,8 @@ class BuildSettings extends AbstractBuildSettings {
private boolean projectWarOsgiHeadersSet
private boolean buildListenersSet
private boolean verboseCompileSet
+ private String resolveChecksum
+ private Map resolveCache = new ConcurrentHashMap()
BuildSettings() {
this(null)
@@ -472,6 +534,14 @@ class BuildSettings extends AbstractBuildSettings {
}
}
+ private storeCache() {
+ def cachedResolve = new File("${projectWorkDir}/${resolveChecksum}.resolve")
+ cachedResolve.withOutputStream { output ->
+ def oos = new ObjectOutputStream(output)
+ oos.writeObject(resolveCache)
+
+ }
+ }
private def loadBuildPropertiesFromClasspath(Properties buildProps) {
InputStream stream = getClass().classLoader.getResourceAsStream("grails.build.properties")
if(stream == null) {
@@ -679,7 +749,62 @@ class BuildSettings extends AbstractBuildSettings {
defaultPluginSet = config.grails.default.plugin.set
}
flatConfig = config.flatten()
- configureDependencyManager(config)
+
+ def configURL = config.getConfigFile()
+ def configFile = configURL ? new File(configURL.getFile()) : null
+
+ def metadataFile = Metadata.current.getMetadataFile()
+
+ if(configFile?.exists() && metadataFile?.exists()) {
+ this.resolveChecksum = ChecksumHelper.computeAsString(configFile, "md5") +
+ ChecksumHelper.computeAsString(metadataFile, "md5")
+ }
+
+ def cachedResolve = new File("${projectWorkDir}/${resolveChecksum}.resolve")
+ if(cachedResolve.exists()) {
+
+
+
+ cachedResolve.withInputStream { input ->
+ def ois = new ObjectInputStream(input)
+ def dependencyMap = ois.readObject()
+
+ def compileDeps = dependencyMap.compile
+ def runtimeDeps = dependencyMap.runtime
+ def testDeps = dependencyMap.test
+ def buildDeps = dependencyMap.build
+ def providedDeps = dependencyMap.provided
+
+ if(compileDeps) {
+ this.@compileDependencies.addAll(compileDeps)
+ defaultCompileDepsAdded = true
+ }
+
+ if(runtimeDeps) {
+ this.@runtimeDependencies.addAll(runtimeDeps)
+ defaultRuntimeDepsAdded = true
+ }
+
+ if(testDeps) {
+ this.@testDependencies.addAll(testDeps)
+ defaultTestDepsAdded = true
+ }
+
+ if(buildDeps) {
+ this.@buildDependencies.addAll(buildDeps)
+ defaultBuildDepsAdded = true
+ }
+
+ if(providedDeps) {
+ this.@providedDependencies.addAll(providedDeps)
+ defaultProvidedDepsAdded = true
+ }
+ }
+ }
+ else {
+ this.modified = true
+ }
+ configureDependencyManager(config)
}
protected boolean settingsFileLoaded = false
@@ -750,39 +875,46 @@ class BuildSettings extends AbstractBuildSettings {
}
} as TransferListener
+
+ def grailsConfig = config.grails
+
if (!dependenciesExternallyConfigured) {
- config.grails.global.dependency.resolution = IvyDependencyManager.getDefaultDependencies(grailsVersion)
- def credentials = config.grails.project.ivy.authentication
+ grailsConfig.global.dependency.resolution = IvyDependencyManager.getDefaultDependencies(grailsVersion)
+ def credentials = grailsConfig.project.ivy.authentication
if (credentials instanceof Closure) {
dependencyManager.parseDependencies credentials
}
}
else {
// Even if the dependencies are handled externally, we still
// to handle plugin dependencies.
- config.grails.global.dependency.resolution = {
+ grailsConfig.global.dependency.resolution = {
repositories {
grailsPlugins()
}
}
}
-
- def dependencyConfig = config.grails.project.dependency.resolution
+
+ def dependencyConfig = grailsConfig.project.dependency.resolution
if (!dependencyConfig) {
- dependencyConfig = config.grails.global.dependency.resolution
+ dependencyConfig = grailsConfig.global.dependency.resolution
dependencyManager.inheritsAll = true
}
if (dependencyConfig) {
+ if(resolveCache) {
+ dependencyManager.pluginsOnly = true
+ }
+
dependencyManager.parseDependencies dependencyConfig
+
}
-
+
// All projects need the plugins to be resolved.
def handlePluginDirectory = pluginDependencyHandler()
-
- Asynchronizer.doParallel(5) {
- def pluginDirs = getPluginDirectories()
- pluginDirs.eachParallel(handlePluginDirectory)
- }
+ def pluginDirs = getPluginDirectories()
+ for(dir in pluginDirs) {
+ handlePluginDirectory(dir)
+ }
}
Closure pluginDependencyHandler() {
View
8 src/java/grails/util/Metadata.java
@@ -59,8 +59,14 @@ private Metadata() {
private Metadata(File f) {
this.metadataFile = f;
}
+
+
- /**
+ public File getMetadataFile() {
+ return metadataFile;
+ }
+
+ /**
* Resets the current state of the Metadata so it is re-read.
*/
public static void reset() {
View
3 src/java/org/codehaus/groovy/grails/cli/GrailsScriptRunner.java
@@ -843,9 +843,6 @@ private static void addCommandScripts(File dir, List<File> scripts) {
// Add build-only dependencies to the project
final boolean dependenciesExternallyConfigured = settings.isDependenciesExternallyConfigured();
- if (!dependenciesExternallyConfigured) {
- System.out.println("Resolving dependencies...");
- }
long now = System.currentTimeMillis();
// add dependencies required by the build system
final List<File> buildDependencies = settings.getBuildDependencies();
View
97 src/java/org/codehaus/groovy/grails/resolve/AbstractIvyDependencyManager.java
@@ -14,6 +14,8 @@
*/
package org.codehaus.groovy.grails.resolve;
+import groovy.lang.Closure;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
@@ -22,8 +24,10 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ExcludeRule;
@@ -113,13 +117,52 @@
protected Set<String> pluginDependencyNames = new HashSet<String>();
protected Set<String> metadataRegisteredPluginNames = new HashSet<String>();
protected Map<String, Collection<ModuleRevisionId>> orgToDepMap = new HashMap<String, Collection<ModuleRevisionId>>();
+ protected Collection<String> usedConfigurations = new ConcurrentLinkedQueue();
protected Map<String, DependencyDescriptor> pluginNameToDescriptorMap =
new ConcurrentHashMap<String, DependencyDescriptor>();
protected String applicationName;
protected String applicationVersion;
-
- /**
+ protected DefaultDependencyDescriptor currentDependencyDescriptor;
+ protected DefaultModuleDescriptor moduleDescriptor;
+ protected boolean hasApplicationDependencies = false;
+
+
+ public DefaultModuleDescriptor getModuleDescriptor() {
+ return moduleDescriptor;
+ }
+
+ public void setModuleDescriptor(DefaultModuleDescriptor moduleDescriptor) {
+ this.moduleDescriptor = moduleDescriptor;
+ }
+
+ /**
+ * Returns true if the application has any dependencies that are not inherited
+ * from the framework or other plugins
+ */
+
+ public boolean hasApplicationDependencies() {
+ return hasApplicationDependencies;
+ }
+
+ public DefaultDependencyDescriptor getCurrentDependencyDescriptor() {
+ return currentDependencyDescriptor;
+ }
+
+ public void setCurrentDependencyDescriptor(
+ DefaultDependencyDescriptor currentDependencyDescriptor) {
+ this.currentDependencyDescriptor = currentDependencyDescriptor;
+ }
+
+ public Collection<String> getUsedConfigurations() {
+ return usedConfigurations;
+ }
+
+ public void setUsedConfigurations(Collection<String> usedConfigurations) {
+ this.usedConfigurations = usedConfigurations;
+ }
+
+ /**
* Obtains a set of dependency descriptors defined in the project
*/
Set<DependencyDescriptor> getDependencyDescriptors() {
@@ -215,6 +258,56 @@ public void addDependency(ModuleRevisionId revisionId) {
}
}
+ public void configureDependencyDescriptor(EnhancedDefaultDependencyDescriptor dependencyDescriptor, String scope) {
+ configureDependencyDescriptor(dependencyDescriptor, scope, null, false);
+ }
+
+ public void configureDependencyDescriptor(EnhancedDefaultDependencyDescriptor dependencyDescriptor, String scope, Closure dependencyConfigurer) {
+ configureDependencyDescriptor(dependencyDescriptor, scope, dependencyConfigurer, false);
+ }
+
+ public void configureDependencyDescriptor(EnhancedDefaultDependencyDescriptor dependencyDescriptor, String scope, Closure dependencyConfigurer, boolean pluginMode ) {
+ if (!usedConfigurations.contains(scope)) {
+ usedConfigurations.add( scope );
+ }
+
+ try {
+ this.currentDependencyDescriptor = dependencyDescriptor;
+ if (dependencyConfigurer != null) {
+ dependencyConfigurer.setResolveStrategy(Closure.DELEGATE_ONLY);
+ dependencyConfigurer.setDelegate(dependencyDescriptor);
+ dependencyConfigurer.call();
+ }
+ }
+ finally {
+ this.currentDependencyDescriptor = null;
+ }
+ if (dependencyDescriptor.getModuleConfigurations().length == 0){
+ List<String> mappings = configurationMappings.get(scope);
+ if(mappings != null) {
+ for(String m : mappings) {
+ dependencyDescriptor.addDependencyConfiguration( scope, m );
+ }
+ }
+ }
+ if (!dependencyDescriptor.isInherited()) {
+ hasApplicationDependencies = true;
+ }
+ if (pluginMode) {
+ String name = dependencyDescriptor.getDependencyId().getName();
+ pluginDependencyNames.add(name);
+ pluginDependencyDescriptors.add(dependencyDescriptor);
+ pluginNameToDescriptorMap.put(name, dependencyDescriptor );
+ }
+ else {
+ dependencyDescriptors.add(dependencyDescriptor);
+ if (dependencyDescriptor.isExportedToApplication()) {
+ moduleDescriptor.addDependency(dependencyDescriptor);
+ }
+
+ }
+ }
+
protected ArtifactId createExcludeArtifactId(String excludeName) {
return createExcludeArtifactId(excludeName, PatternMatcher.ANY_EXPRESSION);
}
View
475 src/java/org/codehaus/groovy/grails/resolve/IvyDependencyManager.groovy
@@ -41,6 +41,8 @@ import org.apache.ivy.util.url.CredentialsStore
import org.apache.ivy.core.module.descriptor.ModuleDescriptor
import org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor
import grails.util.Metadata
+import groovyx.gpars.Parallelizer;
+
import org.apache.ivy.plugins.latest.LatestTimeStrategy
import org.apache.ivy.util.MessageLogger
import org.apache.ivy.core.module.descriptor.Artifact
@@ -54,6 +56,9 @@ import org.apache.ivy.core.module.id.ArtifactId
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor
import org.apache.ivy.plugins.repository.TransferListener
import java.util.concurrent.ConcurrentLinkedQueue
+
+import jsr166y.forkjoin.ForkJoinPool;
+
import org.apache.ivy.plugins.resolver.RepositoryResolver
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser
@@ -65,26 +70,27 @@ import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser
*/
class IvyDependencyManager extends AbstractIvyDependencyManager implements DependencyResolver, DependencyDefinitionParser{
- private hasApplicationDependencies = false
+
ResolveEngine resolveEngine
BuildSettings buildSettings
IvySettings ivySettings
MessageLogger logger
Metadata metadata
- ChainResolver chainResolver = new ChainResolver(name:"default",returnFirst:true)
- DefaultModuleDescriptor moduleDescriptor
+ ChainResolver chainResolver = new ChainResolver(name:"default",returnFirst:true)
DefaultDependencyDescriptor currentDependencyDescriptor
Collection repositoryData = new ConcurrentLinkedQueue()
Collection<String> configuredPlugins = new ConcurrentLinkedQueue()
- Collection<String> usedConfigurations = new ConcurrentLinkedQueue()
+
Collection moduleExcludes = new ConcurrentLinkedQueue()
TransferListener transferListener
boolean readPom = false
boolean inheritsAll = false
boolean resolveErrors = false
boolean defaultDependenciesProvided = false
-
+ boolean pluginsOnly = false
+
+ private static ForkJoinPool forkJoinPool
/**
* Creates a new IvyDependencyManager instance
*/
@@ -145,11 +151,6 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
chainResolver.resolvers.add(new GrailsPluginsDirectoryResolver(buildSettings, ivySettings))
}
- /**
- * Returns true if the application has any dependencies that are not inherited
- * from the framework or other plugins
- */
- boolean hasApplicationDependencies() { this.hasApplicationDependencies }
/**
* Serializes the parsed dependencies using the given builder.
@@ -215,117 +216,144 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
dependencies {
def compileTimeDependenciesMethod = defaultDependenciesProvided ? 'provided' : 'compile'
def runtimeDependenciesMethod = defaultDependenciesProvided ? 'provided' : 'runtime'
+ def parsingClosure = { ModuleRevisionId.newInstance(*it.split(/:/)) }
+
+ Parallelizer.withExistingParallelizer(forkJoinPool) {
+ // dependencies needed by the Grails build system
+ [ModuleRevisionId.newInstance("org.codehaus.gpars", "gpars", "0.9"),
+ ModuleRevisionId.newInstance("org.tmatesoft.svnkit", "svnkit", "1.3.1"),
+ ModuleRevisionId.newInstance("org.apache.ant","ant","1.7.1"),
+ ModuleRevisionId.newInstance("org.apache.ant","ant-launcher","1.7.1"),
+ ModuleRevisionId.newInstance("org.apache.ant","ant-junit","1.7.1"),
+ ModuleRevisionId.newInstance("org.apache.ant","ant-nodeps","1.7.1"),
+ ModuleRevisionId.newInstance("org.apache.ant","ant-trax","1.7.1"),
+ ModuleRevisionId.newInstance("jline","jline","0.9.94"),
+ ModuleRevisionId.newInstance("org.fusesource.jansi","jansi","1.2.1"),
+ ModuleRevisionId.newInstance("xalan","serializer","2.7.1"),
+ ModuleRevisionId.newInstance("org.grails","grails-docs",grailsVersion),
+ ModuleRevisionId.newInstance("org.grails","grails-bootstrap", grailsVersion),
+ ModuleRevisionId.newInstance("org.grails","grails-scripts",grailsVersion),
+ ModuleRevisionId.newInstance("org.grails","grails-core",grailsVersion),
+ ModuleRevisionId.newInstance("org.grails","grails-resources",grailsVersion),
+ ModuleRevisionId.newInstance("org.grails","grails-web",grailsVersion),
+ ModuleRevisionId.newInstance("org.slf4j","slf4j-api","1.5.8"),
+ ModuleRevisionId.newInstance("org.slf4j","slf4j-log4j12","1.5.8"),
+ ModuleRevisionId.newInstance("org.springframework","org.springframework.test","3.0.3.RELEASE"),
+ ModuleRevisionId.newInstance("com.googlecode.concurrentlinkedhashmap","concurrentlinkedhashmap-lru","1.0_jdk5")].eachParallel { mrid ->
+ def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, false ,"build")
+ addDependency mrid
+ configureDependencyDescriptor(dependencyDescriptor, "build", null, false)
+ }
+
+
+ ["org.xhtmlrenderer:core-renderer:R8",
+ "com.lowagie:itext:2.0.8",
+ "radeox:radeox:1.0-b2"].collect(parsingClosure).eachParallel { mrid ->
+ def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, false ,"docs")
+ addDependency mrid
+ configureDependencyDescriptor(dependencyDescriptor, "docs", null, false)
+ }
+
+ // dependencies needed during development, but not for deployment
+ ["javax.servlet:servlet-api:2.5",
+ "javax.servlet:jsp-api:2.1"].collect(parsingClosure).eachParallel {mrid ->
+ def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, false ,"provided")
+ addDependency mrid
+ configureDependencyDescriptor(dependencyDescriptor, "provided", null, false)
+ }
+
+ // dependencies needed for compilation
+ "${compileTimeDependenciesMethod}"("org.codehaus.groovy:groovy-all:1.7.5") {
+ excludes 'jline'
+ }
+
+ "${compileTimeDependenciesMethod}"("commons-beanutils:commons-beanutils:1.8.0", "commons-el:commons-el:1.0", "commons-validator:commons-validator:1.3.1") {
+ excludes "commons-logging", "xml-apis"
+ }
+
+ ["aopalliance:aopalliance:1.0",
+ "com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.0_jdk5",
+ "commons-codec:commons-codec:1.3",
+ "commons-collections:commons-collections:3.2.1",
+ "commons-io:commons-io:1.4",
+ "commons-lang:commons-lang:2.4",
+ "javax.transaction:jta:1.1",
+ "org.hibernate:ejb3-persistence:1.0.2.GA",
+ "opensymphony:sitemesh:2.4",
+ "org.grails:grails-bootstrap:$grailsVersion",
+ "org.grails:grails-core:$grailsVersion",
+ "org.grails:grails-crud:$grailsVersion",
+ "org.grails:grails-gorm:$grailsVersion",
+ "org.grails:grails-resources:$grailsVersion",
+ "org.grails:grails-spring:$grailsVersion",
+ "org.grails:grails-web:$grailsVersion",
+ "org.springframework:org.springframework.core:3.0.3.RELEASE",
+ "org.springframework:org.springframework.aop:3.0.3.RELEASE",
+ "org.springframework:org.springframework.aspects:3.0.3.RELEASE",
+ "org.springframework:org.springframework.asm:3.0.3.RELEASE",
+ "org.springframework:org.springframework.beans:3.0.3.RELEASE",
+ "org.springframework:org.springframework.context:3.0.3.RELEASE",
+ "org.springframework:org.springframework.context.support:3.0.3.RELEASE",
+ "org.springframework:org.springframework.expression:3.0.3.RELEASE",
+ "org.springframework:org.springframework.instrument:3.0.3.RELEASE",
+ "org.springframework:org.springframework.jdbc:3.0.3.RELEASE",
+ "org.springframework:org.springframework.jms:3.0.3.RELEASE",
+ "org.springframework:org.springframework.orm:3.0.3.RELEASE",
+ "org.springframework:org.springframework.oxm:3.0.3.RELEASE",
+ "org.springframework:org.springframework.transaction:3.0.3.RELEASE",
+ "org.springframework:org.springframework.web:3.0.3.RELEASE",
+ "org.springframework:org.springframework.web.servlet:3.0.3.RELEASE",
+ "org.slf4j:slf4j-api:1.5.8"].collect(parsingClosure).eachParallel {mrid ->
+ def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, false ,compileTimeDependenciesMethod)
+ addDependency mrid
+ configureDependencyDescriptor(dependencyDescriptor, compileTimeDependenciesMethod, null, false)
+ }
+
+
+ // dependencies needed for running tests
+ ["junit:junit:4.8.1",
+ "org.grails:grails-test:$grailsVersion",
+ "org.springframework:org.springframework.test:3.0.3.RELEASE"].collect(parsingClosure).eachParallel {mrid ->
+ def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, false ,"test")
+ addDependency mrid
+ configureDependencyDescriptor(dependencyDescriptor, "test", null, false)
+ }
+
+ // dependencies needed at runtime only
+ [ "org.aspectj:aspectjweaver:1.6.8",
+ "org.aspectj:aspectjrt:1.6.8",
+ "cglib:cglib-nodep:2.1_3",
+ "commons-fileupload:commons-fileupload:1.2.1",
+ "oro:oro:2.0.8",
+ "javax.servlet:jstl:1.1.2",
+ // data source
+ "commons-dbcp:commons-dbcp:1.2.2",
+ "commons-pool:commons-pool:1.5.3",
+ "hsqldb:hsqldb:1.8.0.10",
+ "com.h2database:h2:1.2.144",
+ // JSP support
+ "apache-taglibs:standard:1.1.2",
+ "xpp3:xpp3_min:1.1.3.4.O"].collect(parsingClosure).eachParallel {mrid ->
+ def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, false ,runtimeDependenciesMethod)
+ addDependency mrid
+ configureDependencyDescriptor(dependencyDescriptor, runtimeDependenciesMethod, null, false)
+ }
+
+ // caching
+ "${runtimeDependenciesMethod}" ("net.sf.ehcache:ehcache-core:1.7.1") {
+ excludes 'jms', 'commons-logging', 'servlet-api'
+ }
+
+ // logging
+ "${runtimeDependenciesMethod}"("log4j:log4j:1.2.16",
+ "org.slf4j:jcl-over-slf4j:1.5.8",
+ "org.slf4j:jul-to-slf4j:1.5.8",
+ "org.slf4j:slf4j-log4j12:1.5.8" ) {
+ excludes 'mail', 'jms', 'jmxtools', 'jmxri'
+ }
+ }
+
- // dependencies needed by the Grails build system
- build "org.codehaus.gpars:gpars:0.9",
- "org.tmatesoft.svnkit:svnkit:1.3.1",
- "org.apache.ant:ant:1.7.1",
- "org.apache.ant:ant-launcher:1.7.1",
- "org.apache.ant:ant-junit:1.7.1",
- "org.apache.ant:ant-nodeps:1.7.1",
- "org.apache.ant:ant-trax:1.7.1",
- "jline:jline:0.9.94",
- "org.fusesource.jansi:jansi:1.2.1",
- "xalan:serializer:2.7.1",
- "org.grails:grails-docs:$grailsVersion",
- "org.grails:grails-bootstrap:$grailsVersion",
- "org.grails:grails-scripts:$grailsVersion",
- "org.grails:grails-core:$grailsVersion",
- "org.grails:grails-resources:$grailsVersion",
- "org.grails:grails-web:$grailsVersion",
- "org.slf4j:slf4j-api:1.5.8",
- "org.slf4j:slf4j-log4j12:1.5.8",
- "org.springframework:org.springframework.test:3.0.3.RELEASE",
- "com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.0_jdk5"
-
- docs "org.xhtmlrenderer:core-renderer:R8",
- "com.lowagie:itext:2.0.8",
- "radeox:radeox:1.0-b2"
-
- // dependencies needed during development, but not for deployment
- provided "javax.servlet:servlet-api:2.5",
- "javax.servlet:jsp-api:2.1"
-
- // dependencies needed for compilation
- "${compileTimeDependenciesMethod}"("org.codehaus.groovy:groovy-all:1.7.5") {
- excludes 'jline'
- }
-
- "${compileTimeDependenciesMethod}"("commons-beanutils:commons-beanutils:1.8.0", "commons-el:commons-el:1.0", "commons-validator:commons-validator:1.3.1") {
- excludes "commons-logging", "xml-apis"
- }
-
- "${compileTimeDependenciesMethod}"("aopalliance:aopalliance:1.0",
- "com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.0_jdk5",
- "commons-codec:commons-codec:1.3",
- "commons-collections:commons-collections:3.2.1",
- "commons-io:commons-io:1.4",
- "commons-lang:commons-lang:2.4",
- "javax.transaction:jta:1.1",
- "org.hibernate:ejb3-persistence:1.0.2.GA",
- "opensymphony:sitemesh:2.4",
- "org.grails:grails-bootstrap:$grailsVersion",
- "org.grails:grails-core:$grailsVersion",
- "org.grails:grails-crud:$grailsVersion",
- "org.grails:grails-gorm:$grailsVersion",
- "org.grails:grails-resources:$grailsVersion",
- "org.grails:grails-spring:$grailsVersion",
- "org.grails:grails-web:$grailsVersion",
- "org.springframework:org.springframework.core:3.0.3.RELEASE",
- "org.springframework:org.springframework.aop:3.0.3.RELEASE",
- "org.springframework:org.springframework.aspects:3.0.3.RELEASE",
- "org.springframework:org.springframework.asm:3.0.3.RELEASE",
- "org.springframework:org.springframework.beans:3.0.3.RELEASE",
- "org.springframework:org.springframework.context:3.0.3.RELEASE",
- "org.springframework:org.springframework.context.support:3.0.3.RELEASE",
- "org.springframework:org.springframework.expression:3.0.3.RELEASE",
- "org.springframework:org.springframework.instrument:3.0.3.RELEASE",
- "org.springframework:org.springframework.jdbc:3.0.3.RELEASE",
- "org.springframework:org.springframework.jms:3.0.3.RELEASE",
- "org.springframework:org.springframework.orm:3.0.3.RELEASE",
- "org.springframework:org.springframework.oxm:3.0.3.RELEASE",
- "org.springframework:org.springframework.transaction:3.0.3.RELEASE",
- "org.springframework:org.springframework.web:3.0.3.RELEASE",
- "org.springframework:org.springframework.web.servlet:3.0.3.RELEASE",
- "org.slf4j:slf4j-api:1.5.8") {
- transitive = false
- }
-
- // dependencies needed for running tests
- test "junit:junit:4.8.1",
- "org.grails:grails-test:$grailsVersion",
- "org.springframework:org.springframework.test:3.0.3.RELEASE"
-
- // dependencies needed at runtime only
- "${runtimeDependenciesMethod}" "org.aspectj:aspectjweaver:1.6.8",
- "org.aspectj:aspectjrt:1.6.8",
- "cglib:cglib-nodep:2.1_3",
- "commons-fileupload:commons-fileupload:1.2.1",
- "oro:oro:2.0.8",
- "javax.servlet:jstl:1.1.2"
-
- // data source
- "${runtimeDependenciesMethod}" "commons-dbcp:commons-dbcp:1.2.2",
- "commons-pool:commons-pool:1.5.3",
- "hsqldb:hsqldb:1.8.0.10",
- "com.h2database:h2:1.2.144"
-
- // caching
- "${runtimeDependenciesMethod}" ("net.sf.ehcache:ehcache-core:1.7.1") {
- excludes 'jms', 'commons-logging', 'servlet-api'
- }
-
- // logging
- "${runtimeDependenciesMethod}"("log4j:log4j:1.2.16",
- "org.slf4j:jcl-over-slf4j:1.5.8",
- "org.slf4j:jul-to-slf4j:1.5.8",
- "org.slf4j:slf4j-log4j12:1.5.8" ) {
- excludes 'mail', 'jms', 'jmxtools', 'jmxri'
- }
-
- // JSP support
- "${runtimeDependenciesMethod}" "apache-taglibs:standard:1.1.2",
- "xpp3:xpp3_min:1.1.3.4.O"
}
}
}
@@ -387,46 +415,6 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
(configuredPlugins.contains(name) || configuredPlugins.contains(GrailsNameUtils.getPropertyNameForLowerCaseHyphenSeparatedName(name)))
}
- def configureDependencyDescriptor(EnhancedDefaultDependencyDescriptor dependencyDescriptor, String scope, Closure dependencyConfigurer=null, boolean pluginMode = false) {
- if (!usedConfigurations.contains(scope)) {
- usedConfigurations << scope
- }
-
- try {
- this.currentDependencyDescriptor = dependencyDescriptor
- if (dependencyConfigurer) {
- dependencyConfigurer.resolveStrategy = Closure.DELEGATE_ONLY
- dependencyConfigurer.setDelegate(dependencyDescriptor)
- dependencyConfigurer.call()
- }
- }
- finally {
- this.currentDependencyDescriptor = null
- }
- if (dependencyDescriptor.getModuleConfigurations().length == 0){
- def mappings = configurationMappings[scope]
- if(mappings) {
- for(m in mappings) {
- dependencyDescriptor.addDependencyConfiguration scope, m
- }
- }
- }
- if (!dependencyDescriptor.inherited) {
- hasApplicationDependencies = true
- }
- if (pluginMode) {
- def name = dependencyDescriptor.dependencyId.name
- pluginDependencyNames << name
- pluginDependencyDescriptors << dependencyDescriptor
- pluginNameToDescriptorMap[name] = dependencyDescriptor
- }
- else {
- dependencyDescriptors << dependencyDescriptor
- if (dependencyDescriptor.isExportedToApplication())
- moduleDescriptor.addDependency dependencyDescriptor
- }
- }
-
Set<ModuleRevisionId> getModuleRevisionIds(String org) { orgToDepMap[org] }
/**
@@ -593,60 +581,67 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
* Parses the Ivy DSL definition
*/
void parseDependencies(Closure definition) {
- if (definition && applicationName && applicationVersion) {
- if (this.moduleDescriptor == null) {
- this.moduleDescriptor = createModuleDescriptor()
- }
-
- def evaluator = new IvyDomainSpecificLanguageEvaluator(this)
- definition.delegate = evaluator
- definition.resolveStrategy = Closure.DELEGATE_FIRST
- definition()
- evaluator = null
-
- if (readPom && buildSettings) {
- List dependencies = readDependenciesFromPOM()
-
- if (dependencies != null) {
- for (DependencyDescriptor dependencyDescriptor in dependencies) {
- ModuleRevisionId moduleRevisionId = dependencyDescriptor.getDependencyRevisionId()
- ModuleId moduleId = moduleRevisionId.getModuleId()
-
- String groupId = moduleRevisionId.getOrganisation()
- String artifactId = moduleRevisionId.getName()
- String version = moduleRevisionId.getRevision()
- String scope = Arrays.asList(dependencyDescriptor.getModuleConfigurations()).get(0)
-
- if (!hasDependency(moduleId)) {
- def enhancedDependencyDescriptor = new EnhancedDefaultDependencyDescriptor(moduleRevisionId, false, true, scope)
- for (ExcludeRule excludeRule in dependencyDescriptor.getAllExcludeRules()) {
- ModuleId excludedModule = excludeRule.getId().getModuleId()
- enhancedDependencyDescriptor.addRuleForModuleId(excludedModule, scope)
- }
- configureDependencyDescriptor(enhancedDependencyDescriptor, scope)
- addDependencyDescriptor enhancedDependencyDescriptor
- }
- }
- }
- }
+ this.forkJoinPool = new ForkJoinPool()
+ try {
+ if (definition && applicationName && applicationVersion) {
+ if (this.moduleDescriptor == null) {
+ this.moduleDescriptor = createModuleDescriptor()
+ }
+
+ def evaluator = new IvyDomainSpecificLanguageEvaluator(this)
+ definition.delegate = evaluator
+ definition.resolveStrategy = Closure.DELEGATE_FIRST
+ definition()
+ evaluator = null
+
+ if (readPom && buildSettings) {
+ List dependencies = readDependenciesFromPOM()
+
+ if (dependencies != null) {
+ for (DependencyDescriptor dependencyDescriptor in dependencies) {
+ ModuleRevisionId moduleRevisionId = dependencyDescriptor.getDependencyRevisionId()
+ ModuleId moduleId = moduleRevisionId.getModuleId()
+
+ String groupId = moduleRevisionId.getOrganisation()
+ String artifactId = moduleRevisionId.getName()
+ String version = moduleRevisionId.getRevision()
+ String scope = Arrays.asList(dependencyDescriptor.getModuleConfigurations()).get(0)
+
+ if (!hasDependency(moduleId)) {
+ def enhancedDependencyDescriptor = new EnhancedDefaultDependencyDescriptor(moduleRevisionId, false, true, scope)
+ for (ExcludeRule excludeRule in dependencyDescriptor.getAllExcludeRules()) {
+ ModuleId excludedModule = excludeRule.getId().getModuleId()
+ enhancedDependencyDescriptor.addRuleForModuleId(excludedModule, scope)
+ }
+ configureDependencyDescriptor(enhancedDependencyDescriptor, scope)
+ addDependencyDescriptor enhancedDependencyDescriptor
+ }
+ }
+ }
+ }
+
+ def installedPlugins = metadata?.getInstalledPlugins()
+ if (installedPlugins) {
+ for (entry in installedPlugins) {
+ if (!pluginDependencyNames.contains(entry.key)) {
+ def name = entry.key
+ def scope = "runtime"
+ def mrid = ModuleRevisionId.newInstance("org.grails.plugins", name, entry.value)
+ def dd = new EnhancedDefaultDependencyDescriptor(mrid, true, true, scope)
+ def artifact = new DefaultDependencyArtifactDescriptor(dd, name, "zip", "zip", null, null )
+ dd.addDependencyArtifact(scope, artifact)
+ metadataRegisteredPluginNames << name
+ configureDependencyDescriptor(dd, scope, null, true)
+ pluginDependencyDescriptors << dd
+ }
+ }
+ }
+ }
+ }
+ finally {
+ forkJoinPool.shutdown()
+ }
- def installedPlugins = metadata?.getInstalledPlugins()
- if (installedPlugins) {
- for (entry in installedPlugins) {
- if (!pluginDependencyNames.contains(entry.key)) {
- def name = entry.key
- def scope = "runtime"
- def mrid = ModuleRevisionId.newInstance("org.grails.plugins", name, entry.value)
- def dd = new EnhancedDefaultDependencyDescriptor(mrid, true, true, scope)
- def artifact = new DefaultDependencyArtifactDescriptor(dd, name, "zip", "zip", null, null )
- dd.addDependencyArtifact(scope, artifact)
- metadataRegisteredPluginNames << name
- configureDependencyDescriptor(dd, scope, null, true)
- pluginDependencyDescriptors << dd
- }
- }
- }
- }
}
List readDependenciesFromPOM() {
@@ -669,17 +664,24 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
* @param definition the Ivy DSL definition
*/
void parseDependencies(String pluginName,Closure definition) {
- if (definition) {
- if (moduleDescriptor == null) {
- throw new IllegalStateException("Call parseDependencies(Closure) first to parse the application dependencies")
- }
+ this.forkJoinPool = new ForkJoinPool()
+ try {
+ if (definition) {
+ if (moduleDescriptor == null) {
+ throw new IllegalStateException("Call parseDependencies(Closure) first to parse the application dependencies")
+ }
+
+ def evaluator = new IvyDomainSpecificLanguageEvaluator(this)
+ evaluator.currentPluginBeingConfigured = pluginName
+ definition.delegate = evaluator
+ definition.resolveStrategy = Closure.DELEGATE_FIRST
+ definition()
+ }
+ }
+ finally {
+ forkJoinPool.shutdown()
+ }
- def evaluator = new IvyDomainSpecificLanguageEvaluator(this)
- evaluator.currentPluginBeingConfigured = pluginName
- definition.delegate = evaluator
- definition.resolveStrategy = Closure.DELEGATE_FIRST
- definition()
- }
}
boolean getBooleanValue(dependency, String name) {
@@ -1035,6 +1037,7 @@ class IvyDomainSpecificLanguageEvaluator {
}
void dependencies(Closure deps) {
+ if(pluginsOnly) return
deps?.delegate = this
deps?.call()
}
@@ -1060,6 +1063,10 @@ class IvyDomainSpecificLanguageEvaluator {
private parseDependenciesInternal(dependencies, String scope, Closure dependencyConfigurer) {
boolean usedArgs = false
+
+
+
+
def parseDep = { dependency ->
if ((dependency instanceof CharSequence)) {
def args = [:]
@@ -1108,9 +1115,12 @@ class IvyDomainSpecificLanguageEvaluator {
}
else if (dependency instanceof Map) {
def name = dependency.name
- if (!dependency.group && pluginMode) dependency.group = "org.grails.plugins"
+ def group = dependency.group
+ def version = dependency.version
+
+ if (!group && pluginMode) group = "org.grails.plugins"
- if (dependency.group && name && dependency.version) {
+ if (group && name && version) {
boolean isExcluded = currentPluginBeingConfigured ? isExcludedFromPlugin(currentPluginBeingConfigured, name) : isExcluded(name)
if (!isExcluded) {
def attrs = [:]
@@ -1120,10 +1130,10 @@ class IvyDomainSpecificLanguageEvaluator {
def mrid
if (dependency.branch) {
- mrid = ModuleRevisionId.newInstance(dependency.group, name, dependency.branch, dependency.version, attrs)
+ mrid = ModuleRevisionId.newInstance(group, name, dependency.branch, version, attrs)
}
else {
- mrid = ModuleRevisionId.newInstance(dependency.group, name, dependency.version, attrs)
+ mrid = ModuleRevisionId.newInstance(group, name, version, attrs)
}
def dependencyDescriptor = new EnhancedDefaultDependencyDescriptor(mrid, false, getBooleanValue(dependency, 'transitive'), scope)
@@ -1154,9 +1164,12 @@ class IvyDomainSpecificLanguageEvaluator {
}
}
- for (dep in dependencies) {
- parseDep dep
- if ((dependencies[-1] == dep) && usedArgs) break
- }
+ Parallelizer.withExistingParallelizer(IvyDependencyManager.forkJoinPool) {
+ dependencies.eachParallel { dep ->
+ if((dependencies[-1] == dep) && usedArgs) return
+ parseDep(dep)
+ }
+ }
+
}
}

0 comments on commit e8a528a

Please sign in to comment.
Something went wrong with that request. Please try again.