-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (144 loc) · 5.76 KB
/
Makefile
File metadata and controls
175 lines (144 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# =============================================================================
# Spring Boot Course — Makefile
# =============================================================================
# Uso: make <target> [ARGS...]
# Ejemplo: make migrate DESC="add_users_table"
# =============================================================================
GRADLEW := gradlew
# Detección de sistema operativo
UNAME := $(shell uname 2>/dev/null || echo Windows)
ifeq ($(UNAME),Windows)
MIGRATION_SCRIPT = powershell -ExecutionPolicy Bypass -File generate-migration.ps1 -Description
else
MIGRATION_SCRIPT = ./generate-migration.sh
endif
# Colores
CYAN := \033[0;36m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RESET := \033[0m
.DEFAULT_GOAL := help
# =============================================================================
# AYUDA
# =============================================================================
.PHONY: help
help: ## Muestra esta ayuda
@echo ""
@echo "$(CYAN)Spring Boot Course — Comandos disponibles$(RESET)"
@echo "$(CYAN)==========================================$(RESET)"
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ { printf " $(GREEN)%-22s$(RESET) %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | sort
@echo ""
@echo "$(YELLOW)Variables:$(RESET)"
@echo " DESC Descripción de la migración (make migrate DESC='add_users')"
@echo " VER Versión de la migración (make create-migration VER=2 DESC='add_rooms')"
@echo ""
# =============================================================================
# BUILD
# =============================================================================
.PHONY: build
build: ## Compila el proyecto
$(GRADLEW) clean build
.PHONY: compile
compile: ## Compila sin limpiar ni ejecutar tests
$(GRADLEW) classes testClasses
.PHONY: version
version: ## Muestra la versión actual del proyecto
$(GRADLEW) printVersion
# =============================================================================
# EJECUCIÓN
# =============================================================================
.PHONY: run
run: ## Ejecuta la aplicación (perfil dev)
$(GRADLEW) bootRun
.PHONY: run-dev
run-dev: ## Ejecuta con perfil dev explícito
$(GRADLEW) bootRun --args='--spring.profiles.active=dev'
.PHONY: run-prod
run-prod: ## Ejecuta con perfil prod
$(GRADLEW) bootRun --args='--spring.profiles.active=prod'
# =============================================================================
# TESTS
# =============================================================================
.PHONY: test
test: ## Ejecuta todos los tests
$(GRADLEW) test
.PHONY: test-class
test-class: ## Ejecuta una clase de test (make test-class CLASS=HotelServiceTest)
$(GRADLEW) test --tests "com.lgzarturo.springbootcourse.$(CLASS)"
.PHONY: coverage
coverage: ## Ejecuta tests y genera reporte JaCoCo (build/reports/jacoco/)
$(GRADLEW) jacocoTestReport
.PHONY: coverage-check
coverage-check: ## Verifica que la cobertura supere el 85%
$(GRADLEW) jacocoTestCoverageVerification
# =============================================================================
# CALIDAD DE CÓDIGO
# =============================================================================
.PHONY: lint
lint: ## Verifica estilo con ktlint y detekt
$(GRADLEW) checkCodeStyle
.PHONY: format
format: ## Aplica correcciones automáticas (ktlint + detekt)
$(GRADLEW) formatCode
.PHONY: fix
fix: ## Aplica todas las correcciones automáticas disponibles
$(GRADLEW) fixAll
.PHONY: quality
quality: ## Ejecuta lint + tests + cobertura (gate completo)
$(GRADLEW) codeQuality
.PHONY: lint-report
lint-report: ## Genera reportes de análisis en build/reports/
$(GRADLEW) lintReport
# =============================================================================
# BASE DE DATOS
# =============================================================================
.PHONY: ddl
ddl: ## Genera DDL desde entidades JPA (build/schema-create.sql)
$(GRADLEW) generateDDL
.PHONY: diff-migration
diff-migration: ## Muestra instrucciones para generar migración incremental
$(GRADLEW) diffMigration
.PHONY: create-migration
create-migration: ## Crea migración Flyway desde DDL (make create-migration VER=2 DESC="add_rooms")
ifndef VER
$(error Variable VER no definida. Uso: make create-migration VER=2 DESC="add_rooms")
endif
ifndef DESC
$(error Variable DESC no definida. Uso: make create-migration VER=2 DESC="add_rooms")
endif
$(GRADLEW) createMigration -Pmigration_version=$(VER) -Pdescription="$(DESC)"
.PHONY: migrate
migrate: ## Genera migración automática desde entidades JPA (make migrate DESC="add_users")
ifndef DESC
$(error Variable DESC no definida. Uso: make migrate DESC="add_users_table")
endif
$(MIGRATION_SCRIPT) "$(DESC)"
# =============================================================================
# DOCKER
# =============================================================================
.PHONY: docker-up
docker-up: ## Levanta los servicios de Docker (base de datos)
docker compose up -d
.PHONY: docker-down
docker-down: ## Detiene los servicios de Docker
docker compose down
.PHONY: docker-logs
docker-logs: ## Muestra logs de los contenedores
docker compose logs -f
.PHONY: docker-ps
docker-ps: ## Lista contenedores activos
docker compose ps
# =============================================================================
# ATAJOS COMBINADOS
# =============================================================================
.PHONY: ci
ci: ## Simula el pipeline de CI completo (build + quality)
$(GRADLEW) clean build codeQuality
.PHONY: setup
setup: ## Configura el entorno local (copia .env y levanta Docker)
@if [ ! -f .env ]; then cp .env.example .env && echo "$(GREEN).env creado desde .env.example$(RESET)"; fi
$(MAKE) docker-up
.PHONY: reset
reset: ## Limpia build artifacts y detiene Docker
$(GRADLEW) clean
$(MAKE) docker-down