Skip to content

Commit

Permalink
Merge pull request #2 from zero88/release/0.5.1
Browse files Browse the repository at this point in the history
Fix build to correct maven group
  • Loading branch information
zero88 authored Dec 16, 2020
2 parents c64c23e + 070e21e commit c25fd81
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 13 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@

A Vertx framework for microservice

![build](https://github.com/zero88/msa-blueprint/workflows/build/badge.svg?branch=master)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/zero88/msa-blueprint?sort=semver)
![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/io.github.zero88/msa-blueprint?server=https%3A%2F%2Foss.sonatype.org%2F)
![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.zero88/msa-blueprint?server=https%3A%2F%2Foss.sonatype.org%2F)

[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=security_rating)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=coverage)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)


## Overview
2 changes: 2 additions & 0 deletions base/gradle.properties
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
40 changes: 28 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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(),
Expand All @@ -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:",
Expand All @@ -76,6 +92,10 @@ subprojects {
test {
useJUnitPlatform()
}

withType<Sign>().configureEach {
onlyIf { project.hasProperty("release") }
}
}

publishing {
Expand All @@ -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 {
Expand All @@ -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")
}
}
}
Expand Down Expand Up @@ -170,10 +190,6 @@ sonarqube {
}
}

tasks.withType<Sign>().configureEach {
onlyIf { project.hasProperty("release") }
}

task<Sign>("sign") {
dependsOn(subprojects.map { it.tasks.withType<Sign>() })
}
Expand Down
54 changes: 54 additions & 0 deletions buildSrc/src/main/groovy/ProjectUtils.groovy
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
}
}
39 changes: 39 additions & 0 deletions buildSrc/src/main/groovy/Strings.groovy
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})"
}
}
2 changes: 2 additions & 0 deletions cache/gradle.properties
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.parallel=true

# Project properties --------------------------
version=0.5.1
semanticVersion=-SNAPSHOT
semanticVersion=
buildBy=local
buildHash=

Expand Down
2 changes: 2 additions & 0 deletions http/client/gradle.properties
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
2 changes: 2 additions & 0 deletions http/gradle.properties
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
2 changes: 2 additions & 0 deletions http/server/gradle.properties
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
2 changes: 2 additions & 0 deletions micro/gradle.properties
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

0 comments on commit c25fd81

Please sign in to comment.