Mavenビルド出力からgroupid:artifactid:version型の文字列を含む行を取得する方法は? [閉鎖]

Mavenビルド出力からgroupid:artifactid:version型の文字列を含む行を取得する方法は? [閉鎖]
  • mvn -B dependency:resolve-plugins 出力にプラグインのリストが必要です。
  • Mavenのビルドアウトには、ダウンロード、ビルドの成功、プラグイン情報のない追加の行など、他の多くのものがあります。

入力する:-

[INFO] Scanning for projects...
[INFO] 
[INFO]       antlr:antlr:jar:2.7.2
[INFO]       backport-util-concurrent:backport-util-concurrent:jar:3.1
[INFO]       ch.ethz.ganymed:ganymed-ssh2:jar:build210
[INFO]       classworlds:classworlds:jar:1.1
[INFO]       classworlds:classworlds:jar:1.1-alpha-2
[INFO]       com.fasterxml.staxmate:staxmate:jar:2.2.1
[INFO]       com.google.code.findbugs:jsr305:jar:2.0.1
[INFO]       com.google.code.findbugs:jsr305:jar:3.0.1
[INFO]       com.google.code.gson:gson:jar:2.2.2
[INFO]       com.google.guava:guava:jar:14.0.1
[INFO]       com.google.guava:guava:jar:18.0
[INFO]       com.google.guava:guava:jar:19.0
[INFO]       com.googlecode.javaewah:JavaEWAH:jar:0.7.9
[INFO]       com.ibm.icu:icu4j:jar:58.1
[INFO]       com.intellij:annotations:jar:9.0.4
[INFO]       com.jcraft:jsch.agentproxy.core:jar:0.0.7
[INFO]       com.jcraft:jsch.agentproxy.jsch:jar:0.0.7
[INFO]       com.jcraft:jsch.agentproxy.sshagent:jar:0.0.7
[INFO]       com.jcraft:jsch.agentproxy.usocket-jna:jar:0.0.7
[INFO]       com.jcraft:jsch:jar:0.1.38
[INFO]       com.jcraft:jsch:jar:0.1.49


[INFO]       xpp3:xpp3_min:jar:1.1.4c
[INFO]    de.smartics.maven.plugin:buildmetadata-maven-plugin:maven-plugin:1.6.1:runtime
[INFO]    external.atlassian.jgitflow:jgitflow-maven-plugin:maven-plugin:1.0-m5.1:runtime
[INFO]    org.apache.maven.plugins:maven-antrun-plugin:maven-plugin:1.8:runtime
[INFO]    org.apache.maven.plugins:maven-assembly-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-clean-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-compiler-plugin:maven-plugin:3.8.0:runtime
[INFO]    org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:3.1.1:runtime
[INFO]    org.apache.maven.plugins:maven-deploy-plugin:maven-plugin:3.0.0-M1:runtime
[INFO]    org.apache.maven.plugins:maven-enforcer-plugin:maven-plugin:3.0.0-M2:runtime
[INFO]    org.apache.maven.plugins:maven-install-plugin:maven-plugin:3.0.0-M1:runtime
[INFO]    org.apache.maven.plugins:maven-jar-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-javadoc-plugin:maven-plugin:3.0.1:runtime
[INFO]    org.apache.maven.plugins:maven-jxr-plugin:maven-plugin:3.0.0:runtime
[INFO]    org.apache.maven.plugins:maven-project-info-reports-plugin:maven-plugin:3.0.0:runtime
[INFO]    org.apache.maven.plugins:maven-release-plugin:maven-plugin:2.5.3:runtime
[INFO]    org.apache.maven.plugins:maven-resources-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-site-plugin:maven-plugin:3.7.1:runtime
[INFO]    org.apache.maven.plugins:maven-surefire-plugin:maven-plugin:2.22.0:runtime
[INFO]    org.apache.maven.plugins:maven-surefire-report-plugin:maven-plugin:2.22.0:runtime
[INFO]    org.apache.maven.plugins:maven-war-plugin:maven-plugin:3.2.2:runtime
[INFO]    org.basepom.maven:duplicate-finder-maven-plugin:maven-plugin:1.3.0:runtime
[INFO]    org.codehaus.mojo:build-helper-maven-plugin:maven-plugin:3.0.0:runtime
[INFO]    org.codehaus.mojo:exec-maven-plugin:maven-plugin:1.6.0:runtime
[INFO]    org.codehaus.mojo:taglist-maven-plugin:maven-plugin:2.4:runtime
[INFO]    org.codehaus.sonar-plugins:maven-report:maven-plugin:RELEASE:runtime
[INFO]    org.jacoco:jacoco-maven-plugin:maven-plugin:0.8.1:runtime
[INFO]    org.openclover:clover-maven-plugin:maven-plugin:4.3.1:runtime
[INFO]    org.sonarsource.scanner.maven:sonar-maven-plugin:maven-plugin:3.5.0.1254:runtime
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ platform-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ platform-wo-framework-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ platform-wo-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-webapp-base-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-webapp-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-wo-app-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-wo-framework-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-wo-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-wo-webapp-parent ---
[INFO] --- maven-dependency-plugin:3.1.1:resolve-plugins (default-cli) @ store-wo-webservice-parent ---
[INFO] ------------------------------------------------------------------------
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ---------------< com.apple.store.platform:store-parent >----------------
[INFO] --------------< com.apple.store.platform:platform-parent >--------------
[INFO] --------------< com.apple.store.platform:store-wo-parent >--------------
[INFO] ------------< com.apple.store.platform:platform-wo-parent >-------------
[INFO] ------------< com.apple.store.platform:store-webapp-parent >------------
[INFO] ------------< com.apple.store.platform:store-wo-app-parent >------------
[INFO] ----------< com.apple.store.platform:store-wo-webapp-parent >-----------
[INFO] ---------< com.apple.store.platform:store-webapp-base-parent >----------
[INFO] ---------< com.apple.store.platform:store-wo-framework-parent >---------
[INFO] --------< com.apple.store.platform:store-wo-webservice-parent >---------
[INFO] -------< com.apple.store.platform:platform-wo-framework-parent >--------
[INFO] Apple Online Platform Parent POM                                   [pom]
[INFO] Apple Online Platform Parent POM ................... SUCCESS [  2.265 s]
[INFO] Apple Online Platform WebObjects Framework Parent POM              [pom]
[INFO] Apple Online Platform WebObjects Framework Parent POM SUCCESS [  0.717 s]
[INFO] Apple Online Platform WebObjects Parent POM                        [pom]
[INFO] Apple Online Platform WebObjects Parent POM ........ SUCCESS [  0.759 s]
[INFO] BUILD SUCCESS
[INFO] Building Apple Online Platform Parent POM 2019.2-SNAPSHOT          [1/3]
[INFO] Building Apple Online Platform WebObjects Framework Parent POM 2019.2-SNAPSHOT [3/3]
[INFO] Building Apple Online Platform WebObjects Parent POM 2019.2-SNAPSHOT [2/3]
[INFO] Building store-parent 2019.2-SNAPSHOT                              [1/8]
[INFO] Building store-webapp-base-parent 2019.2-SNAPSHOT                  [7/8]
[INFO] Building store-webapp-parent 2019.2-SNAPSHOT                       [8/8]
[INFO] Building store-wo-app-parent 2019.2-SNAPSHOT                       [3/8]
[INFO] Building store-wo-framework-parent 2019.2-SNAPSHOT                 [4/8]
[INFO] Building store-wo-parent 2019.2-SNAPSHOT                           [2/8]
[INFO] Building store-wo-webapp-parent 2019.2-SNAPSHOT                    [5/8]
[INFO] Building store-wo-webservice-parent 2019.2-SNAPSHOT                [6/8]
[INFO] Finished at: 2018-11-13T16:39:27+05:30
[INFO] Finished at: 2018-11-15T18:46:42+05:30
[INFO] Reactor Build Order:
[INFO] Reactor Summary for Apple Online Platform Parent POM 2019.2-SNAPSHOT:
[INFO] Reactor Summary for store-parent 2019.2-SNAPSHOT:
[INFO] Scanning for projects...
[INFO] The following plugins have been resolved:
[INFO] Total time:  4.191 s
[INFO] Total time:  8.564 s
[INFO] store-parent                                                       [pom]
[INFO] store-parent ....................................... SUCCESS [  2.245 s]
[INFO] store-webapp-base-parent                                           [pom]
[INFO] store-webapp-base-parent ........................... SUCCESS [  0.853 s]
[INFO] store-webapp-parent                                                [pom]
[INFO] store-webapp-parent ................................ SUCCESS [  0.807 s]
[INFO] store-wo-app-parent                                                [pom]
[INFO] store-wo-app-parent ................................ SUCCESS [  0.794 s]
[INFO] store-wo-framework-parent                                          [pom]
[INFO] store-wo-framework-parent .......................... SUCCESS [  0.767 s]
[INFO] store-wo-parent                                                    [pom]
[INFO] store-wo-parent .................................... SUCCESS [  0.907 s]
[INFO] store-wo-webapp-parent                                             [pom]
[INFO] store-wo-webapp-parent ............................. SUCCESS [  0.836 s]
[INFO] store-wo-webservice-parent                                         [pom]
[INFO] store-wo-webservice-parent ......................... SUCCESS [  0.831 s]
startlinenumbertodelete=` grep -n "[INFO] The following plugins have been resolved:" | tail -1 | sed 's/^\([0-9]\+\):.*$/\1/'`

出力:-

[INFO]       antlr:antlr:jar:2.7.2
[INFO]       backport-util-concurrent:backport-util-concurrent:jar:3.1
[INFO]       ch.ethz.ganymed:ganymed-ssh2:jar:build210
[INFO]       classworlds:classworlds:jar:1.1
[INFO]       classworlds:classworlds:jar:1.1-alpha-2
[INFO]       com.fasterxml.staxmate:staxmate:jar:2.2.1
[INFO]       com.google.code.findbugs:jsr305:jar:2.0.1
[INFO]       com.google.code.findbugs:jsr305:jar:3.0.1
[INFO]       com.google.code.gson:gson:jar:2.2.2
[INFO]       com.google.guava:guava:jar:14.0.1
[INFO]       com.google.guava:guava:jar:18.0
[INFO]       com.google.guava:guava:jar:19.0
[INFO]       com.googlecode.javaewah:JavaEWAH:jar:0.7.9
[INFO]       com.ibm.icu:icu4j:jar:58.1
[INFO]       com.intellij:annotations:jar:9.0.4
[INFO]       com.jcraft:jsch.agentproxy.core:jar:0.0.7
[INFO]       com.jcraft:jsch.agentproxy.jsch:jar:0.0.7
[INFO]       com.jcraft:jsch.agentproxy.sshagent:jar:0.0.7
[INFO]       com.jcraft:jsch.agentproxy.usocket-jna:jar:0.0.7
[INFO]       com.jcraft:jsch:jar:0.1.38
[INFO]       com.jcraft:jsch:jar:0.1.49
[INFO]       xpp3:xpp3_min:jar:1.1.4c
[INFO]    de.smartics.maven.plugin:buildmetadata-maven-plugin:maven-plugin:1.6.1:runtime
[INFO]    external.atlassian.jgitflow:jgitflow-maven-plugin:maven-plugin:1.0-m5.1:runtime
[INFO]    org.apache.maven.plugins:maven-antrun-plugin:maven-plugin:1.8:runtime
[INFO]    org.apache.maven.plugins:maven-assembly-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-clean-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-compiler-plugin:maven-plugin:3.8.0:runtime
[INFO]    org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:3.1.1:runtime
[INFO]    org.apache.maven.plugins:maven-deploy-plugin:maven-plugin:3.0.0-M1:runtime
[INFO]    org.apache.maven.plugins:maven-enforcer-plugin:maven-plugin:3.0.0-M2:runtime
[INFO]    org.apache.maven.plugins:maven-install-plugin:maven-plugin:3.0.0-M1:runtime
[INFO]    org.apache.maven.plugins:maven-jar-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-javadoc-plugin:maven-plugin:3.0.1:runtime
[INFO]    org.apache.maven.plugins:maven-jxr-plugin:maven-plugin:3.0.0:runtime
[INFO]    org.apache.maven.plugins:maven-project-info-reports-plugin:maven-plugin:3.0.0:runtime
[INFO]    org.apache.maven.plugins:maven-release-plugin:maven-plugin:2.5.3:runtime
[INFO]    org.apache.maven.plugins:maven-resources-plugin:maven-plugin:3.1.0:runtime
[INFO]    org.apache.maven.plugins:maven-site-plugin:maven-plugin:3.7.1:runtime
[INFO]    org.apache.maven.plugins:maven-surefire-plugin:maven-plugin:2.22.0:runtime
[INFO]    org.apache.maven.plugins:maven-surefire-report-plugin:maven-plugin:2.22.0:runtime
[INFO]    org.apache.maven.plugins:maven-war-plugin:maven-plugin:3.2.2:runtime
[INFO]    org.basepom.maven:duplicate-finder-maven-plugin:maven-plugin:1.3.0:runtime
[INFO]    org.codehaus.mojo:build-helper-maven-plugin:maven-plugin:3.0.0:runtime
[INFO]    org.codehaus.mojo:exec-maven-plugin:maven-plugin:1.6.0:runtime
[INFO]    org.codehaus.mojo:taglist-maven-plugin:maven-plugin:2.4:runtime
[INFO]    org.codehaus.sonar-plugins:maven-report:maven-plugin:RELEASE:runtime
[INFO]    org.jacoco:jacoco-maven-plugin:maven-plugin:0.8.1:runtime
[INFO]    org.openclover:clover-maven-plugin:maven-plugin:4.3.1:runtime
[INFO]    org.sonarsource.scanner.maven:sonar-maven-plugin:maven-plugin:3.5.0.1254:runtime

ベストアンサー1

コロンで区切られた4つのフィールドがある行が欲しいようですので、おおよその正規表現は次のようになります。

grep -E '^[^:]+[^: ]+:[^: ]+:[^: ]+:' < input > output

これには1行が必要です。

  • 非コロン文字(^[^:]+)で始まります。
  • その後にコロンやスペースがない内容([^: ]+)が続きます。
  • その後はコロン( :)
  • その後にコロンやスペースがない内容([^: ]+)が続きます。
  • その後はコロン( :)
  • その後にコロンやスペースがない内容([^: ]+)が続きます。
  • その後はコロン( :)

おすすめ記事