How to check if dependency has snapshot using Github action

342 Views Asked by At

I have a maven project. I am replacing maven-release-plugin with maven ci friendly feature. But I want to check if any of the dependency in pom has snapshot version. If so want to fail the build for production. But for staging I would like to continue the build. Is there any github action which will checks for snapshot in dependency ?

1

There are 1 best solutions below

0
MAK Ripon On BEST ANSWER

Answering my own question. @khmarbaise was right. I did using following setup

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-enforcer-plugin</artifactId>
   <version>3.1.0</version>
   <executions>
      <execution>
         <phase>initialize</phase>
         <id>enforce-versions</id>
         <goals>
            <goal>enforce</goal>
         </goals>
         <configuration>
            <rules>
               <requireReleaseDeps>
                  <message>No Snapshots Allowed for Dependencies!</message>
               </requireReleaseDeps>
               <requireReleaseVersion>
                  <message>Snapshot Version is Not Allowed for Release</message>
               </requireReleaseVersion>
            </rules>
            <fail>true</fail>
         </configuration>
      </execution>
   </executions>
</plugin>