gpt4 book ai didi

gradle - 如何检测 gradle 插件是否在 Intellij 内部运行

转载 作者:行者123 更新时间:2023-12-03 05:18:44 31 4
gpt4 key购买 nike

如何检测 gradle 构建脚本是否在 Intellij 内部运行?我想稍微更改项目设置以优化和解决 IDE 用户的问题。
如果我安装了 Android 插件,那么我可以使用,但如果没有那个插件,就没有明显的钩子(Hook)。

properties.containsKey('android.injected.invoked.from.ide')
背景:我有一个源映射两次的 Gradle 构建,这是因为一个构建 Graal native 测试启动器的模块。这并不理想,但需要单独讨论,并且与各种插件(junit 5 + graal)的限制有关。
09:38   Duplicate content roots detected
Path [/home/yschimke/okhttp/okhttp-dnsoverhttps/src/test/java] of module [okhttp-parent.native-image-tests.main] was removed from modules [okhttp-parent.okhttp-dnsoverhttps.test]
Also 4 more paths were deduplicated. See idea log for details

最佳答案

来自 https://www.baeldung.com/junit-5-conditional-test-execution
在 Mac 和 Windows IDEA_INITIAL_DIRECTORY 上使用 XPC_SERVICE_NAME 环境属性

def isIDE = properties.containsKey('android.injected.invoked.from.ide') ||
(System.getenv("XPC_SERVICE_NAME") ?: "").contains("intellij")
(System.getenv("XPC_SERVICE_NAME") ?: "").contains("intellij") ||
System.getenv("IDEA_INITIAL_DIRECTORY") != null
后者来自 https://github.com/JetBrains/intellij-community/blob/f396a4f0777cc1e79908a637f9f814eda794d3f8/native/WinLauncher/WinLauncher/WinLauncher.cpp#L1199

关于gradle - 如何检测 gradle 插件是否在 Intellij 内部运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64726619/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com