HHH-9679 - Fix hibernate-enhance-maven-plugin buid script

This commit is contained in:
barreiro 2015-03-26 01:41:23 +00:00 committed by Steve Ebersole
parent 3b9b2eaa91
commit 81d30aa037
7 changed files with 39 additions and 56 deletions

4
.gitignore vendored
View File

@ -40,7 +40,3 @@ ObjectStore
# Profiler and heap dumps # Profiler and heap dumps
*.jps *.jps
*.hprof *.hprof
# Maven Enhance Plugin
tooling/hibernate-enhance-maven-plugin/src/main/resources/pom.xml
tooling/hibernate-enhance-maven-plugin/src/main/resources/META-INF/maven/plugin.xml

View File

@ -1415,7 +1415,7 @@ hibernate.cache.use_structured_entries true</programlisting>
the compile task as the source location of entity class files to enhance. the compile task as the source location of entity class files to enhance.
<programlisting>apply plugin: 'java' <programlisting>apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'
apply plugin: 'enhance' apply plugin: 'hibernate'
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
@ -1426,7 +1426,6 @@ buildscript {
} }
dependencies { dependencies {
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-[SPEC-VERSION]-api', version: '[IMPL-VERSION]' compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-[SPEC-VERSION]-api', version: '[IMPL-VERSION]'
compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: 'VERSION'
} }
</programlisting> </programlisting>
</para> </para>

View File

@ -26,9 +26,8 @@ project(':metamodel-generator').name = 'hibernate-jpamodelgen'
include 'hibernate-gradle-plugin' include 'hibernate-gradle-plugin'
project(':hibernate-gradle-plugin').projectDir = new File(rootProject.projectDir, "tooling/hibernate-gradle-plugin") project(':hibernate-gradle-plugin').projectDir = new File(rootProject.projectDir, "tooling/hibernate-gradle-plugin")
// Temporarily disabled : HHH-9679 include 'hibernate-enhance-maven-plugin'
//include 'hibernate-enhance-maven-plugin' project(':hibernate-enhance-maven-plugin').projectDir = new File(rootProject.projectDir, "tooling/hibernate-enhance-maven-plugin")
//project(':hibernate-enhance-maven-plugin').projectDir = new File(rootProject.projectDir, "tooling/hibernate-enhance-maven-plugin")
rootProject.children.each { project -> rootProject.children.each { project ->
project.buildFileName = "${project.name}.gradle" project.buildFileName = "${project.name}.gradle"

View File

@ -9,13 +9,10 @@ repositories {
mavenCentral() mavenCentral()
} }
processResources.doLast { processResources {
project.build.outputDirectory = '${project.build.outputDirectory}' include "**/plugin-help.xml"
copy { into processResources.destinationDir
from 'src/main/resources' filter(ReplaceTokens, tokens: ['version' : project.version])
into processResources.destinationDir
expand ([ version: version, project: project, dir: '${dir}' ])
}
} }
dependencies { dependencies {
@ -39,11 +36,10 @@ dependencies {
task processPluginXml(type: Copy) { task processPluginXml(type: Copy) {
// force out-of-date if version changes // force out-of-date if version changes
inputs.property("version", project.version) inputs.property("version", project.version)
from "src/main/resources/META-INF/maven/plugin.xml.original" from "src/main/resources/META-INF/maven/plugin.xml"
into "src/main/resources/META-INF/maven" into "$processResources.destinationDir/META-INF/maven"
rename ("plugin.xml.original", "plugin.xml") filter(ReplaceTokens, tokens: ['version' : project.version, 'generated-dependencies' :\
filter(ReplaceTokens, tokens: ['generated-dependencies' :\
generateMavenDependency(libraries.jpa)\ generateMavenDependency(libraries.jpa)\
+ generateMavenDependency(libraries.antlr)\ + generateMavenDependency(libraries.antlr)\
+ generateMavenDependency(libraries.dom4j)\ + generateMavenDependency(libraries.dom4j)\
@ -58,16 +54,16 @@ task processPluginXml(type: Copy) {
// and I'd rather not rely on it yet. // and I'd rather not rely on it yet.
def generateMavenDependency(String gradleDependency) { def generateMavenDependency(String gradleDependency) {
String[] split = gradleDependency.split(":") String[] split = gradleDependency.split(":")
return \ return "\n<dependency>"\
"<dependency>"\ + "\n <groupId>" + split[0] + "</groupId>"\
+ "<groupId>" + split[0] + "</groupId>"\ + "\n <artifactId>" + split[1] + "</artifactId>"\
+ "<artifactId>" + split[1] + "</artifactId>"\ + "\n <version>" + split[2] + "</version>"\
+ "<type>jar</type>"\ + "\n <type>jar</type>"\
+ "<version>" + split[2] + "</version>"\ + "\n</dependency>"
+ "</dependency>\n"
} }
task writeNewPom(type:Task, description: 'Writes pom.xml using merged Gradle dependency and MavenPom configuration.') { // Writes pom.xml using merged Gradle dependency and MavenPom configuration.
processResources.doLast {
ext.pomDefinition = pom { ext.pomDefinition = pom {
configurations { configurations {
// avoiding test dependencies in generated pom // avoiding test dependencies in generated pom
@ -79,34 +75,27 @@ task writeNewPom(type:Task, description: 'Writes pom.xml using merged Gradle dep
groupId project.group groupId project.group
packaging 'maven-plugin' packaging 'maven-plugin'
name 'Enhance Plugin of the Hibernate project for use with Maven build system.' name 'Enhance Plugin of the Hibernate project for use with Maven build system.'
build {
plugins {
plugin {
groupId 'org.apache.maven.plugins'
artifactId 'maven-plugin-plugin'
version '3.2'
configuration {
skipErrorNoDescriptorsFound 'true'
}
executions {
execution {
id 'mojo-descriptor'
goals {
goal 'descriptor'
}
}
}
}
}
}
properties { properties {
'project.build.sourceEncoding' 'UTF-8' 'project.build.sourceEncoding' 'UTF-8'
} }
} }
} }
ext.pomDefinition.writeTo("$projectDir/src/main/resources/pom.xml")
// HHH-9679 --- build in pom{} conflicts with FactoryBuilderSupport#build so we write that portion of XML by hand
ext.pomDefinition.withXml {
asNode().appendNode('build').appendNode('plugins').appendNode('plugin').with {
appendNode('groupId', 'org.apache.maven.plugins')
appendNode('artifactId', 'maven-plugin-plugin')
appendNode('version', '3.2')
appendNode('configuration').appendNode('skipErrorNoDescriptorsFound', 'true')
appendNode('executions').appendNode('execution').with {
appendNode('id', 'mojo-descriptor')
appendNode('goals').appendNode('goal', 'descriptor')
}
}
}
ext.pomDefinition.writeTo("$processResources.destinationDir/pom.xml")
} }
writeNewPom.dependsOn processPluginXml processResources.dependsOn processPluginXml
processResources.dependsOn writeNewPom

View File

@ -7,7 +7,7 @@
<description></description> <description></description>
<groupId>org.hibernate.orm.tooling</groupId> <groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId> <artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${version}</version> <version>@version@</version>
<goalPrefix>hibernate-enhance</goalPrefix> <goalPrefix>hibernate-enhance</goalPrefix>
<mojos> <mojos>
<mojo> <mojo>

View File

@ -7,7 +7,7 @@
<description></description> <description></description>
<groupId>org.hibernate.orm.tooling</groupId> <groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId> <artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${version}</version> <version>@version@</version>
<goalPrefix>hibernate-enhance</goalPrefix> <goalPrefix>hibernate-enhance</goalPrefix>
<mojos/> <mojos/>
</plugin> </plugin>

View File

@ -7,7 +7,7 @@
<description></description> <description></description>
<groupId>org.hibernate.orm.tooling</groupId> <groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId> <artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${version}</version> <version>@version@</version>
<goalPrefix>hibernate-enhance</goalPrefix> <goalPrefix>hibernate-enhance</goalPrefix>
<isolatedRealm>false</isolatedRealm> <isolatedRealm>false</isolatedRealm>
<inheritedByDefault>true</inheritedByDefault> <inheritedByDefault>true</inheritedByDefault>