简体   繁体   English

如何从依赖项目 maven 中包含 .class 文件?

[英]How to include .class files from dependency project maven?

I have two maven projects:我有两个 maven 项目:

  1. This is the framework project and has the dependency classes in the src/main/java这是框架项目,在 src/main/java 中有依赖类
  2. This is the project that contains my test scripts in the src/test/java这是在 src/test/java 中包含我的测试脚本的项目

I want to build a jar where both the class files are included from the project in the 2nd project's pom.xml file.我想构建一个 jar,其中 class 文件都包含在第二个项目的 pom.xml 文件中。

What type of plugin can do the job?什么类型的插件可以完成这项工作? I have tried using maven jar plugin and assembly plugin but neither of them solved my problem.我试过使用 maven jar 插件和程序集插件,但它们都没有解决我的问题。

Both your tests and your main classes should be included in the same project, not separately.你的测试和你的主类应该包含在同一个项目中,而不是分开。 A test suite should not be a separate "module" that is imported as a dependency via pom.xml .测试套件不应是通过pom.xml作为依赖项导入的单独“模块”。 Just as @J Fabian Meier pointed out - the tests are not included in your output file when compiled - they are just there to be ran while building to test your classes.正如@J Fabian Meier指出的那样 - 编译时测试不包含在您的 output 文件中 - 它们只是在构建时运行以测试您的类。

It's very unclear what you're trying to achieve.目前还不清楚您要达到的目标。 You might want to go through how a standard Maven project directory layout should look like.您可能想了解 go 标准 Maven 项目目录布局的外观。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM