100% found this document useful (1 vote)
52 views

Maven and Gradle

yes-sri

Uploaded by

srikanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
52 views

Maven and Gradle

yes-sri

Uploaded by

srikanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 16
What Is Maven? Maven is a build tool that helps in project management. The tool helps in building and documenting the project Maven is written in Java and C# and is based on the Project Object Model CPOM) The tool is used to build and manage any Java-based project. It simplifies the day to day work of Java Developers and helps them in their projects The Problems That Maven Solved: Getting right JAR files for each project as there may be different versions of separate packages To download dependencies visiting of the official website of different software is not needed. We can just visit “mvnrepositiry.com” Helps to create the right project structure which is essential for execution What is Gradle ? 0 Gradle _ Gradie is an open source build automation tool that is based on the concept of Apache Maven and Ant. G Itintroduces @ Kotlin and Groovy-based DSL(Domain Specific Language) instead of XML (Extensible Markup Language) for declaring the project configuration. Grade offers an elastic model that can help the development lifecycle from compiling and packaging code for web and ‘mobile applications It provides support for the building, testing, end deploying software on different platforms. thas been developed for building automation on many languages and platforms, including Java, Scala, Android, C / C++, and Groovy, Gradle provides integration with several development tools and servers, including Eclipse, Intell), Jenkins, and Android Studio. Some Leading Enterprise companies like \kedIn, Google and Netflix use Grade tis developed to overcome the drawbacks of Maven and Ant and supports a wide range of IDEs. Why to Use Gradle ? Kg Gradle ‘The following is the list of features that Gradle provides: Free and open-source High Performance Highly Customizable Performance Flexibility Mult: proect build support Extonsibity Incremental Bus Familiar with the Java Grace Wrapper User Experience coocecoceceo Writing Build Script * Build script file is build.gradle * We have to describe tasks and projects by using a Groovy or Kotlin for script * We can define custom tasks as well. * Example of simple custom task: task myTask { doLast { Gradle Projects and Tasks aw Gradle QlEverything in Gradle is based on the project and task 1. Task 2. Project Gradle Task 0? Gradle U Task is a single unit of work that a build performs. U These tasks can be compiling classes, creating a JAR, Generating Javadoc, and publishing some archives to a repository and more. U single atomic piece of work for a build process. Types of Task 0 Gradle O There are two types of tasks in Gradle: Default task Custom task Default Tasks aw Gradle O Default tasks are predefined tasks of Gradle. O We can list the default tasks by running the gradle task commands. = $gradle tasks + $gradle tasks --all Custom Tasks @ cradle Q Gradle allows us to create tasks and these tasks are called custom tasks. Custom tasks are user-defined tasks that are built to perform some specific work. task task_name{ group "group_name for the task’ description “description of the task’ doFirst{ ----code for execution----- Gradle Repository AW Cradle Q Specify the location of modules/libraries so that the gradle build can consume them. The location for storing modules/libraries is called a repository. Q Repositories can be in different forms, such as a local or remote repository. O At runtime, Gradle will discover the declared dependencies required for operating a specific task. Once a dependency is resolved, the resolution mechanism stores the essential files of dependency in the local cache memory also call dependency cache. U Future builds reuse the files saved in the cache to skip unnecessary network calls. eta tee LM Cradle 1. Ivy repositories 2. Maven repository 3. Flat directory repository configure Maven central as dependency source. a Grad le Q In your build file you specify the remote repositories to look for dependencies. Gradle supports Maven and Ivy repositories to search for dependencies. The following listing shows how to configure Maven central as dependency coposte You can also specity othor targets, for example Bintray Stortes Tnevencentral() ‘83 Maven repository ) repositories { on ) maven (“http://jcenter.bintray.com/") repositories ( ‘maven { ‘url "https://repo.maven.apache.org/maven2/” > e Gradle Dependencies @? Gradle O Gradle build script describes a process of building projects. Most of the projects are not self-contained. They need some files to compile and test the source files. G For example, to use Spring, we must include some Spring JARs in the classpath. Gradle uses some unique script to manage the dependencies, which needs to be downloaded. C Every dependency is applied to a specified scope. For example, some dependencies are used to compile the source code and some will be available at runtime. O Gradle considers the outcomes of building and publishing the projects A dependency can be used on different phases of the aw seperate Gradle O Compile: The dependencies required to compile the source of the project. C Runtime: These dependencies are used at runtime by classes. By default, it also contains the compile-time dependencies. Q Test Compile: These dependencies are required to compile the test source of the project. It also contains the compiled classes and the compile-time dependencies. CO Test Runtime: These dependencies are required to run the tests. It also contains runtime and test compile dependencies. Gradle vs. Maven @ Cradle Tris a software project management system that is primarily useel It isa build automation system that uses a Groory of Korlin based for java projects DSL (domain-specific language ) ruses an XML file for declaring the project, its dependencies, the It does not use an XML. file for declasing the project build oxder, aad its cequired plugin. configuration tis based on the phases of the fixed and linear model. It is based on a graph of task dependencies that do the work, Trdoes not use the build cache; thus, ts build time is slower than It avoids the work by tracking input and output tasks and only Grade. rus the tasks that have beea changed. Therefore it gives a faster performance. ‘Maven has a limited number of parameters and requirements, so. Gradle is highly customizable; it provides a wide range of IDE customization is a bit complicated. “support custom builds.

You might also like