如何设置 pom.xml 来使用 Maven for Sonar 处理某些目录?
我有一个类似这样的目录结构:
- base
- 子目录1
- 子目录2
- 子目录3
- 子子目录1
- subsubdir2
- 子目录4
- 单元测试
如何设置我的 pom.xml 以便它只处理粗体文件夹?如果可能的话,我希望它们全部在一个 mvn sonar:sonar
调用中进行处理,并在 Sonar 中显示为单独的项目。我尝试查看项目对象模型的文档,但发现它令人不知所措,并且无法弄清楚如何按照我的描述进行设置。这就是我位于 base 中的 pom.xml 目前的样子:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.foo.bar.baz</groupId>
<artifactId>subsubdir2</artifactId>
<name>MyProject</name>
<version>1.0</version>
<build>
<sourceDirectory>subdir3/subsubdir2</sourceDirectory>
<testSourceDirectory>unittests</testSourceDirectory>
</build>
<properties>
<sonar.language>php</sonar.language>
<sonar.phase>generate-sources</sonar.phase>
</properties>
</project>
I have a directory structure something like this:
- base
- subdir1
- subdir2
- subdir3
- subsubdir1
- subsubdir2
- subdir4
- unittests
How do I set up my pom.xml so that it only processes the folders in bold? If possible, I want them to all be processed in one mvn sonar:sonar
call, and to show up as separate projects in Sonar. I tried looking at the documentation for the Project Object Model, but I found it to be overwhelming, and couldn't figure out how to set it up as I described. This is what my pom.xml, located in base, currently looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.foo.bar.baz</groupId>
<artifactId>subsubdir2</artifactId>
<name>MyProject</name>
<version>1.0</version>
<build>
<sourceDirectory>subdir3/subsubdir2</sourceDirectory>
<testSourceDirectory>unittests</testSourceDirectory>
</build>
<properties>
<sonar.language>php</sonar.language>
<sonar.phase>generate-sources</sonar.phase>
</properties>
</project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以构建顶级 pom 并使用 sonar.skippedModules 或 sonar.includedModules 属性 设置要构建的模块列表。这不会将每个模块显示为声纳顶层的单独项目,但如果您进入项目并选择“模块”,那么您将看到列出的每个模块,就好像它是一个单独的项目一样。
You can build the top level pom and use the sonar.skippedModules or sonar.includedModules property to set up the list of modules to build. This won't show each module as a separate project at the top level of sonar, but if you go into the project and select "modules", then you'll see each one listed, as if it were a separate project.