如果特定目录不存在,则有条件地运行MVN插件

发布于 2025-02-10 11:11:56 字数 898 浏览 1 评论 0原文

只有在不存在特定目录的情况下,才可以有条件地运行Maven插件吗?

我本质上是在尝试防止npm ci不必要地作为软件包运行。因此,理想情况下,只有在不存在node_modules时才能运行。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <id>npm-install</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>npm</executable>
                <arguments>
                    <argument>ci</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

Is it possible to conditionally run a maven plugin only if a specific directory doesn't exist?

I'm essentially trying to prevent npm ci from running unnecessarily as package.json rarely changes. So ideally it would only run when node_modules doesn't exists.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <id>npm-install</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>npm</executable>
                <arguments>
                    <argument>ci</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

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

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

发布评论

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

评论(1

遗心遗梦遗幸福 2025-02-17 11:11:56

您可以将其包装到配置文件中,并仅在不存在给定文件时激活该配置文件。

You can wrap it into a profile and activate that profile only if a given file does not exist.

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