Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attaching Gradle sources in IntelliJ IDEA

Once after I create a Gradle project in IntelliJ using the default gradle wrapper and create directories option I see the project structure gets created with build.gradle file.

IntelliJ tips me to "You can configure Gradle wrapper to use distribution with sources. It will provide IDE with Gradle API/DSL documentation" - but I am not able to attach the sources even after clicking "Ok, apply suggestion". The Gradle project is getting refreshed but the sources are not attached.

We are using a Nexus repository.

like image 807
John Jai Avatar asked Oct 30 '14 20:10

John Jai


People also ask

How do I link a Gradle project?

Open the Project pane from the left side of the IDE and select the Android view. Right-click on the module you would like to link to your native library, such as the app module, and select Link C++ Project with Gradle from the menu.

How does IntelliJ recognize Gradle project?

With Intellij 14 you can just open the the build. gradle file using Intellij's File --> Open. this will import the gradle project, including all dependencies.

How do I enable Gradle Auto Import in IntelliJ?

Go to File > Settings (or hit Ctrl + Alt + s ), and navigate to Build, Execution, Deployment > Build Tools > Gradle. Select Automatically import this project on change to build script files and hit OK: JetBrains, who created IntelliJ IDEA, say that this setting can slow things down on large projects.


1 Answers

To improve on @anon58192932 answer you can use only gradleVersion and distributionType fields of Wrapper task and don't need to manually create distributionUrl which is more error prone since you could change gradle version in one place, but not in the other.

task wrapper(type: Wrapper) {     gradleVersion = '4.2'     distributionType = Wrapper.DistributionType.ALL } 

@edit gradle 4.8+ will produce error for above. Use instead

wrapper {     gradleVersion = '4.2'     distributionType = Wrapper.DistributionType.ALL } 
like image 193
Kinmarui Avatar answered Sep 21 '22 23:09

Kinmarui