I am currently using a sed script:
cd (root folder) first
find . -name pom.xml | xargs sed -i "/<dependencies>/,/'</dependencies>'/s/-SNAPSHOT//"
currently, this script removes the -SNAPSHOT
on all pom.xml
on a folder including its subfolders, under the tagging <dependencies></dependencies>
,
example of xml is:
<parent>
<groupId>com.techstack.scheduler</groupId>
<artifactId>scheduler-service</artifactId>
<version>0.0.9-SNAPSHOT</version>
</parent>
<artifactId>scheduler-webapp</artifactId>
<packaging>war</packaging>
<name>Scheduler Service Web Application</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.infor.techstack.scheduler</groupId>
<artifactId>scheduler-service-core</artifactId>
<version>0.0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.security.authentication</groupId>
<artifactId>oauth10a-client</artifactId>
<version>0.0.26-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>xerces</artifactId>
<groupId>xerces</groupId>
</exclusion>
</exclusions>
</dependency>
so now, what I need is to exclude those tagging which has word "scheduler-service-core" or basically scheduler, as I dont need to parse this, but my script is removing it because it is under dependencies tagging, How can I have exclusion on this one? the words "scheduler" will be changing because I will be using this on different services, so the script should be relying the exclusion on the word as I will change it when using to different services.
desired output should be:
<parent>
<groupId>com.techstack.scheduler</groupId>
<artifactId>scheduler-service</artifactId>
<version>0.0.9-SNAPSHOT</version>
</parent>
<artifactId>scheduler-webapp</artifactId>
<packaging>war</packaging>
<name>Scheduler Service Web Application</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.infor.techstack.scheduler</groupId>
<artifactId>scheduler-service-core</artifactId>
<version>0.0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.security.authentication</groupId>
<artifactId>oauth10a-client</artifactId>
<version>0.0.26</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>xerces</artifactId>
<groupId>xerces</groupId>
</exclusion>
</exclusions>
</dependency>
if you can see, the -SNAPSHOT
for artifactID - scheduler-service-core
has been retained, and all other dependencies below which has -SNAPSHOT
will be removed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…