2

私が追加しました:

<licenses>
  <license>
    <name>The Apache Software License, Version 2.0</name>
    <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    <distribution>repo</distribution>
    <comments>A business-friendly OSS license</comments>
  </license>
</licenses>

を pom ファイルに追加すると、作成した新しいソース ファイルごとに Apache ライセンスがきちんと表示されます。ただし、ライセンス テキストは次のように表示されます。

/*
 * Copyright 2013 MyUserName.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
   ...
 */

なりたい

/*
 * Copyright 2013 OldCurmudgeon <--- Note the new name.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
   ...
 */

このフィールドは、プロパティから取得されたように見えますが{user}、テンプレートが示唆しています。プロジェクトごとに変更する方法はありますか?


以下の提供されたオプションをいくつか試した後の答え。

pomファイルの変更については正しかった。

私は Apache-2.0 ライセンスを選択しました。明らかに、選択したライセンスを調整する必要があります。

pom ファイルに追加します。

<licenses>
  <license>
    <name>The Apache Software License, Version 2.0</name>
    <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    <distribution>repo</distribution>
    <comments>A business-friendly OSS license</comments>
  </license>
</licenses>

Java テンプレートを変更します(Tools/Templates/Java/Java Class(および必要に応じてその他)/Open In Editor(button)) :

変化する:

 ...
 * @author ${user}
 ...

 ...
 * @author ${project.property.user}
 ...

次に、ライセンス ファイルを変更します(Tools/Templates/Licences/The license you selected/Open In Editor(button)) :

...
${licensePrefix}Copyright ${date?date?string("yyyy")} ${project.organization!user}.
...

...
${licensePrefix}Copyright ${date?date?string("yyyy")} ${project.property.user}.
...

次に、pom ファイルに追加します。

<properties>
  <!-- For the License -->
  <user>OldCurmudgeon</user>
</properties>

これで完了です。ライセンスファイルを変更しなければならなかったのは残念です。おそらく、NetBeans の今後のリリースでは、これは必要なくなるでしょう。

4

2 に答える 2

1

PROJECT 固有の方法 (User.properties はグローバル) が必要な場合は、ライセンス ヘッダー テンプレートを変更する必要があります。値を ${user} から ${project.property.user} に変更し、各プロジェクトの pom.xml ファイルで project/properties pom 要素内で「user」プロパティを宣言します。このnetbeans.orgの問題を参照してください

于 2013-04-04T18:53:12.637 に答える