Reputation: 75
I'm currently using Eclipse with Buildship plugin. I want to download Spring and Hibernate JARs into my gradle project, how do I do this? I placed the following in my build.gradle file for dependencies:
apply plugin: 'java'
dependencies {
compile 'org.springframework:spring-context:4.2.6.RELEASE'
}
repositories {
jcentral()
}
jar {
manifest {
attributes 'Main-Class': 'one.MainClass'
}
}
Upon running gradle build, it says that the build is successful, and I can run the JAR file produced. I cannot however, find the Spring JARs.
How can I download the Spring jars into my eclipse project so i can add them to the build path?
Upvotes: 0
Views: 899
Reputation: 5236
If you know where the jars are that you want, then do:
Right-click on project -> Build path -> Configure build path... -> Libraries (tab) -> Add External JARs...
Then select all the jars you want from C:\Users\USER\.gradle\caches\modules-2\files-2.1...
Upvotes: 1
Reputation: 1685
If you use the Eclipse plugin for Gradle, Gradle can handle adding jars to the Eclipse path for you:
allprojects{
apply plugin: 'eclipse'
}
After you include that in your build script, simply run gradle eclipse
and it will generate the .settings
directory and the .project
and .classpath
files typical of Eclipse projects, replacing them if they already exist. Run this task and refresh your project in Eclipse anytime you change dependencies.
Alternatively, there is a Gradle plugin for Eclipse in the marketplace that can handle this, so long as you import your project as a gradle project.
Upvotes: 3