Addendum: My question is different from this question, since that question addresses downloading of exactly same dependencies every time the project is executed, that is again and again. So once a dependency IS downloaded, that same dependency will not be downloaded again.
BUT my question is different: I need to work on a project from the start till the end in a completely offline system. So I can never fetch online dependencies during the build. I need to download them manually and host them within my project directory.
I am trying to get started with Gradle plugin in Eclipse and I am following this guide. Initially, when I followed the tutorial completely and did EXACTLY what the tutorial instructed, all went well. I have pasted the build.gradle
at the end of the question.
But now there is a twist/challenge. I need to learn how to host and manage all dependencies offline for an offline program.
The project in the tutorial is using Google's Guava libraries found here. SO I have created a libs
directory in my project root directory and downloaded all files into it and added all those .jar
files to my project's build path
in Eclipse.
But I don't know how to proceed from here. So that is the question. What changes should I make to my build.gradle
file and what else should I do in my project, so that my project can pick those .jar
dependencies from its own folder and run well on an offline system.
build.gradle copied and pasted from linked tutorial - picks 'online' dependencies. Question is how to host and use these dependencies offline for offline project:
apply plugin: 'java'
apply plugin: 'application'
repositories {
jcenter()
}
dependencies {
compile 'com.google.guava:guava:20.0' // Google Guava dependency
testCompile 'junit:junit:4.12' // JUnit dependency for testing
}
mainClassName = 'com.boraji.tutorial.MainApp' // Main class with main method
答案 0 :(得分:0)
Gradle does a good job of avoiding redownloading artifacts, but you can pass --offline to grade to prevent from accessing the network during builds. If it needs something from the network that it doesn't have, instead of attempting to fetch it, your build will fail.
Please have a look at this question How to configure gradle to work "offline" (using cached dependencies). answer credit @iagreen