Axe*_*ine 11 gradle maven-plugin maven
我正在考虑搬到Gradle.但是,我确实有一些Maven插件需要在可预见的未来得到支持.
有没有办法使用Gradle构建Maven插件?
这对我有用:
"install.repositories.mavenInstaller.pom.writeTo( 'pom.xml' )""mvn org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor""build/classes/main/META-INF/maven/plugin.xml"创建这种方式,然后按jar任务正确打包,这是jar文件成为Maven插件AFAIK所需的全部。另外,我认为,“ maven-plugin-annotations”应在插件中使用。
task pluginDescriptor( type: Exec ) {
commandLine 'mvn', '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor'
doFirst {
final File pom = project.file( 'pom.xml' )
install.repositories.mavenInstaller.pom.writeTo( pom )
assert pom.file, "[$pom.canonicalPath] was not created"
pom.text = pom.text.
replace( '<groupId>unknown</groupId>', "<groupId>${project.group}</groupId>" ).
replace( '<artifactId>empty-project</artifactId>', "<artifactId>${project.name}</artifactId>" ).
replace( '<version>0</version>', """
|<version>${version}</version>
| <packaging>maven-plugin</packaging>
| <build>
| <directory>\${project.basedir}/build</directory>
| <outputDirectory>\${project.build.directory}/classes/main</outputDirectory>
| </build>
|""".stripMargin().trim())
}
doLast {
final pluginDescriptor = new File(( File ) project.compileGroovy.destinationDir, 'META-INF/maven/plugin.xml' )
assert pluginDescriptor.file, "[$pluginDescriptor.canonicalPath] was not created"
println "Plugin descriptor file:$pluginDescriptor.canonicalPath is created successfully"
}
}
project.compileGroovy.doLast{ pluginDescriptor.execute() }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2942 次 |
| 最近记录: |