英文:
Add subproject to a maven project to be used in jooq-codegen-maven
问题
以下是您要翻译的内容:
我有一个Gradle项目,其中有一个名为generator的子项目。
子项目是通过gradle.setting文件添加到我的主项目中的:
include 'generator'
我的子项目有一个build.gradle文件,定义如下:
apply plugin: 'java'
dependencies {
  compile "org.jooq:jooq-codegen:${gradle.ext.jooqVersion}"
  compile "srvg.libs:jooq_utils:1908-VBI-580.1.+"
}
sourceSets {
  main {
    java {
      srcDirs = ['src/main/java']
    }
  }
}
如您所见,没有项目构件名称、版本等信息,只定义了依赖项。
现在由于某种原因,我必须将此项目转换为Maven项目。我为主项目生成了一个pom文件,但是子项目该怎么办呢?
我知道我可以将其添加为主项目的模块,但这对我不起作用,因为我的主项目打包为Jar,应保持不变。但是,要为项目创建模块,它的打包方式应为Pom。
目前,我通过辅助插件将子项目添加到资源中:
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>generator/src/main/java/</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>
- 
将我的子项目添加到Maven项目的正确方法是什么?这与gradle的include命令的确切行为是什么。 
- 
当前的辅助插件解决方案是否正确?是否可接受?因为在我的情况下: 
我正在使用jooq生成器,它必须从我子项目中的一个类中读取生成器策略参数?
如果不正确,最佳做法是什么?
英文:
I have a Gradle project which has a sub-project named generator.
sub-project is added to my main project in gradle.setting file :
include 'generator'
my sub-project has a build.gradle file that defined as :
apply plugin: 'java'
dependencies {
  compile("org.jooq:jooq-codegen:${gradle.ext.jooqVersion}")
  compile "srvg.libs:jooq_utils:1908-VBI-580.1.+"
}
sourceSets {
  main {
    java {
      srcDirs = ['src/main/java']
    }
  }
}
As you can see there is no project artifact name or version or etc. Just defined the dependencies.
Now for any reason I have to convert this project to maven nature. I generate a pom for my main project but what about this sub-project?
I know I can add it as a module to my main project but it does not work for me because my main projects packaging is Jar and should stay as is. but to have module for a project it should be Pom packaging.
At the moment I have added my sub-project to resources via a helper plugin:
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<id>add-source</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>generator/src/main/java/</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
- 
what is the true way to add my sub-project to maven project? which is the exact behavior of gradle include command. 
- 
is current solution using helper plugin is true? and acceptable? because in my scenario: 
I am using jooq generator, which has to read the generator strategy parameters from a class in my sub-project?
And if it is not true, what is the best practice?
专注分享java语言的经验与见解,让所有开发者获益!



评论