Home > Net >  I need to run the command based on the -DskipTests flag in pom.xml
I need to run the command based on the -DskipTests flag in pom.xml

Time:03-31

We have an angular folder inside the java spring project.

I am using the maven build tool so if the -DskipTests flag is true I need to trigger the npm buildProdSkipTests command.

If it's false I need to trigger the npm buildProd command.

This is my pom.xml file

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>mbaasportal</artifactId>
<packaging>war</packaging>
<name>mbaasportal</name>
<parent>
    <groupId>xxxx</groupId>
    <artifactId>xxx</artifactId>
    <version>5.7.0.0</version>
</parent>
<properties>
    <middleware.version>[9.4.0.0, 9.4.0.999)</middleware.version>
    <maven.exec.skip>false</maven.exec.skip>
</properties>
<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <configuration>
                <skip>${maven.exec.skip}</skip>
            </configuration>
            <executions>
                <execution>
                    <id>npm-install</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                    <workingDirectory>${project.basedir}/src/main/webapp</workingDirectory>
                    <executable>npm</executable>
                    <arguments>
                        <argument>install</argument>
                    </arguments>
                    </configuration>
                </execution>
                <execution>
                    <id>webpack-build</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                    <workingDirectory>${project.basedir}/src/main/webapp</workingDirectory>
                    <executable>npm</executable>
                    <arguments>
                        <argument>run</argument>
                        <argument>buildProd</argument>
                    </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>

CodePudding user response:

Use

mvn clean install -DskipTests=true

CodePudding user response:

Then you need to put the executions into two Maven profiles and activate them based on the property.

  • Related