Skip to content
Browse files

Aether: fix POM generation

  • Loading branch information...
1 parent c2e3e34 commit eef64f69c49f12bd76077c4285d83ca3c4026c97 @graemerocher graemerocher committed
View
22 ...ain/groovy/org/codehaus/groovy/grails/resolve/maven/aether/AetherDependencyManager.groovy
@@ -17,6 +17,7 @@ package org.codehaus.groovy.grails.resolve.maven.aether
import grails.build.logging.GrailsConsole
import grails.util.BuildSettings
import groovy.transform.CompileStatic
+import groovy.transform.TypeCheckingMode
import groovy.util.slurpersupport.GPathResult
import org.apache.maven.model.building.DefaultModelBuildingRequest
import org.apache.maven.model.building.ModelBuilder
@@ -83,6 +84,7 @@ class AetherDependencyManager implements DependencyManager{
private Set <org.codehaus.groovy.grails.resolve.Dependency> grailsPluginDependencies = []
private List<Dependency> buildDependencies = []
private Map<String, List<org.codehaus.groovy.grails.resolve.Dependency>> grailsDependenciesByScope = [:].withDefault { [] }
+ private Map<String, List<org.codehaus.groovy.grails.resolve.Dependency>> grailsPluginDependenciesByScope = [:].withDefault { [] }
private List<org.codehaus.groovy.grails.resolve.Dependency> grailsDependencies = []
private List<RemoteRepository> repositories = []
String cacheDir
@@ -409,6 +411,7 @@ class AetherDependencyManager implements DependencyManager{
aetherDependencies << dependency
if (dependency.artifact.groupId == 'org.grails.plugins' || dependency.artifact.properties.extension == 'zip') {
grailsPluginDependencies << grailsDependency
+ grailsPluginDependenciesByScope[dependency.scope] << grailsDependency
}
}
@@ -436,6 +439,7 @@ class AetherDependencyManager implements DependencyManager{
buildDependencies << mavenDependency
if (dependency.group == 'org.grails.plugins' || dependency.properties.extension == 'zip') {
grailsPluginDependencies << dependency
+ grailsPluginDependenciesByScope["build"] << dependency
}
}
@@ -448,6 +452,7 @@ class AetherDependencyManager implements DependencyManager{
buildDependencies << dependency
if (dependency.artifact.groupId == 'org.grails.plugins' || dependency.artifact.properties.extension == 'zip') {
grailsPluginDependencies << grailsDependency
+ grailsPluginDependenciesByScope["build"] << grailsDependency
}
}
@@ -463,13 +468,18 @@ class AetherDependencyManager implements DependencyManager{
grailsDependencies << dependency
grailsDependenciesByScope[scope] << dependency
dependencies << mavenDependency
- if (dependency.group == 'org.grails.plugins' || dependency.properties.extension == 'zip') {
+ if (isGrailsPlugin(dependency)) {
grailsPluginDependencies.add dependency
+ grailsPluginDependenciesByScope[scope] << dependency
}
}
}
+ protected boolean isGrailsPlugin(org.codehaus.groovy.grails.resolve.Dependency dependency) {
+ dependency.group == 'org.grails.plugins' || dependency.properties.extension == 'zip'
+ }
+
@Override
DependencyManager createCopy(BuildSettings buildSettings) {
AetherDependencyManager dependencyManager = new AetherDependencyManager()
@@ -479,8 +489,9 @@ class AetherDependencyManager implements DependencyManager{
}
@Override
+ @CompileStatic(TypeCheckingMode.SKIP)
Collection<org.codehaus.groovy.grails.resolve.Dependency> getApplicationDependencies() {
- return grailsDependencies.findAll{ org.codehaus.groovy.grails.resolve.Dependency d -> !d.inherited }.asImmutable()
+ return grailsDependencies.findAll{ org.codehaus.groovy.grails.resolve.Dependency d -> !d.inherited && !isGrailsPlugin(d)}.asImmutable()
}
@Override
@@ -489,8 +500,13 @@ class AetherDependencyManager implements DependencyManager{
}
@Override
+ @CompileStatic(TypeCheckingMode.SKIP)
Collection<org.codehaus.groovy.grails.resolve.Dependency> getApplicationDependencies(String scope) {
- return grailsDependenciesByScope[scope].findAll{ org.codehaus.groovy.grails.resolve.Dependency d -> !d.inherited }.asImmutable()
+ return grailsDependenciesByScope[scope].findAll{ org.codehaus.groovy.grails.resolve.Dependency d -> !d.inherited && !isGrailsPlugin(d) }.asImmutable()
+ }
+
+ Collection<org.codehaus.groovy.grails.resolve.Dependency> getPluginDependencies(String scope) {
+ return grailsPluginDependenciesByScope[scope].findAll{ org.codehaus.groovy.grails.resolve.Dependency d -> !d.inherited }.asImmutable()
}
@Override
View
16 ...s-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/maven/MavenPomGenerator.groovy
@@ -19,7 +19,9 @@ import org.codehaus.groovy.grails.cli.api.BaseSettingsApi
import grails.util.BuildSettings
import grails.util.Metadata
-import org.codehaus.groovy.grails.plugins.GrailsPluginUtils;
+import org.codehaus.groovy.grails.plugins.GrailsPluginUtils
+import org.codehaus.groovy.grails.resolve.Dependency
+import org.codehaus.groovy.grails.resolve.DependencyManager;
import org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor
import org.apache.ivy.core.module.descriptor.DependencyDescriptor
import org.codehaus.groovy.grails.resolve.IvyDependencyManager
@@ -89,14 +91,14 @@ class MavenPomGenerator extends BaseSettingsApi{
}
}
- def addDependenciesForScope(IvyDependencyManager dependencyManager, String scope, ArrayList<String> dependencies, String type = "", String newScope = null) {
- final appDependencies = type ? dependencyManager.effectivePluginDependencyDescriptors : dependencyManager.getApplicationDependencyDescriptors(scope)
- dependencies.addAll(appDependencies.findAll { EnhancedDefaultDependencyDescriptor dd -> dd.scope == scope }.collect() { EnhancedDefaultDependencyDescriptor dd ->
+ protected void addDependenciesForScope(DependencyManager dependencyManager, String scope, ArrayList<String> dependencies, String type = "", String newScope = null) {
+ Collection<Dependency> appDependencies = type ? dependencyManager.getPluginDependencies(scope) : dependencyManager.getApplicationDependencies(scope)
+ dependencies.addAll(appDependencies.collect { Dependency dd ->
"""
<dependency>
- <groupId>$dd.dependencyId.organisation</groupId>
- <artifactId>$dd.dependencyId.name</artifactId>
- <version>$dd.dependencyRevisionId.revision</version>
+ <groupId>$dd.group</groupId>
+ <artifactId>$dd.name</artifactId>
+ <version>$dd.version</version>
<scope>${ newScope ?: scope }</scope>
$type
</dependency>
View
8 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/DependencyManager.java
@@ -107,6 +107,14 @@
Collection<Dependency> getApplicationDependencies(String scope);
/**
+ * The direct plugin dependencies of the application, not including framework or dependencies inherited from plugins
+ *
+ * @param scope The scope of the dependencies
+ * @return Direct application dependencies
+ */
+ Collection<Dependency> getPluginDependencies(String scope);
+
+ /**
* All dependencies of the current application
*
* @param scope The scope of the dependencies
View
4 ...-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/IvyDependencyManager.groovy
@@ -452,6 +452,10 @@ class IvyDependencyManager extends AbstractIvyDependencyManager implements Depen
convertToGrailsDependencies(getApplicationDependencyDescriptors().findAll { it.scope == scope })
}
+ Collection<Dependency> getPluginDependencies(String scope) {
+ convertToGrailsDependencies(effectivePluginDependencyDescriptors.findAll { EnhancedDefaultDependencyDescriptor dd -> dd.scope == scope})
+ }
+
@Override
Collection<Dependency> getAllDependencies(String scope) {
convertToGrailsDependencies(dependencyDescriptors.findAll { it.scope == scope })

0 comments on commit eef64f6

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