Course – Black Friday 2025 – NPI EA (cat= Baeldung)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Partner – Orkes – NPI EA (cat=Spring)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Partner – Orkes – NPI EA (tag=Microservices)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Partner – Orkes – NPI EA (cat=Java)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2025 – NPI (cat=Baeldung)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

1. Introduction

Maven and Gradle are the two most popular build automation and dependency management tools that simplify the developer’s job. While Maven is a widely used build automation tool, Gradle is more modern and flexible.

As someone who’s transitioning from Maven to Gradle, it’s crucial to understand equivalent commands in Gradle.

In this tutorial, we’ll explore Maven commands and their equivalents in Gradle. We’ll also take a look at how to publish artifacts of one project in the Maven local repository so that it will be available for other projects to use.

2. Maven Commands and Their Gradle Equivalents

In this section, we’ll explore some of the most popular Maven commands and their equivalent commands in Gradle.

2.1. Updating Dependencies

Both Maven and Gradle allow us to update project dependencies to ensure we have the latest versions of them.

In Maven, the following is the typical command used to update the project dependencies:

mvn clean install -U

The mvn clean install with the -U (uppercase) option will force Maven to check for updated versions of dependencies and download them from the remote repository (even if they’re already present in the local repository).

However, this command doesn’t update the non-snapshot dependencies or release versions. If you want to update non-snapshot dependencies, you still need to modify the pom.xml file, or alternatively, you can use the following command:

mvn versions:use-latest-releases

This command will replace any release versions that are not snapshots and do not have a year-month-day suffix with the latest release version.

In Gradle, we use the below command to force refresh dependencies from remote repositories.

gradle build --refresh-dependencies

This command ignores the locally cached versions of dependencies and forces Gradle to do a fresh lookup in the configured repositories. It’s important to note that Gradle checks the remote repositories for updates of dynamic versions like SNAPSHOT, latest.release, and 1.+, and if a newer version is available, it’ll download it.

However, even though Gradle ignores the cache, it doesn’t blindly re-download every artifact. Instead, it compares the hash values of the files in the local and remote repositories, and if they match, it uses the existing file instead of re-downloading it.

2.2. Building and Installing the Project

In Maven, to clean, compile, test, package, and install the project, we use the below command:

mvn clean install

We can achieve the same in Gradle using the below command:

gradle clean build

This command deletes the build/ directory and then compiles, tests, and packages the project.

2.3. Other Common Commands

Let’s now take a look at some of the other commands that are quite commonly used in Maven and their equivalent commands in Gradle:

Maven Command Gradle Command Purpose
mvn clean gradle clean Removes the build directory
mvn compile gradle compileJava Compiles Java code
mvn test gradle test Runs tests
mvn package gradle jar / gradle war Creates JAR/WAR file
mvn verify gradle check Runs all verification tasks
mvn deploy gradle publish Publishes the artifact to a remote repository
mvn site No direct equivalent Maven generates a project site; Gradle doesn’t have this feature built-in
mvn dependency:tree gradle dependencies Shows project dependencies
mvn dependency:purge-local-repository gradle –refresh-dependencies Forces a re-download of dependency

3. Working with Multiple Projects

While working on multiple projects, we often have projects that are dependent on each other. We need to make the artifact of one project available in the local repository for another project to use.

In Maven, we run the command mvn install to make the artifact available in the local repository. But how do we accomplish the same in the case of Gradle? Let’s take a look.

For Gradle versions prior to 7, we use the maven plugin as follows in the build.gradle file:

apply plugin: "java"
apply plugin: "maven"
group = 'com.example'
version = '1.0.0'

And then run:

gradle install

This command installs the artifact into ~/.m2/repository, making it available for dependent projects.

For Gradle 7 and later, we use the maven-publish plugin to publish the artifact to the local repository:

plugins {
  id 'java'
  id 'maven-publish'
}
group = 'com.example'
version = '1.0.0'
publishing {
  publications {
    mavenJava(MavenPublication) {
      from components.java
    }
  }
  repositories {
    mavenLocal()
  }
}

The above script defines two plugins. The Java plugin helps in performing standard Java compilation and packaging, and the Maven-publish plugin helps publish the artifact in the local repository.

Next, we have the group and version properties, which define the project’s unique identifier and version.

The publishing block helps us define how the project’s artifacts should be published. The mavenJava publication, of type MavenPublication, is created using the from components.java statement.

This will ensure that the compiled Java components, including the JAR file and other metadata, are included in the publication.

Finally, as part of the repositories, we defined mavenlocal(), which refers to the maven local repository.

Once we define these, we can then run mvn install to install the artifact in the local Maven repository. The artifact is now available for other local projects to use.

4. Conclusion

In this article, we compared commands for both Maven and Gradle. As we’ve seen, they’re quite similar.

What can be done in Maven can also be done in Gradle; however, they differ in terms of configurations and commands we need to run. While it takes some time to get used to Gradle, the transition is easier if we compare and understand the similarities between the two.

Course – Black Friday 2025 – NPI EA (cat= Baeldung)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Partner – Orkes – NPI EA (cat = Spring)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Partner – Orkes – NPI EA (tag = Microservices)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2025 – NPI (All)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

eBook Jackson – NPI EA – 3 (cat = Jackson)