Gradle build no complete - spring

I create the project in spring, but I have a problem with build gradle. I'm using IntelliJ and i have instal JDK Java 10 and Gradle 4.7. How to fix this?
enter image description here

Check that you have
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
in your build.gradle and re-import the project (Gradle project tool window) in IDE.

Related

Can't build kotlin files using gradle kotlin DSL in Intellij idea

I'm trying to set up a kotlin project with gradle kotlin DSL as build system in IntelliJ idea,but I'm getting below error when try to run buil.gradle.kts file. I have tried with different kotlin compiler version but no luck.
warning: default scripting plugin is disabled: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
error: unable to evaluate script, no scripting plugin loaded
IntelliJ Version:
Gradle version : 6.3
build.gradle.kts
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.70"
// Apply the application plugin to add support for building a CLI application.
application
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
application {
// Define the main class for the application.
mainClassName = "Music.AppKt"
}
The correct way to build a Gradle project in IDEA is to execute "Main menu | Build | Build project" if your build is delegated to Gradle in IDEA settings, or execute one of the build tasks in Gradle tool window: http://jetbrains.com/help/idea/work-with-gradle-tasks.html
However, the behavior you described can be considered a usability problem, I created an issue https://youtrack.jetbrains.com/issue/KT-37814, please follow it for updates.

How to fix Plugin with id 'com.github.dcendents.android-maven' not found. in android studio

I am creating an android application in android studio. I am adding a library to my project which was downloaded from here . When i was adding this library to my project it was showing an error called "Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.". Please tell me how to fix it.
In top level build.gradle dependencies, paste this classpaths.
I wonder why cant i've seen this method in websites.
Anyway, I fixed it using this way.
dependencies {
//YOUR DEPEDENCIES
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
There come two scenarios here:
If you are using apply plugin: 'com.github.dcendents.android-maven' in your module level gradle.
This plugin is generally used to distribute and upload your library project to bintaray.
In this case, all you have to do is make use of correct combinations of gradle plugin and maven-gradle-plugin.
The combination of the following versions is working for me:
Inside project level gradle
classpath 'com.android.tools.build:gradle:2.3.0+'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
and in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
In module level gradle:apply plugin: 'com.github.dcendents.android-maven'
You can check the compatible versions list from Github
If you are not using it, as it is in your case just remove
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
and
apply plugin: com.github.dcendents.android-maven
Just delete the line "apply plugin: 'android-maven'"
in the beginning of build.gradle,
apply plugin: 'com.android.application'
apply plugin: 'android-maven'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
the project doesn't need maven.
Try to add these lines to your project's build.gradle file into dependencies block:
classpath 'com.github.dcendents:android-maven-plugin:1.2'
Like this
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
It just worked for me.
For a Gradle 4.1+ you could do in Project-level build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "com.github.dcendents.android-maven" version "2.0"
}
Add these lines in project.gradle dependencies:
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
Just add this two line in your gradle file
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
For a Gradle 7, I deleted this line in the build.gradle module level:
apply plugin: 'com.github.dcendents.android-maven'
With reference to this answer posted above, I encountered another problem No service of type Factory available in ProjectScopeServices after using it.
I fixed it by including com.github.dcendents:android-maven-gradle-plugin:1.4.1 ( as mentioned in this answer to the above linked question) instead of com.github.dcendents:android-maven-plugin:1.2 in the dependencies in the project gradle.
Don't be too confused. android-maven-gradle-plugin:1.4.1 is only an updated version of the android-maven-plugin:1.2 . As mentioned in the Readme in the git repo for this plugin, dcendents mentioned that he was requested to rename the plugin name by Android maven plugin developers.
This is all depend your gradle version. please check https://github.com/dcendents/android-maven-gradle-plugin i found my solution in there.
dependencies {
// The gradle plugin and the maven plugin have to be updated after each version of Android
// studio comes out
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
finally i can solve this error after trying three days
the solution is very simple just remove the module or library project completely from your project and use gradle dependency instead.
Just copy this in your app module's build.gradle inside dependencies closure
dependencies {
// YOUR OTHER DEPENDENCIES
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'}
to success make this steps when you r online
If in your project any module using this id then you must declare below two dependency at your project level build.gradle file -
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
the problem is that android just, don't know the repos and you must specify the repository like that:
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
}
}
apply plugin: 'com.github.dcendents.android-maven'
add following under project level gradle file
dependencies {
...
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
Upgrade your Github library version as your Gradle version and Github library version doesn't match.
Check the version compatibility here:
https://github.com/dcendents/android-maven-gradle-plugin
It probably causes from android sdk . So i don't know how to occur it but i solved it following these steps.
If you see these warnings on the begining of the console when you enter cordova build or run etc.
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\anypath (DEPRECATED)
Firstly, need to configure ANDROID_HOME path
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#setting-environment-variables
In windows pc, you should enter path from environment variables settings.
https://www.youtube.com/watch?v=S5wqTSuL3j4 ( this video may help you )
Option-1 Then you can add new gradle version https://gradle.org/install/
Option-2 Replace gradle version on /platforms/android/app/build.gradle
from classpath 'com.android.tools.build:gradle:X.X.X
to classpath 'com.android.tools.build:gradle:3.0.1
You can find the right version of gradle by entering command editor:
gradlew --version or gradle --version
or checking this file in your project then find "distributionUrl"
platforms\android\gradle\wrapper\gradle-wrapper.properties
distributionUrl=\https://services.gradle.org/distributions/gradle-4.4-all.zip
Hope it helps you.

mvn install from gradle

I have a created a gradle project and a different project was created in Maven.
The jar from the maven project is a dependency to the gradle project.
Is it possible to run the mvn install for the maven project and add the jar to the gradle project?
Thanks & Regards
Mukund
All that's needed on the Gradle side is:
repositories {
mavenLocal()
}
dependencies {
compile "some.group:someArtifact:1.0"
}

Android studio having fun of me with Gradle version

I have just updated Android Studio to 0.4.2, and the first time I launched it I got an error saying:
Failed to refresh Gradle project 'MyProject'
Gradle version 1.8 is required. Current version is 1.9. If using the gradle wrapper, try editing the distributionUrl in /home/alex/gradle/wrapper/gradle-wrapper.properties to gradle-1.8-all.zip.
Please fix the project's Gradle settings.
The fun fact no. 1 is that the specified path doesn't exist - anyway, I have changed the distributionUrl in gradle-wrapper.properties in my project to 1.8, and relaunching Studio now asks for 1.9!
Any ideas on how I can fix this?
SOLUTION
Solved this by deleting the gradle folder. It downloaded the libs and solved the dependencies on its own.
Android Studio version 0.4.2 wont work with Gradle 1.8 you have to use gradle 1.9
Check following things :
1.inside every build.gradle file in your project the gradle dependency should look like.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
2.If you are using Local Distribution change the path from File>Settings>Compiler>Gradle and point it to gradle 1.9.
Change the path in gradle-wrapper.properties to
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-bin.zip

how to tell gradle to download all the source jars

Ideally, we would like to add a task for downloading all the source jars for the first level and transitive dependencies of our project. Is there a way to do that?
If not, is there a command line option to supply like maven has to get all the sources downloaded onto our machines?
It seems like that should just be the default these days at least for first level dependencies as it gives you the javadoc in eclipse then which is very nice when doing the code completion stuff.
The eclipse task can be configured with downloadSources. Following is an example of that configuration
apply plugin: 'java'
apply plugin: 'eclipse'
eclipse {
classpath {
downloadSources=true
}
}
So run
gradle cleanEclipse eclipse
to have it download sources.
If you use Eclipse and want to navigate the source code of your dependencies there, then the Eclipse plugin does this for you.
Install the eclipse plugin by adding apply plugin: "eclipse" to your build.gradle file. Then run gradle eclipse to generate the Eclipse .project, .classpath and .settings files. The plugin will download all available sources automatically and add references them in the .classpath file (see the sourcepath attribute of the classpathentry element).
To import the project into Eclipse, choose File > Import... > Existing Projects into Workspace and select your project.
(I'm not sure whether the Idea plugin does the same for Idea users, but it may do).
Another catch not mentioned in other answers is when you are using mavenLocal() repository in your gradle.build file. If there are downloaded jar in that local maven repo but no downloaded sources or javadocs in that repo, then gradle will not even try to download javadocs or sources for you. Even with enabled eclipse.classpath.downloadJavadoc and eclipse.classpath.downloadSources.
The solution is to remove mavenLocal() from repositories or place it to bottom of the list. Or you can setup maven to download sources and javadocs and clean your maven local repository (~/.m2/repository).
A more detailed description of the problem is here.
Here is how to add the required configuration in Gradle using the IDEs' plugins:
For Eclipse:
apply plugin: 'java'
apply plugin: 'eclipse'
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
}
For IntelliJ
apply plugin: 'java'
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
To run these plugins:
gradle cleanEclipse eclipse
gradle cleanIdea idea
Piohen's comment above should be it's own answer (since it was the only solution that worked for me)
Right click your project, then select "Build Path" --> "Configure Build Path";
Select "Order and export"
Select "Web App Libraries", and click "Bottom" button, then the "Web App Libraries" will be on the bottom;
And to get this into the Gradle Eclipse plugin (so you don't need to do it manually every time):
Why is Eclipse not attaching 3rd party libs source files to a WTP-faceted Gradle project?
There is only one problem here. This only works if you are generating NEW projects. If you are working on mature projects that can't be re-generated using Gradle, the above suggestions will not work.
One thing I should add is that the version of Gradle/Builsdhip plugin strongly depends on the version of Java you use to start Eclipse. They must all be compatible. I had to switch my Eclipse (current version) from Java 11 back to Java 8 to fix Buildship (3.0.1) errors. We are, and have been, stuck on Gradle 4.2.1 for some time due to API changes in Gradle breaking our build. So to move to Java 11 we have to move to a new version of Gradle, Buildship, and Eclipse. Ugh! Oh yeah, this also fixed the issue mentioned in this thread. Source is now avalable again.

Resources