Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:grails/grails-core.git
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Sep 26, 2011
2 parents e4baa7f + d42ba28 commit 944896b
Show file tree
Hide file tree
Showing 38 changed files with 425 additions and 87 deletions.
12 changes: 8 additions & 4 deletions build.gradle
Expand Up @@ -23,9 +23,11 @@ commonsCollectionsVersion = "3.2.1"
commonsIOVersion = "2.0.1"
commonsLangVersion = "2.6"
datastoreVersion = "1.0.0.BUILD-SNAPSHOT"
gantVersion = "1.9.5"
gantVersion = "1.9.6"
gdocEngineVersion = "1.0.1"
groovyVersion = "1.8.2"
groovyVersion = "1.8.3-SNAPSHOT"
gradleGroovyVersion = groovyVersion
gradleGroovyVersion = "1.8.2"
ivyVersion = "2.2.0"
jansiVersion = "1.2.1"
jlineVersion = "1.0"
Expand Down Expand Up @@ -56,8 +58,10 @@ homeSrcDir = file("src")
// artifacts' POMs.
if(System.getProperty('groovy.jar')) {
groovyDependency = files(System.getProperty('groovy.jar'))
gradleGroovyDependency = groovyDependency
} else {
groovyDependency = "org.codehaus.groovy:groovy-all:${groovyVersion}"
gradleGroovyDependency = "org.codehaus.groovy:groovy-all:${gradleGroovyVersion}"
}


Expand Down Expand Up @@ -115,10 +119,10 @@ subprojects { project ->
// Groovy
if(System.getProperty('groovy.jar')) {
// use the jar specified in the system property (the joint build specifies its own groovy jar)...
groovy groovyDependency
groovy gradleGroovyDependency
} else {
// resolve the dependency from a repo...
groovy( groovyDependency ) {
groovy( gradleGroovyDependency ) {
exclude module:"commons-cli"
exclude module:"ant"
}
Expand Down
9 changes: 7 additions & 2 deletions gradle/assemble.gradle
Expand Up @@ -55,10 +55,15 @@ task pluginsFromSvn {
ant {
mkdir(dir: dir)
def versionTag = grailsVersion.replaceAll(/\./, '_').toUpperCase()
get(src: "http://svn.codehaus.org/grails-plugins/grails-hibernate/tags/RELEASE_${versionTag}/grails-hibernate-${grailsVersion}.zip",
get(src: "http://plugins.grails.org/grails-hibernate/tags/RELEASE_${versionTag}/grails-hibernate-${grailsVersion}.zip",
dest: grailsHibernateDest, verbose: true, usetimestamp: true)
get(src: "http://svn.codehaus.org/grails-plugins/grails-tomcat/tags/RELEASE_${versionTag}/grails-tomcat-${grailsVersion}.zip",
get(src: "http://plugins.grails.org/grails-tomcat/tags/RELEASE_${versionTag}/grails-tomcat-${grailsVersion}.zip",
dest: grailsTomcatDest, verbose: true, usetimestamp: true)
get(src: "http://plugins.grails.org/grails-resources/tags/RELEASE_1_0_2/grails-resources-1.0.2.zip",
dest: dir, verbose: true, usetimestamp: true)
get(src: "http://plugins.grails.org/grails-jquery/tags/RELEASE_1_6_1_1/grails-jquery-1.6.1.1.zip",
dest: dir, verbose: true, usetimestamp: true)

}
}
}
Expand Down
11 changes: 11 additions & 0 deletions grails-bootstrap/src/main/groovy/grails/util/BuildSettings.groovy
Expand Up @@ -67,6 +67,8 @@ class BuildSettings extends AbstractBuildSettings {
*/
public static final String PROJECT_WORK_DIR = "grails.project.work.dir"

public static final String OFFLINE_MODE= "grails.offline.mode"

/**
* The name of the system property for {@link #projectWarExplodedDir}.
*/
Expand Down Expand Up @@ -354,6 +356,11 @@ class BuildSettings extends AbstractBuildSettings {
*/
boolean modified = false

/**
* Whether the build is allowed to connect to remote servers to resolve dependencies
*/
boolean offline = false

GrailsCoreDependencies coreDependencies

private List<File> compileDependencies = []
Expand Down Expand Up @@ -1134,6 +1141,7 @@ class BuildSettings extends AbstractBuildSettings {
dependencyManager = new IvyDependencyManager(appName,
appVersion, this, metadata)

dependencyManager.offline = offline
dependencyManager.includeJavadoc = includeJavadoc
dependencyManager.includeSource = includeSource

Expand Down Expand Up @@ -1276,6 +1284,9 @@ class BuildSettings extends AbstractBuildSettings {
// settings provided by, for example, the Maven plugin.
def props = config.toProperties()
def metadata = Metadata.current

offline = Boolean.valueOf(getPropertyValue(OFFLINE_MODE, props, String.valueOf(offline)))

if (!grailsWorkDirSet) {
grailsWorkDir = new File(getPropertyValue(WORK_DIR, props, "${userHome}/.grails/${grailsVersion}"))
}
Expand Down
Expand Up @@ -63,7 +63,6 @@
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.util.Log4jConfigurer;

/**
* Handles Grails command line interface for running scripts.
Expand Down Expand Up @@ -162,9 +161,8 @@ public static void main(String[] args) {
BuildSettings build = null;
try {
build = new BuildSettings(new File(grailsHome));
if (commandLine.hasOption(CommandLine.RESOLVE_DEPENDENCIES_ARGUMENT)) {
build.setModified(true);
}
build.setModified(commandLine.hasOption(CommandLine.RESOLVE_DEPENDENCIES_ARGUMENT));
build.setOffline(commandLine.hasOption(CommandLine.OFFLINE_ARGUMENT));
if (build.getRootLoader() == null) {
build.setRootLoader((URLClassLoader) GrailsScriptRunner.class.getClassLoader());
}
Expand Down Expand Up @@ -243,6 +241,7 @@ public static CommandLineParser getCommandLineParser() {
CommandLineParser parser = new CommandLineParser();
parser.addOption(CommandLine.RESOLVE_DEPENDENCIES_ARGUMENT, "Whether to force a resolve of dependencies (skipping any caching)");
parser.addOption(CommandLine.VERBOSE_ARGUMENT, "Enable verbose output");
parser.addOption(CommandLine.OFFLINE_ARGUMENT, "Indicates that Grails should not connect to any remote servers during processing of the build");
parser.addOption(CommandLine.STACKTRACE_ARGUMENT, "Enable stack traces in output");
parser.addOption(CommandLine.AGENT_ARGUMENT, "Enable the reloading agent");
parser.addOption(CommandLine.NON_INTERACTIVE_ARGUMENT, "Whether to allow the command line to request input");
Expand Down Expand Up @@ -562,9 +561,9 @@ protected void initializeLogging() {
}

try {
Log4jConfigurer.initLogging("file:" + settings.getGrailsHome() + "/scripts/log4j.properties");
} catch (FileNotFoundException e) {
// ignore, Log4j will print an error in this case
org.springframework.util.Log4jConfigurer.initLogging("file:" + settings.getGrailsHome() + "/scripts/log4j.properties");
} catch (Throwable e) {
console.verbose("Log4j was not found on the classpath and will not be used for command line logging. Cause "+e.getClass().getName()+": " + e.getMessage());
}
}

Expand Down
Expand Up @@ -27,6 +27,7 @@
*/
public interface CommandLine {

String OFFLINE_ARGUMENT = "offline";
String VERBOSE_ARGUMENT = "verbose";
String STACKTRACE_ARGUMENT = "stacktrace";
String AGENT_ARGUMENT = "reloading";
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.resolver.ChainResolver;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser;
import org.codehaus.groovy.grails.resolve.config.DependencyConfigurationConfigurer;
Expand All @@ -45,6 +46,8 @@
*/
public abstract class AbstractIvyDependencyManager {

public static final String SNAPSHOT_CHANGING_PATTERN = ".*SNAPSHOT";

/*
* Out of the box Ivy configurations are:
*
Expand Down Expand Up @@ -137,11 +140,55 @@ public abstract class AbstractIvyDependencyManager {
final protected IvySettings ivySettings;
final protected BuildSettings buildSettings;
final protected Metadata metadata;
private boolean offline;

private ChainResolver chainResolver;


public AbstractIvyDependencyManager(IvySettings ivySettings, BuildSettings buildSettings, Metadata metadata) {
this.ivySettings = ivySettings;
this.buildSettings = buildSettings;
this.metadata = metadata;

chainResolver = new ChainResolver();

// Use the name cache because the root chain resolver is the one that is shown to have resolved the dependency
// when it is resolved in the cache, which makes Ivy debug output easier to understand by making it clear what
// came from the cache
chainResolver.setName("cache");

chainResolver.setReturnFirst(true);
updateChangingPattern(chainResolver);
}

public void setOffline(boolean offline) {
this.offline = offline;
updateChangingPattern(chainResolver);
}

private void updateChangingPattern(ChainResolver chainResolver) {
chainResolver.setChangingPattern(isOffline() ? null : IvyDependencyManager.SNAPSHOT_CHANGING_PATTERN);
}

public ChainResolver getChainResolver() {
return chainResolver;
}

public BuildSettings getBuildSettings() {
return buildSettings;
}

public Metadata getMetadata() {
return metadata;
}

public void setChainResolver(ChainResolver chainResolver) {
this.chainResolver = chainResolver;
updateChangingPattern(chainResolver);
}

public boolean isOffline() {
return offline;
}

public void setIncludeSource(boolean includeSource) {
Expand Down Expand Up @@ -497,6 +544,8 @@ private void doParseDependencies(Closure<?> definition, String pluginName) {
context = DependencyConfigurationContext.forPlugin(dependencyManager, pluginName);
}

context.setOffline(this.offline);

definition.setDelegate(new DependencyConfigurationConfigurer(context));
definition.setResolveStrategy(Closure.DELEGATE_FIRST);
definition.call();
Expand All @@ -506,6 +555,10 @@ private void doParseDependencies(Closure<?> definition, String pluginName) {
* Aspects of registering a dependency common to both plugins and jar dependencies.
*/
private void registerDependencyCommon(String scope, EnhancedDefaultDependencyDescriptor descriptor, boolean isPluginDep) {
if (offline && descriptor.isChanging()) {
descriptor.setChanging(false);
}

registerUsedConfigurationIfNecessary(scope);

if (descriptor.getModuleConfigurations().length == 0) {
Expand Down
Expand Up @@ -149,7 +149,7 @@ public Object doCall() {

// dependencies needed at compile time
ModuleRevisionId[] groovyDependencies = {
ModuleRevisionId.newInstance("org.codehaus.groovy", "groovy-all", "1.8.2")
ModuleRevisionId.newInstance("org.codehaus.groovy", "groovy-all", "1.8.3-SNAPSHOT")
};
registerDependencies(dependencyManager, compileTimeDependenciesMethod, groovyDependencies, "jline");

Expand Down
Expand Up @@ -44,14 +44,8 @@ import org.codehaus.groovy.grails.plugins.VersionComparator
*/
class IvyDependencyManager extends AbstractIvyDependencyManager implements DependencyResolver, DependencyDefinitionParser{

static final SNAPSHOT_CHANGING_PATTERN = ".*SNAPSHOT"

ResolveEngine resolveEngine
MessageLogger logger
ChainResolver chainResolver = new ChainResolver(
name: "default",
returnFirst: true,
changingPattern: SNAPSHOT_CHANGING_PATTERN)

Collection repositoryData = new ConcurrentLinkedQueue()

Expand All @@ -67,8 +61,8 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
/**
* Creates a new IvyDependencyManager instance
*/
IvyDependencyManager(String applicationName, String applicationVersion, BuildSettings settings=null, Metadata metadata = null) {
super(new IvySettings(), settings, metadata)
IvyDependencyManager(String applicationName, String applicationVersion, BuildSettings settings=null, Metadata metadata = null, IvySettings ivySettings = new IvySettings()) {
super(ivySettings, settings, metadata)

ivySettings.defaultInit()
// don't cache for snapshots
Expand All @@ -88,13 +82,23 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
this.applicationVersion = applicationVersion
}

IvyDependencyManager createCopy(BuildSettings buildSettings) {
IvyDependencyManager copy = new IvyDependencyManager(applicationName, applicationVersion, buildSettings)
copy.offline = offline
copy.chainResolver = chainResolver
if (logger) {
copy.logger = logger
}
copy
}

/**
* Allows settings an alternative chain resolver to be used
* @param resolver The resolver to be used
*/
void setChainResolver(ChainResolver resolver) {
this.chainResolver = resolver
resolveEngine.dictatorResolver = chainResolver
super.setChainResolver(chainResolver)
}

/**
Expand All @@ -109,11 +113,6 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen

MessageLogger getLogger() { this.logger }

/**
* @return The current chain resolver
*/
ChainResolver getChainResolver() { chainResolver }

/**
* Resets the Grails plugin resolver if it is used
*/
Expand Down
Expand Up @@ -119,8 +119,8 @@ class PluginInstallEngine {
it.changing || rootChangingPatternCompiled?.matcher(it.dependencyRevisionId.revision)?.matches()
}
if (changingPlugins) {
def noChangingPlugins = changingPlugins.size()
eventHandler "StatusUpdate", "Checking ${noChangingPlugins} changing plugin${noChangingPlugins > 1 ? 's' : ''} for updates"
def numChangingPlugins = changingPlugins.size()
eventHandler "StatusUpdate", "Checking ${numChangingPlugins} changing plugin${numChangingPlugins > 1 ? 's' : ''} for updates"
installPlugins(changingPlugins)
eventHandler "StatusUpdate", "Changing plugin checking complete"
}
Expand Down Expand Up @@ -205,8 +205,8 @@ class PluginInstallEngine {
dependencyManager.parseDependencies {
log "warn"
repositories {
def pluginResolver = new FileSystemResolver(name: name)
pluginResolver.addArtifactPattern("${parentDir.absolutePath}/grails-[module]-[revision].[ext]")
def pluginResolver = new FileSystemResolver(name: "$name plugin install resolver")
pluginResolver.addArtifactPattern("${parentDir.absolutePath}/[module]-[revision].[ext]")
pluginResolver.settings = dependencyManager.ivySettings
pluginResolver.latestStrategy = new LatestTimeStrategy()
pluginResolver.changingPattern = ".*SNAPSHOT"
Expand Down
Expand Up @@ -44,13 +44,7 @@ final class PluginResolveEngine {
}

IvyDependencyManager createFreshDependencyManager() {
IvyDependencyManager dm = new IvyDependencyManager(dependencyManager.applicationName,
dependencyManager.applicationVersion ?: "0.1", settings)
dm.chainResolver = dependencyManager.chainResolver
if (dependencyManager.logger) {
dm.logger = dependencyManager.logger
}
return dm
dependencyManager.createCopy(settings)
}

/**
Expand Down
Expand Up @@ -102,7 +102,7 @@ private ResolvedResource findSnapshotArtifact(Artifact artifact, Date date,
getDefaultRMDParser(artifact.getModuleRevisionId().getModuleId()), date);

if (uniqueResource != null) {
return new LastModifiedResolvedResource(uniqueResource.getResource(), rev.uniqueRevision, rev.lastModified);
return new LastModifiedResolvedResource(uniqueResource.getResource(), rev.revision, rev.lastModified);
}

pattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + mrid.getRevision());
Expand Down Expand Up @@ -133,7 +133,7 @@ private ResolvedResource findSnapshotDescriptor(DependencyDescriptor dd, Resolve
mrid, data.getDate()), getRMDParser(dd, data), data.getDate());

if (uniqueResource != null) {
return new LastModifiedResolvedResource(uniqueResource.getResource(), rev.uniqueRevision, rev.lastModified);
return new LastModifiedResolvedResource(uniqueResource.getResource(), rev.revision, rev.lastModified);
}

pattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + mrid.getRevision());
Expand Down
Expand Up @@ -25,6 +25,7 @@ public class DependencyConfigurationContext {
final public String pluginName;
final public boolean inherited;
final public boolean exported;
private boolean offline;

private DependencyConfigurationContext(IvyDependencyManager dependencyManager, String pluginName, boolean inherited) {
this.dependencyManager = dependencyManager;
Expand All @@ -41,6 +42,14 @@ private DependencyConfigurationContext(IvyDependencyManager dependencyManager, S
}
}

public boolean isOffline() {
return offline;
}

public void setOffline(boolean offline) {
this.offline = offline;
}

static public DependencyConfigurationContext forApplication(IvyDependencyManager dependencyManager) {
return new DependencyConfigurationContext(dependencyManager, null, false);
}
Expand Down

0 comments on commit 944896b

Please sign in to comment.