eriwen
(Eric Wendelin)
October 16, 2015, 7:20pm
1
The Gradle IDEA plugin doesn’t seem to know how to handle Play Framework apps yet (as of Gradle 2.8).
In order to prevent IDEA from going fireball red everywhere when developing on Play I had to add this to my build.gradle file:
apply plugin: "idea"
idea {
module {
sourceDirs += file("app")
testSourceDirs += file("test")
scopes.COMPILE = [plus: [configurations.play], minus: []]
scopes.RUNTIME = [plus: [configurations.playRun], minus: [configurations.play]]
scopes.TEST = [plus: [configurations.playTest], minus: [configurations.playRun]]
}
}
It’d be cool if the Gradle Play plugin could handle this automatically, or at least put this in the Play Documentation
Cheers.
1 Like
emlagowski
(Marcin Lagowski)
October 18, 2015, 4:18pm
2
Thats all? I have added that to my code but it still “can’t resolve symbol …”
eriwen
(Eric Wendelin)
October 19, 2015, 12:36am
3
You’ll have to have the standard Play directory structure.
gradle cleanIdea idea
is assumed as well.
This is Gradle 2.8, Play 2.3.x and Java 8
emlagowski
(Marcin Lagowski)
October 19, 2015, 1:18am
4
I have tried with Play 2.4.3 and 2.3.10, Gradle 2.8-RC2 and java 1.8-20 and IntelliJ 14 Ultimate. IntelliJ still can’t resolve symbols and everything is red. This is my build.gradle. http://pastebin.com/LkpTiT41
Maybe you done something more?
emlagowski
(Marcin Lagowski)
October 19, 2015, 9:01am
5
Ok. I tried again and now this working!
gradlew cleanIdea
gradelw idea
gradlew ideaModule
Thanks for that!
1 Like
cyang
(Chun Yang)
October 21, 2015, 3:48pm
7
I’ve found it helpful to mark the compile/test resources and generated sources as well.
idea.module {
// Source directories
sourceDirs += file('app')
testSourceDirs += file('test')
// Generated sources
def generated = [
file("$buildDir/playBinary/src/compilePlayBinaryRoutes"),
file("$buildDir/playBinary/src/compilePlayBinaryTwirlTemplates")
]
generated.each { src ->
sourceDirs += src
generatedSourceDirs += src
}
// Output directories
outputDir = file("$buildDir/playBinary/classes")
testOutputDir = file("$buildDir/playBinary/testClasses")
// Excluded dirs
excludeDirs -= buildDir
excludeDirs += [
outputDir,
testOutputDir,
file("$buildDir/playBinary/lib"),
file("$buildDir/playBinary/reports"),
file("$buildDir/playBinary/results"),
file("$buildDir/tmp"),
file("$buildDir/assets")
]
// Dependencies
scopes.COMPILE = [ 'plus' : [ configurations.play ] ]
scopes.TEST = [ 'plus' : [ configurations.playTest ] ]
iml.withXml { provider ->
def content = provider.node.component.content.first()
// Resources
def confUrl = 'file://$MODULE_DIR$/conf'
def confAttrs = content.find { it.@url == confUrl }?.attributes()
if (confAttrs) {
confAttrs.remove('isTestSource')
confAttrs.type = 'java-resource'
} else {
content.appendNode('sourceFolder', [url: confUrl, type: 'java-resource'])
}
// Test resources
def testResourcesUrl = 'file://$MODULE_DIR$/test/resources'
def testResourcesAttrs = content.find { it.@url == testResourcesUrl }?.attributes()
if (testResourcesAttrs) {
testResourcesAttrs.remove('isTestSource')
testResourcesAttrs.type = 'java-test-resource'
} else {
content.appendNode('sourceFolder', [url: testResourcesUrl, type: 'java-resource'])
}
}
}
Admittedly, the code for marking resources is ugly. I’m all ears for improvements.
emlagowski
(Marcin Lagowski)
October 21, 2015, 4:26pm
8
I cant find anything about evolutions working with play plugin Does it works for you? What dependencies I need to add? I think have tried everything(play 2.4.3 and 2.3.10 with playEbean, play java ebean and avaje ebeanorm) and it still doesnt work.
cyang
(Chun Yang)
October 21, 2015, 4:48pm
9
There’s an outstanding pull request for the Gradle Play plugin to package resources (including evolution scripts) correctly. https://github.com/gradle/gradle/pull/528
emlagowski
(Marcin Lagowski)
October 21, 2015, 5:15pm
10
Thanks!! Can’t wait it will be released! Btw. What ebean plugin in dependency you are using? I found this … But
play ‘com.typesafe.play:play-ebean_2.11:2.0.0’
model class nit fiund exception
play ‘com.typesafe.play:play-java-ebean_2.11:2.4.0-M2’
when running model enhancement exception
play ‘org.avaje.ebeanorm:avaje-ebeanorm:6.9.1’
compiling but not evolution
@edit
I have build your pull request. But now I see there is no evolution file generating at all… Does it work for you?
cyang
(Chun Yang)
October 22, 2015, 4:55pm
11
Sorry, I’m not using ebean.
You need to write your own evolution files and place them in the right directory .
kknd22
(Chris L)
November 14, 2015, 3:14am
13
This works like charm for me. Thanks, Eric
Just curious how/where did you figure it out - I am unable to find any other reference/documents on this
-Chris L
1 Like
eriwen
(Eric Wendelin)
November 16, 2015, 8:36pm
14
Chris, IIRC I figured it out by looking at the XML under the .idea/ directory and cross-referenced that with a bit of the Gradle source code. Wasn’t as easy as we’d like.
Achaiah
(Ach A)
February 16, 2016, 7:07pm
15
Hey guys,
Has anyone else had success with this approach and IntelliJ 16? I’ve followed everything here and my IntelliJ 16 isn’t even recognizing the external libraries besides Java 1.8. Things seem totally broken with the IDE.
2 Likes
hmatinho
(Hugo Matinho)
April 15, 2016, 6:44am
16
I can confirm that the above works in IntelliJ 15 but not in the current 2016.1 or any versions above 15, any help would be appreciated.
It looks like IDEA 16 splits projects into several modules that are not affected by idea.module, I think? I fixed the highlighting issue by going into Build, Execution & Deployment > Build Tools > Gradle from Idea’s Settings dialog and unchecking “Create separate module per source set”. Would there be a way to target a particular module with the idea plugin?
1 Like
sleshJdev
(Eugene)
October 11, 2016, 10:21pm
18
Greetings guys! Any everyone who have have success experience of generate idea project using gradle?
Just I’m spend a little bit time trying fix it. After generated idea project and opened it, intellijIdea don’t see gradle’s dependencies. Could someone help me please?
sleshJdev
(Eugene)
October 12, 2016, 9:12pm
19
So, In my module .iml file there are orderEntry nodes with correct absolute path:
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/com.typesafe.play/play-slick-evolutions_2.11/2.0.2/c39998e138dfc55d8217ef0cabee8db412108e10/play-slick-evolutions_2.11-2.0.2.jar!/"/>
</CLASSES>
<JAVADOC/>
<SOURCES>
<root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/com.typesafe.play/play-slick-evolutions_2.11/2.0.2/3b4dfa42d55333f24eba317e8b45a7c2f6efd45c/play-slick-evolutions_2.11-2.0.2-sources.jar!/"/>
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/9.4-1204-jdbc42/aae989d89b2f9b10900044d85881e3a65137b1a7/postgresql-9.4-1204-jdbc42.jar!/"/>
</CLASSES>
<JAVADOC/>
<SOURCES>
<root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/9.4-1204-jdbc42/9519b3d8569209b31a27a99f9faecaff2c97efbd/postgresql-9.4-1204-jdbc42-sources.jar!/"/>
</SOURCES>
</library>
</orderEntry>
Why Intellij Idea don’t see these dependencies? I cannot work, because of error. Could some one help me please?
TienTT
(Trần Thanh Tiên)
December 29, 2016, 4:02pm
20
Thanks! It’s working well for me after I wasted of time (5 days)