HHH-8777 dynamically generate descriptor dependencies

This commit is contained in:
Brett Meyer 2014-01-31 11:39:02 -05:00
parent 85792026ae
commit 67dcb38b91
3 changed files with 53 additions and 76 deletions

1
.gitignore vendored
View File

@ -42,3 +42,4 @@ ObjectStore
# Maven Enhance Plugin
hibernate-enhance-maven-plugin/src/main/resources/pom.xml
hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml

View File

@ -1,6 +1,8 @@
apply plugin: 'java'
apply plugin: 'maven'
import org.apache.tools.ant.filters.ReplaceTokens
group = 'org.hibernate.orm.tooling'
repositories {
@ -17,33 +19,17 @@ processResources.doLast {
}
dependencies {
compile( libraries.maven_plugin ) {
transitive = false
}
compile( libraries.maven_plugin_tools ) {
transitive = false
}
compile( project(':hibernate-core') ) {
transitive = false
}
compile( libraries.jpa ){
transitive = false
}
compile( libraries.javassist ){
transitive = false
}
compile( libraries.maven_plugin ) { transitive = false }
compile( libraries.maven_plugin_tools ) { transitive = false }
compile( project(':hibernate-core') ) { transitive = false }
compile( libraries.jpa ) { transitive = false }
compile( libraries.javassist ) { transitive = false }
compile 'org.codehaus.plexus:plexus-utils:3.0.1'
runtime( libraries.maven_plugin ) {
}
runtime( libraries.maven_plugin_tools ) {
}
runtime( project(':hibernate-core') ) {
}
runtime( libraries.jpa ){
}
runtime( libraries.javassist ){
}
runtime( libraries.maven_plugin )
runtime( libraries.maven_plugin_tools )
runtime( project(':hibernate-core') )
runtime( libraries.jpa )
runtime( libraries.javassist )
runtime 'org.codehaus.plexus:plexus-utils:3.0.1'
}
@ -51,6 +37,40 @@ dependencies {
configurations.remove(configurations.getByName('testCompile'))
configurations.remove(configurations.getByName('testRuntime'))
// Inject dependencies into plugin.xml
// Note: injecting the full dependency, rather than just the version,
// removing the need to maintain artifact names that might change with upgrades (JPA/JTA API version, etc.)
task processPluginXml(type: Copy) {
// force out-of-date if version changes
inputs.property("version", project.version)
from "src/main/resources/META-INF/maven/plugin.xml.original"
into "src/main/resources/META-INF/maven"
rename ("plugin.xml.original", "plugin.xml")
filter(ReplaceTokens, tokens: ['generated-dependencies' :\
generateMavenDependency(libraries.jpa)\
+ generateMavenDependency(libraries.antlr)\
+ generateMavenDependency(libraries.dom4j)\
+ generateMavenDependency(libraries.jta)\
+ generateMavenDependency(libraries.commons_annotations)\
+ generateMavenDependency(libraries.javassist)\
+ generateMavenDependency(libraries.logging)\
+ generateMavenDependency("org.hibernate:hibernate-core:" + project.version)])
}
// TODO: There may be a way to do this directly with Gradle's Maven plugin, but it's still incubating
// and I'd rather not rely on it yet.
def generateMavenDependency(String gradleDependency) {
String[] split = gradleDependency.split(":")
return \
"<dependency>"\
+ "<groupId>" + split[0] + "</groupId>"\
+ "<artifactId>" + split[1] + "</artifactId>"\
+ "<type>jar</type>"\
+ "<version>" + split[2] + "</version>"\
+ "</dependency>\n"
}
task writeNewPom(type:Task, description: 'Writes pom.xml using merged Gradle dependency and MavenPom configuration.') {
ext.pomDefinition = pom {
project {
@ -85,5 +105,6 @@ task writeNewPom(type:Task, description: 'Writes pom.xml using merged Gradle dep
ext.pomDefinition.writeTo("$projectDir/src/main/resources/pom.xml")
}
writeNewPom.dependsOn processPluginXml
processResources.dependsOn writeNewPom

View File

@ -44,12 +44,9 @@
</mojo>
</mojos>
<dependencies>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<type>jar</type>
<version>3.1.0.GA</version>
</dependency>
<!-- Generated by Gradle -->
@generated-dependencies@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
@ -68,42 +65,6 @@
<type>jar</type>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<type>jar</type>
<version>4.2.8.Final</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<type>jar</type>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<type>jar</type>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
<type>jar</type>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<type>jar</type>
<version>4.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<type>jar</type>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
@ -152,11 +113,5 @@
<type>jar</type>
<version>0.9.9</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<type>jar</type>
<version>3.18.1-GA</version>
</dependency>
</dependencies>
</plugin>