-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9527e2e
commit 3627abb
Showing
94 changed files
with
193 additions
and
3,300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,45 @@ | ||
plugins { | ||
id 'com.diffplug.spotless' version '7.0.0.BETA1' | ||
id 'com.palantir.docker' version '0.36.0' | ||
id 'io.spring.dependency-management' version '1.1.5' | ||
id 'java' | ||
id 'org.springframework.boot' version '2.7.18' | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath("com.diffplug.spotless:spotless-plugin-gradle:${Version.SPOTLESS}") | ||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${Version.SPRING_BOOT}") | ||
} | ||
} | ||
|
||
def gitRev = { -> | ||
def stdout = new ByteArrayOutputStream() | ||
version = Git.commitHash() | ||
|
||
exec { | ||
commandLine 'git', 'rev-parse', 'HEAD' | ||
standardOutput = stdout | ||
} | ||
subprojects { Project project -> | ||
apply plugin: 'com.diffplug.spotless' | ||
apply plugin: 'io.spring.dependency-management' | ||
apply plugin: 'java' | ||
|
||
return stdout.toString().trim() | ||
} | ||
|
||
String appName = "api" | ||
String appVer = gitRev() | ||
|
||
group = "io.chucknorris" | ||
version = appVer | ||
java.sourceCompatibility = JavaVersion.VERSION_17 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
// versions | ||
def lombokVersion = "1.18.30" | ||
sourceCompatibility = 17 | ||
targetCompatibility = 17 | ||
version Git.commitHash() | ||
|
||
dependencies { | ||
annotationProcessor "org.projectlombok:lombok:${lombokVersion}" | ||
dependencyManagement { | ||
imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${Version.SPRING_BOOT}") } | ||
} | ||
|
||
implementation "com.amazonaws:aws-java-sdk:1.11.561" | ||
implementation "com.fasterxml.jackson.core:jackson-core:2.17.1" | ||
implementation "com.rometools:rome:1.12.0" | ||
implementation "com.vladmihalcea:hibernate-types-52:2.4.0" | ||
implementation "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.3.0" | ||
implementation "org.hibernate:hibernate-validator:6.0.16.Final" | ||
implementation "org.postgresql:postgresql:42.2.9" | ||
implementation "org.projectlombok:lombok:${lombokVersion}" | ||
implementation "org.springframework.boot:spring-boot-starter-data-jpa" | ||
implementation "org.springframework.boot:spring-boot-starter-thymeleaf" | ||
implementation "org.springframework.boot:spring-boot-starter-web" | ||
implementation 'com.google.guava:guava:33.2.1-jre' | ||
|
||
testImplementation "org.springframework.boot:spring-boot-starter-test" | ||
testImplementation 'junit:junit:4.12' | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
tasks { | ||
bootJar { | ||
manifest.attributes( | ||
'Multi-Release': 'true' | ||
) | ||
tasks.withType(Test) { | ||
useJUnitPlatform() | ||
|
||
archiveBaseName.set(appName) | ||
archiveVersion.set(appVer) | ||
testLogging { | ||
events TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED | ||
} | ||
} | ||
|
||
if (project.hasProperty("archiveName")) { | ||
archiveFileName.set(project.properties["archiveName"] as String) | ||
} | ||
} | ||
|
||
docker { | ||
dependsOn bootJar | ||
|
||
def imageName = "${project.properties.group}/${appName}" | ||
name = "${imageName}:latest" | ||
|
||
tag("current", "${imageName}:${appVer}") | ||
tag("latest", "${imageName}:latest") | ||
tag("herokuProduction", "registry.heroku.com/chucky/web") | ||
|
||
dockerfile file("${projectDir}/src/main/docker/Dockerfile") | ||
files tasks.bootJar.outputs | ||
buildArgs([JAR_FILE: bootJar.getArchiveFileName().get()]) | ||
} | ||
|
||
springBoot { | ||
buildInfo { | ||
properties { | ||
artifact = "${appName}-${appVer}.jar" | ||
version = appVer | ||
name = appName | ||
} | ||
} | ||
} | ||
|
||
spotless { | ||
java { | ||
googleJavaFormat() | ||
} | ||
} | ||
} | ||
spotless { | ||
java { | ||
googleJavaFormat() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import org.gradle.api.GradleException | ||
|
||
class Git { | ||
|
||
private static final VERSION_2 = "git version 2" | ||
|
||
static String branch() throws GradleException { | ||
def gitBranch = execute('git rev-parse --abbrev-ref HEAD') | ||
|
||
if (gitBranch == null || gitBranch.empty) { | ||
throw new GradleException('Could not determine Git branch name') | ||
} | ||
|
||
return gitBranch.replace("/", "-") | ||
} | ||
|
||
static int commitCount() { | ||
return execute('git rev-list --count HEAD').toInteger() | ||
} | ||
|
||
static int commitDateUnix() { | ||
return execute( | ||
"git show -s --format=%ct ${commitHash()}" | ||
).toInteger() | ||
} | ||
|
||
static String commitHash() { | ||
return execute('git rev-parse HEAD') | ||
} | ||
|
||
static String commitHashShort() { | ||
return execute('git rev-parse --short HEAD').substring(0, 7) | ||
} | ||
|
||
static String remoteOriginUrl() { | ||
return execute('git config --get remote.origin.url') | ||
} | ||
|
||
static void writePropertiesTo(pathname) { | ||
def properties = new Properties() | ||
|
||
properties.setProperty('git.branch', branch()) | ||
properties.setProperty('git.commit_count', commitCount().toString()) | ||
properties.setProperty('git.commit_date_unix', commitDateUnix().toString()) | ||
properties.setProperty('git.commit_long', commitHash()) | ||
properties.setProperty('git.commit_short', commitHashShort()) | ||
properties.setProperty('git.remote_origin_url', remoteOriginUrl()) | ||
|
||
def file = new File(pathname) | ||
if (!file.getParentFile().exists()) { | ||
file.getParentFile().mkdirs() | ||
} | ||
|
||
file.withWriter('UTF-8') { | ||
properties.each { key, value -> it.writeLine("$key = $value") } | ||
} | ||
} | ||
|
||
static boolean isAvailable() { | ||
try { | ||
return execute("git --version").startsWith(VERSION_2) | ||
} catch (ignored) { | ||
return false | ||
} | ||
} | ||
|
||
private static String execute(String command) { | ||
return command.execute().in.text.trim() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface Version { | ||
public static final String SPRING_BOOT = '2.7.18' | ||
public static final String SPOTLESS = '7.0.0.BETA1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
plugins { | ||
id "com.palantir.docker" version "0.36.0" | ||
id 'org.springframework.boot' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
// versions | ||
def lombokVersion = "1.18.30" | ||
|
||
dependencies { | ||
annotationProcessor "org.projectlombok:lombok:${lombokVersion}" | ||
|
||
implementation "com.amazonaws:aws-java-sdk:1.11.561" | ||
implementation "com.fasterxml.jackson.core:jackson-core:2.17.1" | ||
implementation "com.rometools:rome:1.12.0" | ||
implementation "com.vladmihalcea:hibernate-types-52:2.4.0" | ||
implementation "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.3.0" | ||
implementation "org.hibernate:hibernate-validator:6.0.16.Final" | ||
implementation "org.postgresql:postgresql:42.2.9" | ||
implementation "org.projectlombok:lombok:${lombokVersion}" | ||
implementation "org.springframework.boot:spring-boot-starter-data-jpa" | ||
implementation "org.springframework.boot:spring-boot-starter-thymeleaf" | ||
implementation "org.springframework.boot:spring-boot-starter-web" | ||
implementation "com.google.guava:guava:33.2.1-jre" | ||
|
||
testImplementation "org.springframework.boot:spring-boot-starter-test" | ||
testImplementation "junit:junit:4.12" | ||
} | ||
|
||
tasks { | ||
bootJar { | ||
manifest.attributes("Multi-Release": "true") | ||
|
||
archiveBaseName.set(project.name) | ||
archiveVersion.set(project.version) | ||
|
||
if (project.hasProperty("archiveName")) { | ||
archiveFileName.set(project.properties["archiveName"] as String) | ||
} | ||
} | ||
|
||
docker { | ||
dependsOn bootJar | ||
|
||
def imageName = "${project.properties.group}/${project.name}" | ||
name = "${imageName}:latest" | ||
|
||
tag("current", "${imageName}:${project.version}") | ||
tag("latest", "${imageName}:latest") | ||
tag("herokuProduction", "registry.heroku.com/chucky/web") | ||
|
||
dockerfile file("${projectDir}/src/main/docker/Dockerfile") | ||
files tasks.bootJar.outputs | ||
buildArgs([JAR_FILE: bootJar.getArchiveFileName().get()]) | ||
} | ||
|
||
springBoot { | ||
buildInfo { | ||
properties { | ||
artifact = "${project.name}-${project.version}.jar" | ||
version = project.version | ||
name = project.name | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.