8
8
plugins {
9
9
id " local.java-module"
10
10
id " local.publishing"
11
- id " org.hibernate.build. maven-embedder "
11
+ id " org.gradlex. maven-plugin-development " version " 1.0.3 "
12
12
}
13
13
14
14
description = ' Maven plugin to integrate aspects of Hibernate into your build.'
@@ -17,9 +17,10 @@ dependencies {
17
17
implementation project( " :hibernate-core" )
18
18
19
19
implementation " org.apache.maven:maven-plugin-api:3.6.3"
20
- implementation " org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0"
21
20
implementation " org.apache.maven:maven-project:2.2.1"
22
21
implementation " org.apache.maven.shared:file-management:3.1.0"
22
+
23
+ compileOnly " org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0"
23
24
}
24
25
25
26
def releasePrepareTask = tasks. register(" releasePrepare" ) {
@@ -48,6 +49,9 @@ var publishingExtension = project.getExtensions().getByType(PublishingExtension)
48
49
publishingExtension. publications. named(" publishedArtifacts" ) {
49
50
from components. java
50
51
52
+ // Adjust the pom for 3 things:
53
+ // 1. set packaging to maven-plugin (org.gradlex.maven-plugin-development does not in my testing)
54
+ // 2. scope of org.apache.maven dependencies
51
55
pom. withXml {
52
56
asNode()
53
57
.version
@@ -61,77 +65,10 @@ publishingExtension.publications.named("publishedArtifacts") {
61
65
dependency. groupId. text(). startsWith(' org.apache.maven' )
62
66
}
63
67
.each { dependency ->
64
- if (dependency. groupId. text(). startsWith(' org.apache.maven.shared' )) {
65
- dependency. scope* . value = ' compile'
66
- } else {
68
+ if (! dependency. groupId. text(). startsWith(' org.apache.maven.shared' )) {
67
69
dependency. scope* . value = ' provided'
68
70
}
69
71
}
70
- asNode()
71
- .dependencies
72
- .dependency
73
- .findAll { dependency ->
74
- dependency. groupId. text(). startsWith(' org.hibernate.orm' )
75
- }
76
- .each { dependency ->
77
- dependency. scope* . value = ' compile'
78
- }
79
- asNode()
80
- .dependencies
81
- .plus {
82
- def plugins = build(). appendNode(' plugins' )
83
- def pluginPlugin = plugins. appendNode(' plugin' )
84
- pluginPlugin. appendNode(' groupId' , ' org.apache.maven.plugins' )
85
- pluginPlugin. appendNode(' artifactId' , ' maven-plugin-plugin' )
86
- pluginPlugin. appendNode(' version' , ' 3.15.0' )
87
- def pluginConfiguration = pluginPlugin. appendNode(' configuration' )
88
- pluginConfiguration. appendNode(' goalPrefix' , ' plugin' )
89
- pluginConfiguration. appendNode(' outputDirectory' , layout. buildDirectory. dir(' generated/sources/plugin-descriptors/META-INF/maven' ). get(). getAsFile(). getAbsolutePath() )
90
- def invokerPlugin = plugins. appendNode(' plugin' );
91
- invokerPlugin. appendNode(' groupId' , ' org.apache.maven.plugins' )
92
- invokerPlugin. appendNode(' artifactId' , ' maven-invoker-plugin' )
93
- invokerPlugin. appendNode(' version' , ' 3.8.0' )
94
- def invokerConfiguration = invokerPlugin. appendNode(' configuration' );
95
- invokerConfiguration. appendNode(' debug' , ' true' );
96
- invokerConfiguration. appendNode(' mavenExecutable' , ' mvnw' );
97
- def scriptVariables = invokerConfiguration. appendNode(' scriptVariables' );
98
- scriptVariables. appendNode(' hibernateCoreJarPath' , layout. buildDirectory. file(' maven-embedder/maven-local/org/hibernate/orm/hibernate-core/' + project. version + ' /hibernate-core-' + project. version + ' .jar' ). get(). getAsFile(). getAbsolutePath())
99
- }
100
72
}
101
73
}
102
74
103
- // Following tasks need to be performed:
104
- // 1. Compile the Java classes
105
- // 2. Copy the source tree to the working directory
106
- // 3. Copy the compiled Java classes to the working directory
107
- // 4. Install the 'hibernate-core' dependency in the local Maven repo
108
- // 5. Install the 'hibernate-scan-jandex' dependency in the local Maven repo
109
- // 6. Generate the pom.xml file for the Maven plugin
110
- // 7. Generate the Maven plugin descriptor
111
- // 8. Create the jar for the Maven plugin
112
- // 9. Install the Maven plugin descriptor in the local Maven repo
113
- // 10. Run the integration tests
114
-
115
- // Prepare the working directory
116
- tasks. register(' prepareWorkspace' , Copy ) {
117
- into(' target/maven-embedder/workspace' )
118
- // copy the plugin pom
119
- with( copySpec {
120
- from(' target/publications/publishedArtifacts/pom-default.xml' )
121
- rename(' pom-default.xml' , ' pom.xml' )
122
- dependsOn(' generatePomFileForPublishedArtifactsPublication' )
123
- })
124
- // copy the compiled java classes
125
- into(' target/classes' ) {
126
- with( copySpec {
127
- from(' target/classes/java/main' )
128
- dependsOn(' compileJava' )
129
- })
130
- }
131
- // copy the integration tests
132
- into(' src/it' ) {
133
- with( copySpec {
134
- from(' src/it' )
135
- })
136
- }
137
- }
0 commit comments