Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some fixes to the IDEA integration.

  • Loading branch information...
commit fae1fce3025fb9481d857816a2ae4b93ce86f565 1 parent 0827fb4
Luke Daley alkemist authored
38 ratpack-gradle-plugin/src/main/groovy/org/ratpackframework/gradle/IdeaConfigurer.groovy
@@ -4,32 +4,52 @@ import org.gradle.api.Action
4 4 import org.gradle.api.Project
5 5 import org.gradle.api.XmlProvider
6 6 import org.gradle.plugins.ide.idea.model.IdeaModel
  7 +import org.gradle.process.JavaExecSpec
7 8
8 9 class IdeaConfigurer implements Action<Project> {
9 10
10 11 private final RatpackAppSpec ratpackApp
11 12
12   - IdeaConfigurer(RatpackAppSpec ratpackApp) {
  13 + private JavaExecSpec runSpec
  14 +
  15 + IdeaConfigurer(RatpackAppSpec ratpackApp, JavaExecSpec runSpec) {
13 16 this.ratpackApp = ratpackApp
  17 + this.runSpec = runSpec
14 18 }
15 19
16 20 @Override
17 21 void execute(Project project) {
18   - def idea = project.extensions.getByType(IdeaModel)
  22 + def ideaModule = project.extensions.getByType(IdeaModel).module
  23 + def ideaWorkspace = project.rootProject.extensions.getByType(IdeaModel).workspace
19 24
20   - idea.module.scopes.RUNTIME.plus += ratpackApp.springloadedClasspath
21   - idea.workspace.iws.withXml { XmlProvider provider ->
  25 + ideaModule.scopes.RUNTIME.plus += ratpackApp.springloadedClasspath
  26 + ideaWorkspace.iws.withXml { XmlProvider provider ->
22 27 Node node = provider.asNode()
23 28
24 29 Node runManagerConfig = node.getByName('component').find { it.'@name' == 'RunManager' }
25 30
26   - // Add an application configuration
27   - runManagerConfig.'@selected' = 'Application.Ratpack'
  31 + def jvmArgs = new ArrayList<>(runSpec.allJvmArgs)
  32 + def cpArg = jvmArgs.indexOf("-cp")
  33 + if (cpArg < 0) {
  34 + cpArg = jvmArgs.indexOf("-classpath")
  35 + }
  36 +
  37 + if (cpArg >= 0) {
  38 + jvmArgs.remove(cpArg) // -cp
  39 + jvmArgs.remove(cpArg) // associated value
  40 + }
  41 +
  42 + for (arg in ratpackApp.springloadedJvmArgs) {
  43 + if (!jvmArgs.contains(arg)) {
  44 + jvmArgs.add(arg)
  45 + }
  46 + }
  47 +
28 48 runManagerConfig.append(new XmlParser().parseText("""
29   - <configuration default="false" name="Ratpack" type="Application" factoryName="Application">
  49 + <configuration default="false" name="Ratpack Run (${ideaModule.name})" type="Application" factoryName="Application">
30 50 <extension name="coverage" enabled="false" merge="false" />
31 51 <option name="MAIN_CLASS_NAME" value="${ratpackApp.mainClassName}" />
32   - <option name="VM_PARAMETERS" value="${ratpackApp.springloadedJvmArgs.collect { "&quot;$it&quot;" }.join(" ")}" />
  52 + <option name="VM_PARAMETERS" value="${jvmArgs.collect { "&quot;$it&quot;" }.join(" ")}" />
33 53 <option name="PROGRAM_PARAMETERS" value="" />
34 54 <option name="WORKING_DIRECTORY" value="${ratpackApp.appRootRelativePath}" />
35 55 <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -37,7 +57,7 @@ class IdeaConfigurer implements Action<Project> {
37 57 <option name="ENABLE_SWING_INSPECTOR" value="false" />
38 58 <option name="ENV_VARIABLES" />
39 59 <option name="PASS_PARENT_ENVS" value="true" />
40   - <module name="${idea.module.name}" />
  60 + <module name="${ideaModule.name}" />
41 61 <envs />
42 62 <RunnerSettings RunnerId="Debug">
43 63 <option name="DEBUG_PORT" value="63810" />
2  ratpack-gradle-plugin/src/main/groovy/org/ratpackframework/gradle/RatpackAppSpec.groovy
@@ -36,7 +36,7 @@ class RatpackAppSpec {
36 36 List<String> getSpringloadedJvmArgs() {
37 37 def jarFile = getSpringloadedJar()
38 38 if (jarFile) {
39   - ["-Dspringloaded=profile=grails", String.format("-javaagent:%s", jarFile.absolutePath), "-noverify"]
  39 + [String.format("-javaagent:%s", jarFile.absolutePath), "-noverify"]
40 40 } else {
41 41 Collections.emptyList()
42 42 }
8 ratpack-gradle-plugin/src/main/groovy/org/ratpackframework/gradle/RatpackPlugin.groovy
@@ -24,6 +24,7 @@ import org.gradle.api.Plugin
24 24 import org.gradle.api.Project
25 25 import org.gradle.api.plugins.GroovyPlugin
26 26 import org.gradle.api.plugins.ApplicationPlugin
  27 +import org.gradle.api.tasks.JavaExec
27 28 import org.gradle.plugins.ide.idea.IdeaPlugin
28 29
29 30 class RatpackPlugin implements Plugin<Project> {
@@ -34,9 +35,6 @@ class RatpackPlugin implements Plugin<Project> {
34 35 project.plugins.apply(GroovyPlugin)
35 36 project.plugins.apply(ApplicationPlugin)
36 37
37   -
38   -
39   -
40 38 project.repositories {
41 39 mavenCentral()
42 40 }
@@ -68,7 +66,7 @@ class RatpackPlugin implements Plugin<Project> {
68 66 }
69 67 }
70 68
71   - project.run {
  69 + JavaExec run = project.run {
72 70 dependsOn configureRun
73 71 main = ratpackApp.mainClassName
74 72 workingDir = project.file("src/ratpack")
@@ -79,7 +77,7 @@ class RatpackPlugin implements Plugin<Project> {
79 77 }
80 78
81 79 project.plugins.withType(IdeaPlugin) {
82   - new IdeaConfigurer(ratpackApp).execute(project)
  80 + new IdeaConfigurer(ratpackApp, run).execute(project)
83 81 }
84 82 }
85 83

0 comments on commit fae1fce

Please sign in to comment.
Something went wrong with that request. Please try again.