diff --git a/.gitignore b/.gitignore
index eea1679a2f..c224a9835c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/hibernate-enhance-maven-plugin/hibernate-enhance-maven-plugin.gradle b/hibernate-enhance-maven-plugin/hibernate-enhance-maven-plugin.gradle
index 0b6966a4cc..68c47ada48 100644
--- a/hibernate-enhance-maven-plugin/hibernate-enhance-maven-plugin.gradle
+++ b/hibernate-enhance-maven-plugin/hibernate-enhance-maven-plugin.gradle
@@ -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,7 +37,41 @@ dependencies {
configurations.remove(configurations.getByName('testCompile'))
configurations.remove(configurations.getByName('testRuntime'))
-task writeNewPom(type:Task, description: 'Writes pom.xml using merged Gradle dependency and MavenPom configuration.') {
+// 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 \
+ ""\
+ + "" + split[0] + ""\
+ + "" + split[1] + ""\
+ + "jar"\
+ + "" + split[2] + ""\
+ + "\n"
+}
+
+task writeNewPom(type:Task, description: 'Writes pom.xml using merged Gradle dependency and MavenPom configuration.') {
ext.pomDefinition = pom {
project {
groupId project.group
@@ -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
diff --git a/hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml b/hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml.original
similarity index 71%
rename from hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml
rename to hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml.original
index ea4d1d4096..08aea62758 100644
--- a/hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml
+++ b/hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml.original
@@ -44,12 +44,9 @@
-
- org.jboss.logging
- jboss-logging
- jar
- 3.1.0.GA
-
+
+ @generated-dependencies@
+
org.codehaus.plexus
plexus-utils
@@ -68,42 +65,6 @@
jar
3.0
-
- org.hibernate
- hibernate-core
- jar
- 4.2.8.Final
-
-
- antlr
- antlr
- jar
- 2.7.7
-
-
- dom4j
- dom4j
- jar
- 1.6.1
-
-
- org.jboss.spec.javax.transaction
- jboss-transaction-api_1.1_spec
- jar
- 1.0.1.Final
-
-
- org.hibernate.common
- hibernate-commons-annotations
- jar
- 4.0.2.Final
-
-
- org.hibernate.javax.persistence
- hibernate-jpa-2.0-api
- jar
- 1.0.1.Final
-
org.apache.maven
maven-plugin-api
@@ -152,11 +113,5 @@
jar
0.9.9
-
- org.javassist
- javassist
- jar
- 3.18.1-GA
-
-
\ No newline at end of file
+