I have the following 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>
<groupId>com.qburst.app</groupId>
<artifactId>main-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>main-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven</id>
<url>http://nexus:8081/repository/maven-group/</url>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
<url>http://nexus:8081/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexus</id>
<url>http://nexus:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</pluginManagement>
<!-- To use the plugin goals in your POM or parent POM -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</build>
</project>
I want to change a version of a particular dependency using sed command in terminal. However the following command doesnot seem to work:
sed -n -E 's/\(<dependency>[.\n\t ]*<groupId>com.mycompany.app<\/groupId>[.\S\w\n\t ]*<version>\)[0-9.]*\(<\/version>[.\n\t ]*<\/dependency>\)/\14.3\2/' pom.xml
I found out using online that the following regular expression is True However:
(<dependency>[.\n\t ]*<groupId>com.mycompany.app<\/groupId>[.\S\w\n\t ]*<version>)[0-9.]*(<\/version>[.\n\t ]*<\/dependency>)
However in sed it doesnot work. Someone please help