Skip to content

Commit

Permalink
Fix for GRAILS-6270: the Ivy module descriptor was defaulting to an
Browse files Browse the repository at this point in the history
organisation based on the application name. Such a default does mean
there's a good chance of conflicts with the project's dependencies.

I've hard-coded an organisation of "org.grails.internal". A bit of a
hack, but since the organisation is immaterial at that point in the
code, it works fine. Hopefully no one will publish JARs in that org!
  • Loading branch information
pledbrook committed May 19, 2010
1 parent e778af1 commit 15f3912
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Expand Up @@ -249,8 +249,15 @@ public void addDependencyDescriptor(DependencyDescriptor dd) {
}

public ModuleDescriptor createModuleDescriptor() {
// This is a blatant hack: we use an organisation that is highly
// unlikely to conflict with the project's dependencies. The
// truth is, the dependency manager doesn't really care what the
// organisation is. See:
//
// http://jira.codehaus.org/browse/GRAILS-6270
//
DefaultModuleDescriptor moduleDescriptor =
DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(applicationName, applicationName, applicationVersion));
DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance("org.grails.internal", applicationName, applicationVersion));

// TODO: make configurations extensible
moduleDescriptor.addConfiguration( BUILD_CONFIGURATION );
Expand Down
Expand Up @@ -693,14 +693,11 @@ public class IvyDependencyManager extends AbstractIvyDependencyManager implement
}
}


boolean getBooleanValue(dependency, String name) {
return dependency.containsKey(name) ? Boolean.valueOf(dependency[name]) : true
}



}

class IvyDomainSpecificLanguageEvaluator {

static final String WILDCARD = '*'
Expand Down
Expand Up @@ -629,7 +629,7 @@ public class IvyDependencyManagerTests extends GroovyTestCase{
void testListDependencies() {
def manager = new IvyDependencyManager("test", "0.1")
manager.parseDependencies TEST_DATA
assertEquals 12, manager.listDependencies("build").size()
assertEquals 13, manager.listDependencies("build").size()
assertEquals 21, manager.listDependencies("runtime").size()
assertEquals 22, manager.listDependencies("test").size()
}
Expand Down Expand Up @@ -667,6 +667,15 @@ public class IvyDependencyManagerTests extends GroovyTestCase{
ModuleRevisionId junit = manager.dependencies.find { ModuleRevisionId m -> m.organisation == 'junit'}
}

void testCreateModuleDescriptor() {
def manager = new IvyDependencyManager("test", "0.1")
def md = manager.createModuleDescriptor()

assert md.moduleRevisionId.organisation == "org.grails.internal"
assert md.moduleRevisionId.name == "test"
assert md.moduleRevisionId.revision == "0.1"
}


static final TEST_DATA = {
repositories {
Expand All @@ -687,7 +696,8 @@ public class IvyDependencyManagerTests extends GroovyTestCase{
"javax.servlet:servlet-api:2.5",
"javax.servlet:jsp-api:2.1",
"javax.servlet:jstl:1.1.2",
"xalan:serializer:2.7.1"
"xalan:serializer:2.7.1",
"test:test:0.5"

test "junit:junit:4.8.1"

Expand Down

0 comments on commit 15f3912

Please sign in to comment.