Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Gradle?

So I was using Eclipse and migrated over to Android Studio before sometime. I was introduced to Gradle for the first time. I have read that it is build automation for building, testing and publishing. But I have done these tasks one at a time while developing apps. I will code then test if it is working and then when I am happy with the result and think it is good enough to be used by everyone, I will publish it. Where does gradle come in between all these? Sorry if it is a very noob question but I have been reading and I am still unable to get my head around all this.

like image 735
vishalmullur Avatar asked Jul 02 '14 15:07

vishalmullur


People also ask

What are advantages of Gradle?

Gradle's performance advantagesIncremental build works for compilation, test execution, or any other task that happens in your build. A Gradle task is the equivalent of a Maven goal. Just a unit of work to get executed in the build. Gradle keeps track of each task's inputs and outputs.

Why we use Gradle instead of Maven?

Gradle allows custom dependency scopes, which provides better-modeled and faster builds. Maven dependency conflict resolution works with a shortest path, which is impacted by declaration ordering. Gradle does full conflict resolution, selecting the highest version of a dependency found in the graph.

What is the use of Gradle in Java?

Gradle is a general-purpose build toolGradle makes it easy to build common types of project — say Java libraries — by adding a layer of conventions and prebuilt functionality through plugins. You can even create and publish custom plugins to encapsulate your own conventions and build functionality.

Is Gradle really better than Maven?

Summary of performance resultsGradle is between 7 and 85 times faster than Maven when building incremental changes; benefits increase with number of subprojects. Gradle builds are 3 to 30 times faster than Maven builds when task outputs can be resolved Gradle's build cache.


3 Answers

The main advantage of the new Gradle-based build system is, you can easily define multiple

  • Build Types (E.g. debug and release)
  • Product Flavours (E.g. lite and pro version)

And define the whole build process for each one of those (and combinations) individually, such as:

  • Code set
  • Debuggable
  • Application Id
  • Signing Config
  • Dependencies

This allows for very neat things like having a different application id (package name) for debug releases, so that both release and debug can be installed at the same time.

like image 83
FD_ Avatar answered Oct 08 '22 11:10

FD_


At first there are some ideological reasons. Some developers just love command line tools. And you can dramatically increase your speed by chosing command line over GUI.

At the moment you are fine with your build process. But the grade of Automation is just limited, when using a gui tool. It will be made just for some special cases. With something like gradle, which just uses an entire scripting language for builds, there are no limits at all. And this is the second reason.

How you would achive automatically build the project, push apk on 50 different mobile devices, run the testsuite and then deploy the app to play and amazon after successfull test run every time when code is merged from develop to master branch with eclipse only?

like image 37
dre-hh Avatar answered Oct 08 '22 09:10

dre-hh


You will need a dependency management tool like maven or gradle for a good size project. Also, it will help you automate the release process which could be very complex

For a small personal app, it maybe overkill.

like image 25
Bill Lin Avatar answered Oct 08 '22 11:10

Bill Lin