问题
我想将交互式调试器与 IntelliJ 一起使用。 不幸的是,我无法说服 IntelliJ 加载和编译插件。但是,我可以做到gradle clean build
,并且插件按预期构建并运行其测试。
具体来说,我正在尝试调试对gradle-js-plugin 的本地更改, 而IntelliJ 说它找不到. (我在想也许这与它们的加载方式有关,但这是一个猜测。) com.google.javascript.jscomp.CompilerOptions
spock.lang.Specification
我尝试过的事情
注意:我没有在步骤之间恢复任何流程。
0. 我的第一个猜测
我在docs.codehaus.org上注意到了一个 howto。IntelliJ 找不到,因此我对其进行了调整以与以下内容一起使用:org.gradle.launcher.GradleMain
GradleLauncher
import org.gradle.GradleLauncher
class GradleScriptRunner {
public static void main(String[] args) {
GradleLauncher.newInstance(
"-p",
"/path/to/gradle-js-plugin/src/test/resources/build.gradle",
"clean assemble"
)
}
}
结果: IntelliJ 不会编译该项目。
1. Per Peter Niederwieser 的回答Fix idea project & debug via plugin
脚步
~# cd /path/to/gradle-js-plugin && gradle cleanIdea idea
- 打开新创建的项目并尝试使用第 0 步中的 ScriptRunner 进行调试。
结果:项目编译(耶!),但我只能在GradleScriptRunner.groovy
.
2. Per Peter Niederwieser 的回答run gradle CLI w/special options
1 & 2. 为清晰起见合并:
~# export GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
~# gradle clean assemble
Listening for transport dt_socket at address: 5005
- 配置 IntelliJ 以连接到此端口并开始调试(见图):
对于这一步,我尝试了以下 .gradle 文件配置:
1. 只使用 build.gradle
--build.gradle--
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'js'
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile findProject "/path/to/gradle-js-plugin"
}
}
repositories {
mavenLocal()
mavenCentral()
}
结果:
FAILURE: Build failed with an exception.
* Where:
Build file '/path/to/gradle-js-plugin/src/test/resources/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating root project 'resources'.
> No such property: findProject for class: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8 mins 50.498 secs
2. 同时使用 build.gradle 和 settings.gradle
--settings.gradle--
include "/path/to/gradle-js-plugin"
--build.gradle--
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'js'
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
}
repositories {
mavenLocal()
mavenCentral()
}
结果:
FAILURE: Build failed with an exception.
* Where:
Build file '/path/to/gradle-js-plugin/src/test/resources/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating root project 'resources'.
> Plugin with id 'js' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 13.553 secs
我的设置
摇篮
~# gradle -v
------------------------------------------------------------
Gradle 1.0
------------------------------------------------------------
Gradle build time: Tuesday, June 12, 2012 12:56:21 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.7.0_04 (Oracle Corporation 23.0-b21)
OS: Linux 3.2.0-2-amd64 amd64
爪哇
~# java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)
智能
IntelliJ IDEA Ultimate 117.499 w/ Bundled Gradle plugin
希望
任何能让我在插件中进入调试模式的提示。