在哪里放置 Stash 插件的 .p12 文件?

Where to put .p12 file for a Stash plugin?

所以我正在尝试编写一个 Stash post 接收挂钩插件,最终将一些相关信息写入 Google 电子表格。 为此,我必须从 .p12 文件中提取用于 Oauth2 身份验证的私钥。我做了几个测试项目,它们只是简单的 Java 命令行应用程序,我只是在根目录中取出 .p12 文件并从那里调用它。我做了另一个,我会从资源文件夹中调用它,它也工作得很好。

我移植了那段代码,解决了我所有的依赖关系,然后 运行 它。我天真地将 .p12 文件放在根目录中,显然出现了找不到文件的异常。查看目标目录,发现它从来没有把它带过来,重新调整并把它放在资源文件夹中,看看它是否会被带走。另一个文件未找到异常并且仍然​​不在目标目录中。我试着把它放在其他几个不同的地方,看看它是否会被带过来。到目前为止没有任何效果。

我做错了什么?

我想我可以把文件放在我的 Stash 实例上并从那里调用它,但我宁愿把它自己包含在插件中。

我搜索了很多,但没有找到真正相关的内容。有人有什么建议吗?

如果其他人看到这个并且想知道我是如何解决它的... 一位 Atlassian 开发人员向我指出,我的主要问题是我只是将 .p12 文件放在根资源目录中。一旦我将它放入其中自己的文件夹中,它就像一个魅力。我使这一切正常工作的最终代码(在其他 Stack Overflow 问题的帮助下)

String sheetURL = "XXXXXX@XXXXXX-XXXX.iam.gserviceaccount.com";
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jsonFactory = new JacksonFactory();
String[] SCOPESArray = {"https://spreadsheets.google.com/feeds", "https://spreadsheets.google.com/feeds/spreadsheets/private/full", "https://docs.google.com/feeds"};

final List SCOPES = Arrays.asList(SCOPESArray);
GoogleCredential credential = null;
InputStream stream = null;
File tempFile = null;

try {
    stream = this.getClass().getClassLoader().getResourceAsStream("authentication/key.p12");
    tempFile = File.createTempFile("temp", "temp");
    IOUtils.copy(stream, new FileOutputStream(tempFile));
}
catch (IOException e) {
    print(e.toString());
}
finally {
    if (stream != null) {
        IOUtils.closeQuietly(stream);
    }
}

credential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setServiceAccountId(sheetURL)
    .setServiceAccountScopes(SCOPES)
    .setServiceAccountPrivateKeyFromP12File(tempFile) 
    .build();