将子项目添加到Maven项目中,以便在jooq-codegen-maven中使用。

huangapple 未分类评论43阅读模式
英文:

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>
  1. 将我的子项目添加到Maven项目的正确方法是什么?这与gradle的include命令的确切行为是什么。

  2. 当前的辅助插件解决方案是否正确?是否可接受?因为在我的情况下:

我正在使用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 &#39;generator&#39;

my sub-project has a build.gradle file that defined as :

apply plugin: &#39;java&#39;

dependencies {
  compile(&quot;org.jooq:jooq-codegen:${gradle.ext.jooqVersion}&quot;)
  compile &quot;srvg.libs:jooq_utils:1908-VBI-580.1.+&quot;
}

sourceSets {
  main {
    java {
      srcDirs = [&#39;src/main/java&#39;]
    }
  }
}

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:

			&lt;plugin&gt;
				&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
				&lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
				&lt;version&gt;3.1.0&lt;/version&gt;
				&lt;executions&gt;
					&lt;execution&gt;
						&lt;id&gt;add-source&lt;/id&gt;
						&lt;phase&gt;generate-sources&lt;/phase&gt;
						&lt;goals&gt;
							&lt;goal&gt;add-source&lt;/goal&gt;
						&lt;/goals&gt;
						&lt;configuration&gt;
							&lt;sources&gt;
								&lt;source&gt;generator/src/main/java/&lt;/source&gt;
							&lt;/sources&gt;
						&lt;/configuration&gt;
					&lt;/execution&gt;
				&lt;/executions&gt;
			&lt;/plugin&gt;
  1. what is the true way to add my sub-project to maven project? which is the exact behavior of gradle include command.

  2. 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?

huangapple
  • 本文由 发表于 2020年4月3日 21:50:40
  • 转载请务必保留本文链接:https://java.coder-hub.com/61013425.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定