Skip to content

⚠️ a maven plugin to eliminates human errors.

Notifications You must be signed in to change notification settings

umjammer/careless-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Release Java CI CodeQL Java

careless-maven-plugin

⚠️ eliminates human errors.

🐣️ this project is a good exsample of

  • maven plugin
  • maven plugin junit5 test wip

Install

Usage

 <properties><javaVersion>21</javaVersion></properties>
   <plugin>
     <artifactId>careless-maven-plugin</artifactId>
     <configuration>
       <targets>
         <target>
           <path>.github/workflows/codeql.yml</path>
           <ri>jobs.analyze.steps[2].name</ri>
           <value>Set up JDK ${javaVersion}</value>
         </target>
         <target>
           <path>pom.xml</path>
           <ri>//*[local-name()='artifactId' and text()='maven-compiler-plugin']/..//*[local-name()='release' or local-name()='source']/text()</ri>
           <value>${javaVersion}</value>
         </target>
         <target>
           <path>README.md</path>
           <ri>img\.shields\.io\/badge\/Java-(\d+?)-b07219</ri>
           <value>${javaVersion}</value>
         </target>
         <target>
           <path>pom.xml</path>
           <ri>//*[local-name()='project']/*[local-name()='version']/text()</ri>
           <value>.*-SNAPSHOT</value>
           <negative>true</negative>
         </target>
       </targets>
     </configuration>
   </plugin>
  • ri: meaning is changed implicitly
    • file is xml(.xml, .pom) ... xpath 1.0 (java doesn't support xpath 2.0...)
    • file is yaml(.yml) ... yaml-path
    • else (.md) ... word extracted by regex (), line is extracted by grep
$ mvn -f src/test/resources/test-pom.xml validate                                                                                                                                                                main
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the MultiThreadedBuilder implementation with a thread count of 24
[INFO] 
[INFO] ----------------------------< vavi:sample >-----------------------------
[INFO] Building sample 0.0.1-SNAPSHOT
[INFO]   from test-pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- careless:0.0.1-SNAPSHOT:careless (default) @ sample ---
[INFO] OK: yml: matched: for target: { path='.github/workflows/codeql.yml', ri='jobs.analyze.steps[2].name', value='Set up JDK 17' }
[INFO] OK: xml: matched: for target: { path='pom.xml', ri='//*[local-name()='artifactId' and text()='maven-compiler-plugin']/..//*[local-name()='release' or local-name()='source']/text()', value='17' }
[INFO] OK: md: matched: for target: { path='README.md', ri='img\.shields\.io\/badge\/Java-(\d+?)-b07219', value='17' }, lines: [3]
[ERROR] NG: xml: matched: for target: { path='pom.xml', ri='//*[local-name()='project']/*[local-name()='version']/text()', value='.*-SNAPSHOT' }, actual: 0.0.1-SNAPSHOT

Preference

TODO

  • checkstyle <- ???
  • unit/integrated test