2015-05-19 00:23:35 -04:00
|
|
|
/*
|
|
|
|
* Hibernate, Relational Persistence for Idiomatic Java
|
|
|
|
*
|
|
|
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
|
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
|
|
*/
|
2020-04-06 13:21:11 -04:00
|
|
|
description = 'Enhance Plugin of the Hibernate project for use with Maven build system.'
|
|
|
|
|
2018-01-10 16:06:58 -05:00
|
|
|
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
|
2021-10-13 04:24:56 -04:00
|
|
|
apply plugin: 'maven-publish'
|
2013-12-19 10:09:40 -05:00
|
|
|
|
2014-01-31 11:39:02 -05:00
|
|
|
|
2020-04-06 13:21:11 -04:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
2013-12-19 10:09:40 -05:00
|
|
|
group = 'org.hibernate.orm.tooling'
|
|
|
|
|
2015-03-25 21:41:23 -04:00
|
|
|
processResources {
|
2016-11-29 12:20:12 -05:00
|
|
|
include "**/lifecycle-mapping-metadata.xml"
|
2015-03-25 21:41:23 -04:00
|
|
|
include "**/plugin-help.xml"
|
|
|
|
into processResources.destinationDir
|
|
|
|
filter(ReplaceTokens, tokens: ['version' : project.version])
|
2013-12-19 10:09:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2021-05-14 15:59:59 -04:00
|
|
|
implementation( project(':hibernate-core') ) { transitive = false }
|
2022-04-22 19:40:06 -04:00
|
|
|
implementation( jakartaLibs.jpa ) { transitive = false }
|
|
|
|
implementation( jakartaLibs.jta ) { transitive = false }
|
|
|
|
implementation libs.byteBuddy
|
|
|
|
|
|
|
|
implementation( mavenLibs.mavenCore ) { transitive = false }
|
|
|
|
implementation( mavenLibs.mavenArtifact ) { transitive = false }
|
|
|
|
implementation( mavenLibs.mavenPlugin ) { transitive = false }
|
|
|
|
implementation( mavenLibs.mavenPluginTools ) { transitive = false }
|
|
|
|
|
2021-05-14 15:59:59 -04:00
|
|
|
implementation 'org.codehaus.plexus:plexus-utils:3.0.24'
|
|
|
|
implementation 'org.sonatype.plexus:plexus-build-api:0.0.7'
|
|
|
|
|
2022-04-22 19:40:06 -04:00
|
|
|
runtimeOnly mavenLibs.mavenCore
|
|
|
|
runtimeOnly mavenLibs.mavenArtifact
|
|
|
|
runtimeOnly mavenLibs.mavenPlugin
|
|
|
|
runtimeOnly mavenLibs.mavenPluginTools
|
2013-12-19 10:09:40 -05:00
|
|
|
}
|
|
|
|
|
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)
|
2015-03-25 21:41:23 -04:00
|
|
|
|
|
|
|
from "src/main/resources/META-INF/maven/plugin.xml"
|
|
|
|
into "$processResources.destinationDir/META-INF/maven"
|
|
|
|
filter(ReplaceTokens, tokens: ['version' : project.version, 'generated-dependencies' :\
|
2022-04-22 19:40:06 -04:00
|
|
|
generateMavenDependency(jakartaLibs.jpa)\
|
|
|
|
+ generateMavenDependency(libs.antlr)\
|
|
|
|
+ generateMavenDependency(jakartaLibs.jta)\
|
|
|
|
+ generateMavenDependency(libs.hcann)\
|
|
|
|
+ generateMavenDependency(libs.byteBuddy)\
|
|
|
|
+ generateMavenDependency(libs.logging)\
|
2014-01-31 11:39:02 -05:00
|
|
|
+ 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(":")
|
2015-03-25 21:41:23 -04:00
|
|
|
return "\n<dependency>"\
|
|
|
|
+ "\n <groupId>" + split[0] + "</groupId>"\
|
|
|
|
+ "\n <artifactId>" + split[1] + "</artifactId>"\
|
|
|
|
+ "\n <version>" + split[2] + "</version>"\
|
|
|
|
+ "\n <type>jar</type>"\
|
|
|
|
+ "\n</dependency>"
|
2014-01-31 11:39:02 -05:00
|
|
|
}
|
|
|
|
|
2022-04-22 19:40:06 -04:00
|
|
|
def generateMavenDependency(Provider<?> gradleDependencyProvider) {
|
|
|
|
String[] split = gradleDependencyProvider.get().toString().split(":")
|
|
|
|
return "\n<dependency>"\
|
|
|
|
+ "\n <groupId>" + split[0] + "</groupId>"\
|
|
|
|
+ "\n <artifactId>" + split[1] + "</artifactId>"\
|
|
|
|
+ "\n <version>" + split[2] + "</version>"\
|
|
|
|
+ "\n <type>jar</type>"\
|
|
|
|
+ "\n</dependency>"
|
|
|
|
}
|
|
|
|
|
2015-03-25 21:41:23 -04:00
|
|
|
// Writes pom.xml using merged Gradle dependency and MavenPom configuration.
|
2021-10-13 04:24:56 -04:00
|
|
|
tasks.named('generatePomFileForPublishedArtifactsPublication') {
|
|
|
|
pom.with {
|
|
|
|
packaging 'maven-plugin'
|
|
|
|
name.set('Hibernate Enhance Maven Plugin')
|
|
|
|
description 'Enhance Plugin of the Hibernate project for use with Maven build system.'
|
|
|
|
properties.put(
|
|
|
|
'project.build.sourceEncoding', 'UTF-8'
|
|
|
|
)
|
|
|
|
// HHH-9679 --- build in pom{} conflicts with FactoryBuilderSupport#build so we write that portion of XML by hand
|
|
|
|
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')
|
|
|
|
}
|
2021-09-22 18:52:06 -04:00
|
|
|
}
|
|
|
|
}
|
2013-12-19 10:09:40 -05:00
|
|
|
}
|
2015-03-25 21:41:23 -04:00
|
|
|
}
|
2013-12-19 10:09:40 -05:00
|
|
|
|
2015-03-25 21:41:23 -04:00
|
|
|
processResources.dependsOn processPluginXml
|
2021-09-01 13:49:54 -04:00
|
|
|
// We need this filter here, otherwise Gradle or the JUnit Jupiter platform will load classes at a point
|
|
|
|
// when they are not yet enhanced, leading to test failures
|
|
|
|
test.include '**/*Test.class'
|