您当前的位置: 首页 >  apache

Bulut0907

暂无认证

  • 0浏览

    0关注

    346博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Apache Maven help插件介绍和pom.xml中进行property属性的定义、引用

Bulut0907 发布时间:2022-07-13 08:54:17 ,浏览量:0

目录
  • 1. help插件和目标
  • 2. 使用help:evaluate查看属性值
    • 2.1 查看pom.xml定义的property
    • 2.2 查看系统的属性值
    • 2.3 查看系统的环境变量
    • 2.4 查看project的pom.xml中的属性值
    • 2.5 访问maven的settings.xml中的属性值

1. help插件和目标

详细的使用请参考官网:https://maven.apache.org/plugins/maven-help-plugin

目标说明help:active-profiles列出当前工程已激活的profilehelp:all-profiles列出当前工程所有可用profilehelp:describe描述一个插件和Mojo(Maven Old Java Object,插件的一个执行目标)的属性help:effective-pom以XML格式展示有效POMhelp:effective-settings为当前工程以XML格式展示计算得到的settings配置help:evaluate在交互模式下对Maven表达式进行计算help:system显示平台详细信息列表,如系统属性和环境变量 2. 使用help:evaluate查看属性值 2.1 查看pom.xml定义的property

在pom.xml中定义的property如下

  
    my-value
  

然后交互式的查看属性值

C:\Users\dell\Desktop\maven-learn>mvn help:evaluate
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.hh:maven-learn >-------------------------
[INFO] Building my-project 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:evaluate (default-cli) @ maven-learn ---
[INFO] No artifact parameter specified, using 'com.hh:maven-learn:jar:0.1' as project.
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${my-key}
[INFO]
my-value
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
2.2 查看系统的属性值

可以获取系统的属性值,也就是Java中的System.getProperties()可以获取到的属性

[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${java.runtime.version}
[INFO]
11.0.15+10-LTS
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
2.3 查看系统的环境变量
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${env.JAVA_HOME}
[INFO]
d:install_software\java11\zulu11.56.19-ca-jdk11.0.15-win_x64
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
2.4 查看project的pom.xml中的属性值

使用表达式${project.xxx}可以访问当前pom.xml中的元素值

[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${project.organization.name}
[INFO]
my-company
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${project.licenses[0]}
[INFO]

  Apache License, Version 2.0
  https://www.apache.org/licenses/LICENSE-2.0
  
    55
    14
    
      com.hh:maven-learn:0.1
      C:\Users\dell\Desktop\maven-learn\pom.xml
    
  
  
    56
    13
    
  
  
    57
    12
    
  

[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
2.5 访问maven的settings.xml中的属性值
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${settings.localRepository}
[INFO]
D:\install_software\maven\apache-maven-3.8.6\repository
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
关注
打赏
1664501120
查看更多评论
立即登录/注册

微信扫码登录

0.3228s