Is there a way to update the version in package.json (npm version minor) in maven's pom.xml file? - maven

I would like to update the version in package.json automatically when running a maven release. How do I update the version (npm version minor) in the pom.xml file ?
I've tried updating the pom.xml file with a plugin
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.plugin.version}</version>
<executions>
<execution>
<id>npm run version</id>
<goals>
<goal>exec</goal>
</goals>
<configurations>
<executable>cd</executable>
<arguments>
<argument>web/gui</argument>
</arguments>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>version</argument>
</arguments>
</configurations>
</execution>
<executions>
</plugin>
Nothing really happened when I ran mvn clean:release

Related

How to skip the build of jar file "app-source.jar" when maven build happens in SpringBoot?

I have following jar's when in run mvn clean package command
app.jar
app-source.jar
app.jar.original
I dont want the app-source.jar to be generated when I run the above maven command.
I have added
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<finalName>app</finalName>
<addResources>false</addResources>
<arguments>-Dmaven.source.skip=true</arguments>
<includeSystemScope>false</includeSystemScope>
</configuration>
<executions>
<!--<execution>
<id>skip-sources</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
The below specified attribute 'attach' will disable the sources.jar not included in the artifact list
<attach>false</attach>
</configuration>
</execution>-->
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<!--The below specified attribute 'attach' will disable the sources.jar not included in the artifact list-->
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
SprinBoot Version : 2.7.5
Maven Source Plugin version : 3.2.0
The goal executed in maven build
[INFO] --- maven-source-plugin:3.2.0:jar-no-fork (attach-sources) # app
[INFO] Building jar: path\to\project\target\app-sources.jar
Thanks
Rohit

Conditionally run a mvn plugin if a specific directory doesn't exist

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>
You can wrap it into a profile and activate that profile only if a given file does not exist.

maven npm exec-maven-plugin set registry and proxy

Maven + npm install
I have following plugin to install package.json dependencies, is there a way i can run npm config set registry and npm config set proxy command with following plugin ?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>exec-npm-install</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${basedir}/src/main/webapp</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
was able to get it done through .nprmc file on project root
create file and have entry like
registry=
proxy=

Running Gradle from Maven

I'm looking for some Gradle executor plugin for Maven (similar to Maven ant-run plugin).
Google did not help. Is it possible that such plugin doesn't exist?
I should try this:
https://github.com/if6was9/gradle-maven-plugin
This is a maven plugin that makes it easy to invoke gradle from maven.
It is similar to the maven-antrun-plugin that allows ant to be invoked
from maven.
I probably would use:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<executable>./gradlew</executable>
<arguments>
<argument>test</argument>
<argument>-i</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<executable>./gradlew</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
Because of the following reasons:
I would prefer to trust in a plugin maintained by Codehaus.
If you use the gradle-maven-plugin, probably you'll have to configure additional information in your settings.xml. Otherwise this error can occur: Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8

maven plugins: phase clean, Could not resolve dependencies

There's this task:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
<delete dir="src\test\resources\templates" includeemptydirs="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The problem is: when I run mvn clean, <phase>clean</phase> tells maven to download project dependencies (that don't exist yet) and I get Could not resolve dependencies error.
How to tell maven not to require project dependencies to run this plugin?

Resources