我正在尝试创建一个 Gradle 任务,取决于 assembleRelease 任务。 它将根据生成的release-APK路径准备一封邮件,并在默认邮件程序中打开它。
我搜索了很多相关内容,发现 Java 的 Desktop-API 可以做到这一点。
但是当我尝试在 Gradle 脚本中使用它时,它给出以下错误:
Unable to resolve class Desktop
是否可以在 Gradle 脚本中创建这样的“邮件”任务?
最佳答案
通过在 gradle.properties
中指定属性来编写代码以打开电子邮件应用
通过下面的代码访问属性
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream("gradle.properties");
// load a properties file
prop.load(input);
// get the property value and print it out
System.out.println(prop.getProperty("user.password"));
} catch (IOException ex) {
ex.printStackTrace();
}
看看这个 tutorial
关于java - 如何在 Gradle 中打开带有主题和正文的默认邮件程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43039321/