2
我編寫了一個Gradle插件,其版本在其構建腳本中指定。從自己的代碼獲取自定義Gradle插件的版本
這個插件有可能在有人使用它時知道它自己的版本嗎? (即當它調用apply(Project project)
方法時)
我編寫了一個Gradle插件,其版本在其構建腳本中指定。從自己的代碼獲取自定義Gradle插件的版本
這個插件有可能在有人使用它時知道它自己的版本嗎? (即當它調用apply(Project project)
方法時)
對於我的插件,我在構建期間將一個字段嵌入名爲Implementation-Version的MANIFEST.MF文件中。然後我讀在這一領域的運行時,通過訪問這樣的包:
def pkg = MyPlugin.class.getPackage()
return pkg.implementationVersion
或使用輔助類,如:https://github.com/nebula-plugins/nebula-core/blob/master/src/main/groovy/nebula/core/ClassHelper.groovy#L16從清單搶任意字段。
它工作正常,謝謝。用於在清單中添加屬性的片段:'jar {清單{ }屬性(「Implementation-Version」:版本) } }'' – Vincent