2013-12-19 10:09:40 -05:00
|
|
|
apply plugin: 'java'
|
|
|
|
apply plugin: 'maven'
|
|
|
|
|
2014-01-31 11:39:02 -05:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
2013-12-19 10:09:40 -05:00
|
|
|
group = 'org.hibernate.orm.tooling'
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
processResources.doLast {
|
|
|
|
project.build.outputDirectory = '${project.build.outputDirectory}'
|
|
|
|
copy {
|
|
|
|
from 'src/main/resources'
|
|
|
|
into processResources.destinationDir
|
|
|
|
expand ([ version: version, project: project, dir: '${dir}' ])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2014-01-31 11:39:02 -05:00
|
|
|
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 }
|
2013-12-19 10:09:40 -05:00
|
|
|
compile 'org.codehaus.plexus:plexus-utils:3.0.1'
|
2014-01-31 11:39:02 -05:00
|
|
|
runtime( libraries.maven_plugin )
|
|
|
|
runtime( libraries.maven_plugin_tools )
|
|
|
|
runtime( project(':hibernate-core') )
|
|
|
|
runtime( libraries.jpa )
|
|
|
|
runtime( libraries.javassist )
|
2013-12-19 10:09:40 -05:00
|
|
|
runtime 'org.codehaus.plexus:plexus-utils:3.0.1'
|
|
|
|
}
|
|
|
|
|
2014-01-31 11:39:02 -05:00
|
|
|
// 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.') {
|
2013-12-19 10:09:40 -05:00
|
|
|
ext.pomDefinition = pom {
|
2014-02-04 12:30:53 -05:00
|
|
|
configurations {
|
|
|
|
// avoiding test dependencies in generated pom
|
|
|
|
compile
|
|
|
|
runtime
|
|
|
|
}
|
|
|
|
|
2013-12-19 10:09:40 -05:00
|
|
|
project {
|
|
|
|
groupId project.group
|
|
|
|
packaging 'maven-plugin'
|
|
|
|
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 {
|
|
|
|
'project.build.sourceEncoding' 'UTF-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ext.pomDefinition.writeTo("$projectDir/src/main/resources/pom.xml")
|
|
|
|
}
|
|
|
|
|
2014-01-31 11:39:02 -05:00
|
|
|
writeNewPom.dependsOn processPluginXml
|
2013-12-19 10:09:40 -05:00
|
|
|
processResources.dependsOn writeNewPom
|
|
|
|
|