How to fix gradle eclipse plugin to use correct JRE when importing gradle project? - gradle

Currently, I can run ./gradlew eclipse and create the eclipse project and that works great in that it uses JavaSE-1.8. Unfortunately, I have 12 projects and don't really feel like loading each one at a time.
The issue though is when I use the gradle eclipse plugin and import the project, it decides to use JavaSE-1.7 which I did 'used' to use. I can't seem to find a quick setting in the gradle plugin, though it would be even nicer if I could just put the info in the build.gradle file for everyone to use.
The following code blew up in my face when I imported the project..
https://issues.gradle.org/browse/GRADLE-3100
Well, the .remove method blew up. Removing that resulted in ending up in 1.7 even though I put 1.8.
I am using gradle-2.11-bin.zip
UPDATE: I removed the '' replacing with single ' so that it doesn't throw an exception but still loads 1.7. To work around this issue, I load with gradle plugin and then run ./gradlew eclipse and then collapse all projects and using the shift key, I then select all projects and refresh and it moves to 1.8 (so the gradlew eclipse works while the gradle plugin doesn't :( they must be different code path).

Related

Gradle dependency autocompletion in IntelliJ IDEA

I've been searching around for a while and can't seem to find anything regarding this issue. I'm new to Java in general and for the last half a year I've been learning Maven. I use IntelliJ IDEA and I'm already used to the fact that it can autocomplete dependency coordinates (groupId, artifactId, version) if you sync the repository. It works nicely and it feels natural when you decide to add some dependency after the initial project generation.
Now I'm trying to switch to Gradle (which is a requirement on my new job) and I'm studying it. And I can't get over the first roadblock that I've encountered with it: there is no autocompletion and it even seems like IntelliJ IDEA's support for this kind of feature has degraded over time (I saw a video of old version of IDEA where there used to be a "Generate" -> "Add maven dependency" option, which I cannot find in the latest version). I even tried a bunch of plugins with names like "Gradle Dependency Helper" and non of them worked.
Are we supposed to type the whole dependency coordinates to add them to gradle build? Because that feels like a big downside of Gradle with IDEA. Or is there some well hidden feature that I missed?
You may manage Gradle dependencies in Intellij IDEA using View→Tool windows→Dependencies.
It allows to add or remove dependencies from dependencies section in your build.gradle and gives full-text search for available dependencies.

Gradle composite build with custom gradle plugin fails in IntelliJ: "Could not find method api() for arguments"

I have a Gradle composite build project which contains a custom Gradle plugin. This project builds fine when using Gradle CLI, but IntelliJ fails.
I tried a few different variations on the plugin version within the resolutionStrategy block: org.test:test-plugin:0.0.1 and test-plugin:test-plugin.gradle.plugin:0.0.1 as described here: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers - both of those work from the CLI; changing to invalid values ("blah:blah") causes a failure.
I've made a sample Github project that contains the code to reproduce, here: https://github.com/mwmitchell/intellij-gradle-plugin-composite-build-bug along with instructions to reproduce and a workaround. The workaround is something that's not really feasible for me, as it requires repeating configuration code (dependencies, plugins etc.) and I have many, many projects that require the same/common configuration.
I would expect IntelliJ to load the project successfully, just like the CLI does. It seems like IntelliJ is loading the sub-project (:project-1:library-a) before the parent (:project-1), such that the java-library is not actually applied to the sub-project when it's evaluated.
Thanks for the sample project! Indeed, it is an issue in IntelliJ IDEA, see this ticket.
Gradle projects can have only one settings.gradle. You can include subproject "library-a" with include 'project-1:library-a' in the main settings.gradle.

Unindex maven repository https://repo.grails.org/grails/core in Intellij with Grails 3.0

I am using IntelliJ IDEA 15.0.1 and I am trying to create a Grails 3.0 application and ran into issues.
While trying to create a Grails 3.0 project I get the following.
After doing what it does I also noticed that the Grails Tool Window is on the upper left is gone. When I open the repositories list and click on update I get the following error:
I have seen some other questions that it says to click on 'Disable....' but i do not think so...
Will not i need the grails core repo at some poing during development?
How come the Grails Tool Window disappeared? How to make it come back?
To resolve this problem i changed (the file is build.gradle)
"https://repo.grails.org/grails/core/"
for
"http://repo.grails.org/grails/repo/"
So close and open your project again.
For what it's worth, if you are using gradle for all of your projects, you can remove maven from your development machine entirely. then, add 'apply plugin: "maven" ' to your build.gradle files. then, you can completely ignore your IDE's messages about Unindexed remote maven repositories. gradle will take care of it for you.

Intellij Debugging picking up old version project files

I am debugging code in Intellij. I use maven to build the project and there are various versions of the project sitting in the local .m2 repository. Intellij keeps on picking the old version of the code from the previous snapshot of the project when I start debugging. How do I make IntelliJ debug the latest code from the local repository?
You can tell Intellij 2016 to ask you each time which source code to step through.
File->Settings->Debugger
Show alternative source switcher
Try removing .jar and .war files that contain your code from your ~/.m2/repository/
For me the issue is that I built something and it is now registered in Maven under what Maven considers a newer version, but isn't what I was currently working on. I compiled, say, version "2.1" to debug something and then went back to working on "sand-box-idea-SNAPSHOT". I keep thinking why isn't Intellij picking up my latest sand box change but it's because it's deferring to the Maven version 2.1 which Maven assumes is better than 'sand-box-SNAPSHOT'.
It may be that you have some plug-ins interfering with IntelliJ's build process. I know that the Google Protocol Buffers Plugin can cause my Intellij to be unable to detect dirty classes that need to be re-compiled.
I've met similar behavior, maybe it can help you :-)
I developed app (using maven) and during the time I change output packaging from jar to war. Maven repository than contained both versions, jar and war, because maven does not remove old jar when you change it. As project pointed to mvn repository, it still used old reference to jar but new version within war was updated.
I was really upset as maven compilation and tests worked fine but Idea used me old version. I've had rebuild idea project and it worked later fine.
I have seen this very recently after upgrading from IDEA 13 to IDEA 14. It seems like launching configurations created in IDEA 13 are no longer automatically triggering a mvn package prior to launch.
In order to fix this I manually added a mvn goal in the "Before Launch" dialog.

STS M2E 'Plugin execution not covered by lifecycle configuration" Error - Flex-Mojos

I am trying to write my pom.xml for a multimodal flex application. I have been using this resource as an example:
http://www.sonatype.com/books/mvnref-book/reference/flex-dev-sect-creating-with-archetype.html
I am using M2E v1.01 but I am faced with a number of 'Plugin execution not covered by lifecycle configuration" errors. As far as I can see - there are no m2E connectors available to resolve this and I have tried all the Maven advice I can find - to include:
Clean
Update dependencies
Update project configuration
The problem only occurs if the project is declared as swc or swf package. My next move to ask Eclipse to 'permanently mark goal as ignored' - which seems a little brash.
Any advice would be appreciated.
Thanks in advance.
With STS 2.8.0, we have upgraded m2eclipse to be version 1.0. However, this can cause a bit of trouble with existing projects. I wrote a blog on this a couple of months ago.
http://blog.springsource.org/2011/10/18/upgrading-maven-integration-for-springsource-tool-suite-2-8-0/
Essentially, the new architecture for m2eclipse requires that each maven plugin you use must be mapped to one Eclipse plugin to handle the plugin's execution inside of Eclipse. This obviously causes problems since not every maven plugin author has the knowledge or time to create also create and maintain an Eclipse plugin.
By marking the plugin as ignored, you are saying that the plugin should never be executed inside of Eclipse (implying that whenever you need it to be executed, you will do so from the command line). Once marked as ignored, you can then change it to execute, which means that it should always be executed whenever the associated lifecycle is performed in Eclipse. This may cause performance problems, and so only do it if you know the risks.
If all this is too much for you, then STS provides a downgrade option to revert to an older version of m2eclipse. Go to the Dashboard extensions page. Unfortunately, you will have to manually revert all changes to your .project and .classpath files (we provide an auto-upgrade mechanism, but not a downgrade mechanism...presumably everything is in version control).
Any questions or problems should be sent to the STS forums:
http://forum.springsource.org/forumdisplay.php?32-SpringSource-Tool-Suite
You can check this alpha connector "Flex Maven Integration for Flash Builder" on the eclipse marketplace: http://marketplace.eclipse.org/node/648556.

Resources