maven防止依赖编译

发布于 2024-08-24 05:03:36 字数 119 浏览 9 评论 0原文

我有一个自定义 jar,其中包括 java 源; Maven 在构建时尝试进行编译。如何跳过 jar 文件中的源编译?我已经尝试过在编译器插件和源目录定义中排除某些模式,但我没有得到任何运气。谢谢!

C05

I have a custom jar which including java sources; Maven tries to compile when it builds. How do I skip source compile in the jar file? I have tried such as exclude with some pattern in the compiler-plug in and source directory define but I have not get any luck. Thanks!

C05

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哆兒滾 2024-08-31 05:03:36

这是 的正常行为javac 搜索整个类路径以查找要编译的源文件,除非给出 -sourcepath 选项(这将是此处的解决方案)。

不幸的是,存在一个关于 Maven 编译器插件未将 -sourcepath 传递给 javac 的 Jira 问题(请参阅 MCOMPILER-98)。但有一个解决方法:

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <compilerArguments>
      <sourcepath>${project.basedir}/src/main/java</sourcepath>
    </compilerArguments>
  </configuration>
</plugin>

This is a normal behavior of javac that searches the whole classpath for source files to compile unless the -sourcepath option is given (and this would be the solution here).

Unfortunately, there is a Jira issue about -sourcepath not being passed to javac by the Maven Compiler Plugin (see MCOMPILER-98). But there is a workaround:

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <compilerArguments>
      <sourcepath>${project.basedir}/src/main/java</sourcepath>
    </compilerArguments>
  </configuration>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文