Maven settings.xml配置文件中的可重用常量/变量

时间:2018-12-20 14:40:32

标签: xml maven maven-3 settings

在我的settings.xml中,我有:

first = [
  { "id": "15", "name": "raza" },
  { "id": "1", "name": "sahir" },
  { "id": "54", "name": "ayyan" },
  { "id": "3", "name": "tahir" },
];

second = [
  { "id": "15", "name": "razi" },
  { "id": "3", "name": "qasim" },
  { "id": "1", "name": "taha" },
];

let h = {}; second.map(x=>h[x.id]=1);     // we use hash map with data2 ids
let result = first.filter(x=>!h[x.id]);

console.log(result);

您会看到用户名和密码重复了几次。
为了方便起见,我想将它们放入常量并仅在一个位置进行更改。

<servers>
    <server>
      <username>MYUSERNAME</username>
      <password>MYPASSWORDHASH</password>
      <id>central</id>
    </server>
    <server>
      <username>MYUSERNAME</username>
      <password>MYPASSWORDHASH</password>
      <id>snapshots</id>
    </server>
    ...
    <server>
      <username>MYUSERNAME</username>
      <password>MYPASSWORDHASH</password>
      <id>maven</id>
    </server>
</servers>

问题:
1.是否可以在Maven settings.xml文件中声明此类内容?
2.如果没有,还有另一种方法可以消除这种冗余?

0 个答案:

没有答案