{"id":14092,"date":"2020-02-15T16:53:11","date_gmt":"2020-02-15T15:53:11","guid":{"rendered":"http:\/\/blog.wenzlaff.de\/?p=14092"},"modified":"2020-02-15T17:12:28","modified_gmt":"2020-02-15T16:12:28","slug":"beispiel-verwendung-des-maven-plugin-de-wenzlaff-command-maven-plugin","status":"publish","type":"post","link":"http:\/\/blog.wenzlaff.de\/?p=14092","title":{"rendered":"Beispiel Verwendung des Maven Plugin: de.wenzlaff.command.maven.plugin"},"content":{"rendered":"<p>Vor einiger Zeit hatte ich <a href=\"http:\/\/blog.wenzlaff.de\/?p=14048\" rel=\"noopener noreferrer\" target=\"_blank\">hier<\/a> mal beschrieben, wie ein einfaches Maven-Plugin erstellt werden kann, dass alle Kommandozeilen Parameter im Log ausgibt z.B. ls, <strong>ps<\/strong>, ls -la. So k\u00f6nnen im Build-Prozess Verzeichnisse oder Prozesse \u00fcberwacht werden.<\/p>\n<p>Wer aber nur das Kommandozeilen Plugin nutzen will, kann dieses mit ein paar Zeilen in der <strong>pom.xml<\/strong> tun, da das Plugin auf Maven-Central frei verf\u00fcgbar ist.<\/p>\n<figure id=\"attachment_14093\" aria-describedby=\"caption-attachment-14093\" style=\"width: 525px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-768x1024.jpg\" alt=\"\" width=\"525\" height=\"700\" class=\"size-large wp-image-14093\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-768x1024.jpg 768w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-225x300.jpg 225w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-1152x1536.jpg 1152w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-1536x2048.jpg 1536w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2020\/02\/squirrel-scaled.jpg 1920w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/a><figcaption id=\"caption-attachment-14093\" class=\"wp-caption-text\">Squirrel  (Sciurus vulgaris) in der 3.Etage am 15.01.2020<\/figcaption><\/figure>\n<p>Einfach die pom.xml um folgende Zeilen erg\u00e4nzen:<!--more--><\/p>\n<pre class=\"lang:xhtml decode:true \" >&lt;build&gt;\r\n\t\t&lt;plugins&gt;\r\n\t\t\t&lt;plugin&gt;\r\n\t\t\t\t&lt;groupId&gt;de.wenzlaff.command.maven.plugin&lt;\/groupId&gt;\r\n\t\t\t\t&lt;artifactId&gt;de.wenzlaff.command.maven.plugin&lt;\/artifactId&gt;\r\n\t\t\t\t&lt;version&gt;0.0.1&lt;\/version&gt;\r\n\t\t\t\t&lt;configuration&gt;\r\n\t\t\t\t\t&lt;!-- Optional: Kommandoparameter der hier ge\u00e4ndert werden kann --&gt;\r\n\t\t\t\t\t&lt;command&gt;ls -lat&lt;\/command&gt;\r\n\t\t\t\t&lt;\/configuration&gt;\r\n\t\t\t\t&lt;executions&gt;\r\n\t\t\t\t\t&lt;execution&gt;\r\n\t\t\t\t\t\t&lt;goals&gt;\r\n\t\t\t\t\t\t\t&lt;goal&gt;info&lt;\/goal&gt;\r\n\t\t\t\t\t\t&lt;\/goals&gt;\r\n\t\t\t\t\t&lt;\/execution&gt;\r\n\t\t\t\t&lt;\/executions&gt;\r\n\t\t\t&lt;\/plugin&gt;\r\n\t\t&lt;\/plugins&gt;\r\n\t&lt;\/build&gt;<\/pre>\n<p>Schon wird das Info Goal bei einem <strong>mvn clean install<\/strong> ausgef\u00fchrt, wie dieses Log zeigt:<\/p>\n<pre class=\"lang:default decode:true \" >[INFO] Scanning for projects...\r\n[INFO] \r\n[INFO] --&lt; de.wenzlaff.beispiel.maven.command.plugin:de.wenzlaff.beispiel.maven.command.plugin &gt;--\r\n[INFO] Building de.wenzlaff.beispiel.maven.command.plugin 0.0.1-SNAPSHOT\r\n[INFO] --------------------------------[ pom ]---------------------------------\r\n[INFO] \r\n[INFO] --- de.wenzlaff.command.maven.plugin:0.0.1:info (default) @ de.wenzlaff.beispiel.maven.command.plugin ---\r\n[INFO] Thomas sein Command-Plugin in Version: 0.0.1-SNAPSHOT, ArtifactId: de.wenzlaff.beispiel.maven.command.plugin\r\n[INFO] F\u00fchre das Kommando aus: ls -lat\r\n[INFO] \r\ntotal 24\r\n-rw-r--r--   1 thomaswenzlaff  staff  1308 Feb 15 16:22 .classpath\r\n-rw-r--r--   1 thomaswenzlaff  staff   934 Feb 15 16:21 pom.xml\r\ndrwxr-xr-x   7 thomaswenzlaff  staff   224 Feb 15 16:11 target\r\ndrwxr-xr-x   8 thomaswenzlaff  staff   256 Feb 15 16:11 .\r\ndrwxr-xr-x   4 thomaswenzlaff  staff   128 Feb 15 15:51 .settings\r\n-rw-r--r--   1 thomaswenzlaff  staff   570 Feb 15 15:51 .project\r\ndrwxr-xr-x   4 thomaswenzlaff  staff   128 Feb 15 15:51 src\r\ndrwxr-xr-x  80 thomaswenzlaff  staff  2560 Feb 15 15:51 ..\r\n\r\n[INFO] \r\n[INFO] --- maven-install-plugin:2.4:install (default-install) @ de.wenzlaff.beispiel.maven.command.plugin ---\r\n[INFO] Installing \/Users\/thomaswenzlaff\/eclipse-workspace-2018-09\/de.wenzlaff.beispiel.maven.command.plugin\/pom.xml to \/Users\/thomaswenzlaff\/.m2\/repository\/de\/wenzlaff\/beispiel\/maven\/command\/plugin\/de.wenzlaff.beispiel.maven.command.plugin\/0.0.1-SNAPSHOT\/de.wenzlaff.beispiel.maven.command.plugin-0.0.1-SNAPSHOT.pom\r\n[INFO] ------------------------------------------------------------------------\r\n[INFO] BUILD SUCCESS<\/pre>\n<p>Es wird alles im INFO-Level geloggt. Die ganze Pom eines Beispiel-Projektes sieht so aus:<\/p>\n<pre class=\"lang:default decode:true \" >&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\"\r\n\txmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n\txsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\t&lt;groupId&gt;de.wenzlaff.beispiel.maven.command.plugin&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;de.wenzlaff.beispiel.maven.command.plugin&lt;\/artifactId&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;packaging&gt;pom&lt;\/packaging&gt;\r\n\r\n\t&lt;build&gt;\r\n\t\t&lt;plugins&gt;\r\n\t\t\t&lt;plugin&gt;\r\n\t\t\t\t&lt;groupId&gt;de.wenzlaff.command.maven.plugin&lt;\/groupId&gt;\r\n\t\t\t\t&lt;artifactId&gt;de.wenzlaff.command.maven.plugin&lt;\/artifactId&gt;\r\n\t\t\t\t&lt;version&gt;0.0.1&lt;\/version&gt;\r\n\t\t\t\t&lt;configuration&gt;\r\n\t\t\t\t\t&lt;!-- Optional: Kommandoparameter der hier ge\u00e4ndert werden kann --&gt;\r\n\t\t\t\t\t&lt;command&gt;ls -lat&lt;\/command&gt;\r\n\t\t\t\t&lt;\/configuration&gt;\r\n\t\t\t\t&lt;executions&gt;\r\n\t\t\t\t\t&lt;execution&gt;\r\n\t\t\t\t\t\t&lt;goals&gt;\r\n\t\t\t\t\t\t\t&lt;goal&gt;info&lt;\/goal&gt;\r\n\t\t\t\t\t\t&lt;\/goals&gt;\r\n\t\t\t\t\t&lt;\/execution&gt;\r\n\t\t\t\t&lt;\/executions&gt;\r\n\t\t\t&lt;\/plugin&gt;\r\n\t\t&lt;\/plugins&gt;\r\n\t&lt;\/build&gt;\r\n&lt;\/project&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Vor einiger Zeit hatte ich hier mal beschrieben, wie ein einfaches Maven-Plugin erstellt werden kann, dass alle Kommandozeilen Parameter im Log ausgibt z.B. ls, ps, ls -la. So k\u00f6nnen im Build-Prozess Verzeichnisse oder Prozesse \u00fcberwacht werden. Wer aber nur das Kommandozeilen Plugin nutzen will, kann dieses mit ein paar Zeilen in der pom.xml tun, da &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/blog.wenzlaff.de\/?p=14092\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eBeispiel Verwendung des Maven Plugin: de.wenzlaff.command.maven.plugin\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[220,3161,3897,5,3163,79,7],"tags":[3906,3905,66,2674,3898],"class_list":["post-14092","post","type-post","status-publish","format-standard","hentry","category-anleitung","category-build","category-java-programmierung","category-java","category-maven","category-programmierung","category-tools","tag-komandline","tag-kommando","tag-maven","tag-maven-central","tag-maven-plugin"],"_links":{"self":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/14092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14092"}],"version-history":[{"count":0,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/14092\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14092"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}