Skip to content

Commit

Permalink
Merge pull request #164 from makevook/issue/163
Browse files Browse the repository at this point in the history
refactor: gradle 멀티 모듈 도입
  • Loading branch information
seungyeop-lee authored Jul 19, 2024
2 parents 1144825 + 50a240c commit 44423e2
Show file tree
Hide file tree
Showing 223 changed files with 153 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- develop
paths:
- "api/**"
- "server/**"

jobs:
deploy:
Expand All @@ -27,7 +27,7 @@ jobs:
module: ./cicd
args: >-
deploy
--source-dir=api
--source-dir=server
--profile=dev
--ssh-dest=env:SSH_DEST
--ssh-key=env:SSH_KEY
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- main
paths:
- "api/**"
- "server/**"

jobs:
deploy:
Expand All @@ -27,7 +27,7 @@ jobs:
module: ./cicd
args: >-
deploy
--source-dir=api
--source-dir=server
--profile=prod
--ssh-dest=env:SSH_DEST
--ssh-key=env:SSH_KEY
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-stag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- release
paths:
- "api/**"
- "server/**"

jobs:
deploy:
Expand All @@ -27,7 +27,7 @@ jobs:
module: ./cicd
args: >-
deploy
--source-dir=api
--source-dir=server
--profile=stag
--ssh-dest=env:SSH_DEST
--ssh-key=env:SSH_KEY
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "api/src/test/resources/migrate/sql"]
path = api/src/test/resources/migrate/sql
url = git@github.com:makevook/vook-sql.git
[submodule "server/api/src/test/resources/migrate/sql"]
path = server/api/src/test/resources/migrate/sql
url = git@github.com:makevook/vook-sql.git
1 change: 0 additions & 1 deletion api/settings.gradle

This file was deleted.

8 changes: 4 additions & 4 deletions cicd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VERSION := $(shell git describe --tags --always --dirty)
.PHONY:deploy-dev
deploy-dev:
dagger call -v deploy \
--source-dir=../api \
--source-dir=../server \
--profile=dev \
--ssh-dest=file:./secrets/dev/dest.txt \
--ssh-key=file:./secrets/dev/ssh.key \
Expand All @@ -14,7 +14,7 @@ deploy-dev:
.PHONY:deploy-stag
deploy-stag:
dagger call -v deploy \
--source-dir=../api \
--source-dir=../server \
--profile=stag \
--ssh-dest=file:./secrets/stag/dest.txt \
--ssh-key=file:./secrets/stag/ssh.key \
Expand All @@ -25,7 +25,7 @@ deploy-stag:
.PHONY:deploy-prod
deploy-prod:
dagger call -v deploy \
--source-dir=../api \
--source-dir=../server \
--profile=prod \
--ssh-dest=file:./secrets/prod/dest.txt \
--ssh-key=file:./secrets/prod/ssh.key \
Expand All @@ -35,7 +35,7 @@ deploy-prod:

.PHONY:build-jar
build-jar:
dagger call -v build-api-jar --dir=../api --test export --path out/api.jar
dagger call -v build-api-jar --dir=../server --test --sub-module=api export --path out/api.jar

.PHONY:build-image
build-image: build-jar
Expand Down
22 changes: 19 additions & 3 deletions cicd/dagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func (v *VookServer) BuildApiJar(
dir *dagger.Directory,
// +optional
test bool,
// +optional
subModule string,
) (*dagger.File, error) {
c := dag.Java().
Init().
Expand All @@ -24,17 +26,31 @@ func (v *VookServer) BuildApiJar(
Container()

if test {
var testCommand []string
if subModule == "" {
testCommand = []string{"./gradlew", "test"}
} else {
testCommand = []string{"./gradlew", fmt.Sprintf(":%s:test", subModule)}
}

_, err := c.
With(dag.DockerService().WithCacheVolume("docker-var/lib/docker").BindAsService).
WithExec([]string{"./gradlew", "test"}).
WithExec(testCommand).
Sync(ctx)
if err != nil {
return nil, errors.New("test fail:" + err.Error())
}
}

var bootJarCommand []string
if subModule == "" {
bootJarCommand = []string{"./gradlew", "bootJar"}
} else {
bootJarCommand = []string{"./gradlew", fmt.Sprintf(":%s:bootJar", subModule)}
}

jarFile := c.
WithExec([]string{"./gradlew", "bootJar"}).
WithExec(bootJarCommand).
File("jar/api.jar")

return jarFile, nil
Expand Down Expand Up @@ -146,7 +162,7 @@ func (v *VookServer) Deploy(
version string,
command string,
) error {
jarFile, err := v.BuildApiJar(ctx, sourceDir, true)
jarFile, err := v.BuildApiJar(ctx, sourceDir, true, "api")
if err != nil {
return err
}
Expand Down
File renamed without changes.
34 changes: 0 additions & 34 deletions api/build.gradle → server/api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
}

ext {
springModulithVersion = "1.2.1"
}

group = 'vook.server'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
// spring
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
Expand Down Expand Up @@ -72,17 +47,8 @@ dependencies {
testImplementation 'org.testcontainers:mariadb'
}

bootJar {
destinationDirectory = file(rootDir.absolutePath + '/jar')
archiveFileName = "${project.name}.jar"
}

dependencyManagement {
imports {
mavenBom "org.springframework.modulith:spring-modulith-bom:$springModulithVersion"
}
}

tasks.named('test') {
useJUnitPlatform()
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DemoLogicTest extends IntegrationTestBase {
@BeforeAll
void beforeAll() {
List<DemoTerm> terms = testTermsLoader.getTerms(
"classpath:init/데모.tsv",
"classpath:init/demo.tsv",
InitService::convertToDemoTerm
);
demoTermRepository.saveAll(terms);
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 44423e2

Please sign in to comment.