如何设置 pom.xml 来使用 Maven for Sonar 处理某些目录?

发布于 2024-11-24 20:09:33 字数 1319 浏览 1 评论 0原文

我有一个类似这样的目录结构:

  • 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 技术交流群。

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

发布评论

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

评论(1

忆沫 2024-12-01 20:09:34

您可以构建顶级 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文