-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
10 changed files
with
145 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
title=MSA BP Base | ||
description=This module declares and defines core functionality microservices |
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 |
---|---|---|
|
@@ -13,9 +13,10 @@ plugins { | |
} | ||
val jacocoHtml: String? by project | ||
val semanticVersion: String by project | ||
val buildHash: String by project | ||
|
||
allprojects { | ||
group = "io.github.zero88" | ||
group = "io.github.zero88.msa.bp" | ||
|
||
repositories { | ||
mavenLocal() | ||
|
@@ -34,6 +35,10 @@ subprojects { | |
apply(plugin = "signing") | ||
apply(plugin = "maven-publish") | ||
project.version = "$version$semanticVersion" | ||
project.group = ProjectUtils.computeGroup(project) | ||
project.ext.set("title", findProperty("title") ?: project.name) | ||
project.ext.set("baseName", ProjectUtils.computeBaseName(project)) | ||
project.ext.set("description", findProperty("description") ?: "A Vertx framework for microservice: ${project.name}") | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
|
@@ -54,9 +59,19 @@ subprojects { | |
|
||
tasks { | ||
jar { | ||
doFirst { | ||
println("- Project Name: ${project.ext.get("baseName")}") | ||
println("- Project Title: ${project.ext.get("title")}") | ||
println("- Project Group: ${project.group}") | ||
println("- Project Artifact: ${project.name}") | ||
println("- Project Version: ${project.version}") | ||
} | ||
|
||
archiveBaseName.set(project.ext.get("baseName") as String) | ||
manifest { | ||
attributes( | ||
mapOf(Name.IMPLEMENTATION_TITLE.toString() to project.name, | ||
mapOf(Name.MANIFEST_VERSION.toString() to "1.0", | ||
Name.IMPLEMENTATION_TITLE.toString() to archiveBaseName, | ||
Name.IMPLEMENTATION_VERSION.toString() to project.version, | ||
"Created-By" to GradleVersion.current(), | ||
"Build-Jdk" to Jvm.current(), | ||
|
@@ -67,6 +82,7 @@ subprojects { | |
} | ||
} | ||
javadoc { | ||
title = "${project.ext.get("title")} ${project.version} API" | ||
options { | ||
this as StandardJavadocDocletOptions | ||
tags = mutableListOf("apiNote:a:API Note:", "implSpec:a:Implementation Requirements:", | ||
|
@@ -76,6 +92,10 @@ subprojects { | |
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
withType<Sign>().configureEach { | ||
onlyIf { project.hasProperty("release") } | ||
} | ||
} | ||
|
||
publishing { | ||
|
@@ -96,12 +116,12 @@ subprojects { | |
} | ||
pom { | ||
name.set(project.name) | ||
description.set("A Vertx framework for microservice") | ||
url.set("https://github.com/zero88/blueprint") | ||
description.set(project.ext.get("description") as String) | ||
url.set("https://github.com/zero88/msa-blueprint") | ||
licenses { | ||
license { | ||
name.set("The Apache License, Version 2.0") | ||
url.set("https://github.com/zero88/blueprint/blob/master/LICENSE") | ||
url.set("https://github.com/zero88/msa-blueprint/blob/master/LICENSE") | ||
} | ||
} | ||
developers { | ||
|
@@ -111,9 +131,9 @@ subprojects { | |
} | ||
} | ||
scm { | ||
connection.set("scm:git:git://[email protected]:zero88/blueprint.git") | ||
developerConnection.set("scm:git:ssh://[email protected]:zero88/blueprint.git") | ||
url.set("https://github.com/zero88/blueprint") | ||
connection.set("scm:git:git://[email protected]:zero88/msa-blueprint.git") | ||
developerConnection.set("scm:git:ssh://[email protected]:zero88/msa-blueprint.git") | ||
url.set("https://github.com/zero88/msa-blueprint") | ||
} | ||
} | ||
} | ||
|
@@ -170,10 +190,6 @@ sonarqube { | |
} | ||
} | ||
|
||
tasks.withType<Sign>().configureEach { | ||
onlyIf { project.hasProperty("release") } | ||
} | ||
|
||
task<Sign>("sign") { | ||
dependsOn(subprojects.map { it.tasks.withType<Sign>() }) | ||
} | ||
|
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,54 @@ | ||
import org.gradle.api.Project | ||
|
||
class ProjectUtils { | ||
|
||
static boolean isSubProject(Project project, String projectName) { | ||
if (project.parent == null) { | ||
return project.name == projectName | ||
} | ||
return project.parent.name == projectName || isSubProject(project.parent, projectName) | ||
} | ||
|
||
static String computeGroup(Project project) { | ||
if (project.parent == null) { | ||
return project.group | ||
} | ||
def suffix = project.parent == project.rootProject ? "" : ("." + project.parent.name) | ||
return computeGroup(project.parent) + suffix | ||
} | ||
|
||
static String computeBaseName(Project project) { | ||
return computeProjectName(project, "-") | ||
} | ||
|
||
static String computeDockerName(Project project) { | ||
return computeProjectName(project, "-", "/") | ||
} | ||
|
||
def static loadSecretProps(Project project, secretFile) { | ||
def sf = new File(secretFile.toString()) | ||
if (sf.exists()) { | ||
def props = new Properties() | ||
sf.withInputStream { props.load(it) } | ||
props.findAll { Strings.isBlank(extraProp(project, it.key.toString())) } | ||
.each { k, v -> project.ext.set(k, v) } | ||
} | ||
} | ||
|
||
static String extraProp(Project project, String key) { | ||
return extraProp(project, key, null) | ||
} | ||
|
||
static String extraProp(Project project, String key, String fallback) { | ||
return project.ext.has(key) && !Strings.isBlank((String) project.ext.get(key)) ? (String) project.ext.get(key) : | ||
fallback | ||
} | ||
|
||
private static String computeProjectName(Project project, String sep, String firstSep = null) { | ||
if (project.parent == null) { | ||
return extraProp(project, "baseName", project.name) | ||
} | ||
final def s = project.parent.parent == null && firstSep ? firstSep : sep | ||
return computeProjectName(project.parent, sep, firstSep) + s + project.name | ||
} | ||
} |
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,39 @@ | ||
|
||
|
||
class Strings { | ||
|
||
static boolean isBlank(String text) { | ||
return text == null || "" == text.trim() | ||
} | ||
|
||
static String requireNotBlank(String text) { | ||
return requireNotBlank(text, "Not blank") | ||
} | ||
|
||
static String requireNotBlank(String text, String message) { | ||
if (isBlank(text)) { | ||
throw new IllegalArgumentException(message) | ||
} | ||
return text.trim() | ||
} | ||
|
||
static String toSnakeCase(String text, boolean upper = true) { | ||
if (upper && text == text.toUpperCase()) { | ||
return text | ||
} | ||
if (!upper && text == text.toLowerCase()) { | ||
return text | ||
} | ||
def regex = upper ? "A-Z" : "a-z" | ||
def t = text.replaceAll(/([$regex])/, /_$1/).replaceAll(/^_/, '') | ||
return upper ? t.toUpperCase() : t.toLowerCase() | ||
} | ||
|
||
static String replaceJsonSuffix(String name) { | ||
return name.replaceAll(toRegexIgnoreCase("_JSON(_ARRAY)?|_ARRAY\$"), "") | ||
} | ||
|
||
static String toRegexIgnoreCase(String name) { | ||
return "(?i:${name})" | ||
} | ||
} |
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,2 @@ | ||
title=MSA BP Cache | ||
description=This module declares and defines microservice cache |
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,2 @@ | ||
title=MSA BP HTTP Client | ||
description=This module declares and defines microservice HTTP Client |
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,2 @@ | ||
title=MSA BP HTTP | ||
description=This module declares and defines microservice base HTTP functional |
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,2 @@ | ||
title=MSA BP HTTP Server | ||
description=This module declares and defines microservice HTTP server |
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,2 @@ | ||
title=MSA BP Micro | ||
description=This module declares and defines microservice service discovery |