我的任务是将具有基于java的maven插件的maven项目迁移到gradle。该插件使用maven-plugin-plugin并具有目标描述符和helpmojo。
SELECT *
FROM user_college_tbl
WHERE college_name LIKE '%Impulse%' OR
col1 LIKE '%Impulse%' OR
col2 LIKE '%Impulse%'
有什么方法可以在gradle中执行这些目标,还是我需要在gradle中重写基于java的maven插件?
答案 0 :(得分:0)
您可以通过在build.gradle上运行此任务代码来使用gradle创建此文件。此代码生成临时pom.xml,使用临时pom运行maven并生成plguin.xml文件。最后(在doLast上),任务将文件复制到META-INF / maven /目录。
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"
}
}