C
Dev Tools/Build API/Lesson 03

Build + API — Maven · Gradle · curl · Postman

30 min·theory

Build + API — Maven · Gradle · curl · Postman

🎯 After reading this lesson

After finishing this lesson, you will be able to confidently do the following three things.

  • ✅ Choose between Maven vs Gradle + understand why to use Wrapper
  • ✅ curl + Postman + Newman workflow
  • ✅ Automate API regression testing in GitHub Actions

Keep the learning objectives as a checklist and close the lesson once you can answer all of them.

Maven vs Gradle — Java Build Standards

In one line: An automation tool for dependency management, build, test, and deployment.

ItemMavenGradle
Released20042007
SyntaxXML (pom.xml)Groovy / Kotlin DSL (build.gradle)
ExpressivenessDeclarative (low)Imperative + Declarative (high)
Build speedSlow (~45s)Fast (~12s, incremental build)
CacheWeakStrong (build cache + daemon)
Learning curveLowMedium
AndroidXStandard
Korean large companiesManyGrowing trend

Same dependency, different syntax:

xml
<!-- Maven pom.xml -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
gradle
// Gradle build.gradle
implementation 'org.springframework.boot:spring-boot-starter-web'

> 💡 When to use which: New projects = Gradle. Existing Maven projects = keep as is. Spring Initializr also defaults to Gradle.

💻 📌 ./gradlew vs gradle — Version Pinning Is the Key

curl + Postman — API Testing

curl = terminal HTTP client. The standard for CI, debugging, and documentation examples.

Essential options:

  • -X POST — method
  • -H "Header: value" — add header
  • -d '{"key":"value"}' — body (POST/PUT)
  • -i — include response headers
  • -v — verbose (full request and response)
  • -o file — save to file
  • -L — follow redirects

Examples:

bash
# GET
curl -i https://api.github.com/users/torvalds

# POST + JSON
curl -X POST https://api.example.com/login \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"x"}'

# Authorization header
curl -H "Authorization: Bearer $TOKEN" https://api.example.com/me

# File upload
curl -X POST -F "[email protected]" https://api.example.com/upload

Postman = GUI + collaboration features:

  • Collection — API group (shared with team)
  • Environment — dev/stage/prod variables
  • Tests — validate responses with JS (pm.expect(...))
  • Mock Server — fake API responses (frontend development without backend)
  • Newman — run collections via CLI (CI integration)

> 💡 curl is for code examples, CI, and quick debugging. Postman is for team collaboration and complex scenarios. Use both.

💻 📌 Postman + Newman CI — Automating API Regression Testing
💻 📌 Build & API Command Reference
# === Maven ===
mvn clean package                   # Build (includes tests)
mvn clean install -DskipTests       # Skip tests and install to local repo
mvn dependency:tree                 # Dependency tree
mvn -pl module-a clean install      # Specific module in multi-module
mvn versions:display-dependency-updates  # List of available dependency updates

# === Gradle ===
./gradlew build                     # Build + test
./gradlew bootRun                   # Run Spring Boot
./gradlew dependencies               # Dependency tree
./gradlew :module-a:build           # Specific module only
./gradlew build --scan              # Build scan (visualization)
./gradlew clean build --refresh-dependencies  # Ignore cache

# === npm / pnpm ===
npm install                         # Install based on package-lock.json
npm ci                              # Exactly as per lock (CI recommended)
npm update                          # Minor/patch updates
npm outdated                        # List of outdated packages
pnpm install                        # Disk/speed ↑ compared to npm

# === Python ===
python -m venv .venv                # Create virtual environment
source .venv/bin/activate           # Activate (macOS/Linux)
.venv\Scripts\activate              # Windows
pip install -r requirements.txt
pip install -e .                    # For development (editable install)
pip freeze > requirements.txt        # Save current state

# === curl in practice ===
# Measure response time
curl -o /dev/null -s -w "%{\n}" URL
# Check HTTP/2
curl --http2 -I https://example.com
# Headers only (HEAD method)
curl -I https://example.com
# Save and reuse cookies
curl -c cookies.txt -d "user=x" URL/login
curl -b cookies.txt URL/dashboard

🤖 Try Asking AI Like This

Knowing the concepts from this lesson lets you give specific instructions to AI. Not a vague 'fix this,' but a request with the right vocabulary — that's where token savings begin.

  • 'Migrate this pom.xml to build.gradle.kts'
  • 'Check this dependency graph for conflicts and duplicates'

Why This Reduces Tokens

Without the concepts, even after receiving an AI response you have to ask again: 'What does that mean?' Those follow-up questions are what consume tokens. Learn the concept once and the conversation ends in one go.

Build + API — Maven · Gradle · curl · Postman - Dev Tools