Initial commit

This commit is contained in:
CUBETIQ Solution 2021-12-20 17:26:07 +07:00
commit c72ee8968f
48 changed files with 1014 additions and 0 deletions

13
.drone.yml Normal file
View File

@ -0,0 +1,13 @@
kind: pipeline
type: docker
name: ci
steps:
- name: submodules
image: d.ctdn.net/alpine/git
commands:
- git submodule update --init --recursive
- name: test
image: d.ctdn.net/cubetiq/openjdk:11u-ubuntu
commands:
- apt-get update && apt-get install git -y
- sh gradlew bootJar

38
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

39
.gitignore vendored Normal file
View File

@ -0,0 +1,39 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
.DS_Store

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM cubetiq/calpine-openjdk11:latest
LABEL maintainer="sombochea@cubetiqs.com"
# Working directory for application
WORKDIR /opt/cubetiq
# Define mount volumn for data path
VOLUME ["/opt/cubetiq/data"]
# Copy build source to container
COPY api/build/libs/*.jar ./api.jar
ENV APP_DATA_DIR "/opt/cubetiq/data"
# Entrypoint to app
CMD ["java","-jar", "./api.jar"]

16
README.md Normal file
View File

@ -0,0 +1,16 @@
# CUBETIQ Web Modules (Template)
- Setup and Default Web Configuration
- Swagger UI and API's Documentation (SpringFox)
- General Purpose for External and Internal use-cases
- Dockerfile and Docker profile build support
# Modules
- API (Default Module)
# Contributors
- Sambo Chea <sombochea@cubetiqs.com>
### Language and Framework
- Spring Boot: 2.5.7
- Kotlin: 1.6.0
- Gradle: 7.3.1

37
api/.gitignore vendored Normal file
View File

@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/

52
api/build.gradle.kts Normal file
View File

@ -0,0 +1,52 @@
import java.io.ByteArrayOutputStream
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("jvm")
kotlin("plugin.spring")
}
val kotlinVersion = "1.6.0"
val springBootVersion = "2.5.7"
// find the last commit
fun getGitHashLastCommit(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}
springBoot {
buildInfo {
properties {
additional["commitId"] = getGitHashLastCommit()
additional["springBootVersion"] = springBootVersion
additional["kotlinVersion"] = kotlinVersion
}
}
}
dependencies {
// Migrating from SpringFox
implementation("org.springdoc:springdoc-openapi-ui:1.5.13")
// SPRING FRAMEWORK AND CORE
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
// Development Runtime
developmentOnly("org.springframework.boot:spring-boot-devtools")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}

View File

@ -0,0 +1,11 @@
package com.cubetiqs.web
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class ApiApplication
fun main(args: Array<String>) {
runApplication<ApiApplication>(*args)
}

View File

@ -0,0 +1,12 @@
package com.cubetiqs.web
import com.cubetiqs.web.stereotype.FunctionComponent
import org.springframework.context.annotation.Lazy
@FunctionComponent
@Lazy(false)
class StaticContextInitializer {
init {
println("Static context is loaded...!")
}
}

View File

@ -0,0 +1,8 @@
package com.cubetiqs.web.annotation
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.security.SecurityRequirement
@Retention(AnnotationRetention.RUNTIME)
@Operation(security = [SecurityRequirement(name = "bearerAuth")])
annotation class ApiBearerAuth()

View File

@ -0,0 +1,6 @@
package com.cubetiqs.web.config
import org.springframework.context.annotation.Configuration
@Configuration
class DefaultConfig

View File

@ -0,0 +1,57 @@
package com.cubetiqs.web.config
import com.cubetiqs.web.property.AppProperties
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType
import io.swagger.v3.oas.annotations.security.SecurityScheme
import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.info.Info
import io.swagger.v3.oas.models.info.License
import org.springdoc.core.GroupedOpenApi
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
@SecurityScheme(
name = "bearerAuth",
type = SecuritySchemeType.HTTP,
scheme = "bearer",
bearerFormat = "JWT",
)
class OpenApiDocConfig @Autowired constructor(
val appProperties: AppProperties,
) {
companion object {
private val ADMIN_API_PATH get() = "/admin/**"
private val DEFAULT_API_PATH get() = "/**"
}
@Bean
fun defaultApi(): GroupedOpenApi {
return GroupedOpenApi.builder()
.group("default")
.pathsToMatch(DEFAULT_API_PATH)
.pathsToExclude("/error", ADMIN_API_PATH)
.packagesToScan("com.cubetiqs.web")
.build()
}
@Bean
fun adminApi(): GroupedOpenApi {
return GroupedOpenApi.builder()
.group("admin")
.pathsToMatch(ADMIN_API_PATH)
.build()
}
@Bean
fun cubetiqOpenAPI(): OpenAPI {
return OpenAPI()
.info(
Info().title(appProperties.appName)
.description(appProperties.appDescription)
.version(appProperties.appVersion)
.license(License().name("Apache 2.0").url(appProperties.appLicenseUrl))
)
}
}

View File

@ -0,0 +1,15 @@
package com.cubetiqs.web.controller
import io.swagger.v3.oas.annotations.Hidden
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.servlet.view.RedirectView
@Hidden
@Controller
class ApiDoc {
@GetMapping(value = [ "/api-doc", "/api-docs"])
fun redirect(): RedirectView {
return RedirectView("/swagger-ui/")
}
}

View File

@ -0,0 +1,13 @@
package com.cubetiqs.web.controller
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
interface BaseController {
fun <T> response(
data: T?,
status: HttpStatus = HttpStatus.OK,
): ResponseEntity<T?> {
return ResponseEntity.status(status).body(data)
}
}

View File

@ -0,0 +1,47 @@
package com.cubetiqs.web.controller
import com.cubetiqs.web.model.response.ApiInfoAuthorResponse
import com.cubetiqs.web.model.response.ApiInfoResponse
import com.cubetiqs.web.model.response.HealthResponse
import com.cubetiqs.web.util.RouteConstants
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.info.BuildProperties
import org.springframework.core.env.Environment
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@Tag(name = "Miscellaneous")
@RestController
@RequestMapping(RouteConstants.INDEX)
class IndexController @Autowired constructor(
private val buildProperties: BuildProperties,
private val environment: Environment,
) : BaseController {
@GetMapping
fun index(): ResponseEntity<ApiInfoResponse?> {
val authors = listOf(
ApiInfoAuthorResponse(name = "Sambo Chea", email = "sombochea@cubetiqs.com"),
ApiInfoAuthorResponse(name = "CUBETIQ OSS", email = "oss@cubetiqs.com"),
)
val response = ApiInfoResponse(
info = "API Operation is running normally on ${environment.activeProfiles.joinToString(separator = ",")}",
name = buildProperties.name,
service = buildProperties.artifact,
version = buildProperties.version,
date = buildProperties.time.toString(),
commit = buildProperties["commitId"],
authors = authors,
)
return response(response)
}
@GetMapping("/health")
fun health(): ResponseEntity<HealthResponse?> {
return response(
HealthResponse.UP
)
}
}

View File

@ -0,0 +1,20 @@
package com.cubetiqs.web.controller.admin
import com.cubetiqs.web.annotation.ApiBearerAuth
import com.cubetiqs.web.controller.BaseController
import com.cubetiqs.web.util.RouteConstants
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@Tag(name = "Admin")
@RestController
@RequestMapping(RouteConstants.ADMIN)
class AdminController : BaseController {
@ApiBearerAuth
@GetMapping
fun getAdmin(): String {
return "Admin"
}
}

View File

@ -0,0 +1,14 @@
package com.cubetiqs.web.exception
open class BaseException : RuntimeException {
constructor() : super()
constructor(message: String?) : super(message)
constructor(message: String?, cause: Throwable?) : super(message, cause)
constructor(cause: Throwable?) : super(cause)
constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
message,
cause,
enableSuppression,
writableStackTrace
)
}

View File

@ -0,0 +1,5 @@
package com.cubetiqs.web.infrastructure.component
interface BaseFunctionComponent<I, O> {
fun execute(input: I?): O?
}

View File

@ -0,0 +1,7 @@
package com.cubetiqs.web.infrastructure.data
import java.io.Serializable
interface BaseEntity <ID : Serializable> : Serializable {
fun setId(id: ID)
}

View File

@ -0,0 +1,5 @@
package com.cubetiqs.web.infrastructure.event
import java.io.Serializable
interface BaseEvent : Serializable

View File

@ -0,0 +1,9 @@
package com.cubetiqs.web.infrastructure.listener
import com.cubetiqs.web.infrastructure.event.BaseEvent
interface BaseEventListener {
fun persist(event: BaseEvent) {
return
}
}

View File

@ -0,0 +1,3 @@
package com.cubetiqs.web.infrastructure.repository
interface BaseRepository

View File

@ -0,0 +1,3 @@
package com.cubetiqs.web.infrastructure.service
interface BaseService

View File

@ -0,0 +1,5 @@
package com.cubetiqs.web.model.ob
import java.io.Serializable
interface BaseOb : Serializable

View File

@ -0,0 +1,5 @@
package com.cubetiqs.web.model.request
import com.cubetiqs.web.model.ob.BaseOb
interface BaseResponseModel : BaseOb

View File

@ -0,0 +1,20 @@
package com.cubetiqs.web.model.response
import io.swagger.v3.oas.annotations.media.Schema
@Schema(name = "ApiInfoResponse", description = "ApiInfoResponse")
data class ApiInfoResponse(
val name: String,
val info: String,
val service: String,
val version: String,
val date: String,
val commit: String,
val authors: Collection<ApiInfoAuthorResponse> = listOf(),
) : BaseRequestModel
@Schema(name = "ApiInfoAuthorResponse", description = "ApiInfoAuthorResponse")
data class ApiInfoAuthorResponse(
val name: String,
val email: String,
) : BaseRequestModel

View File

@ -0,0 +1,5 @@
package com.cubetiqs.web.model.response
import com.cubetiqs.web.model.ob.BaseOb
interface BaseRequestModel : BaseOb

View File

@ -0,0 +1,16 @@
package com.cubetiqs.web.model.response
import io.swagger.v3.oas.annotations.media.Schema
@Schema(name = "HealthResponse", description = "HealthResponse")
data class HealthResponse(
@Schema(name = "status", description = "Status for the service")
val status: String,
) : BaseRequestModel {
companion object {
private const val STATUS_UP = "UP"
private const val STATUS_DOWN = "DOWN"
val UP get() = HealthResponse(STATUS_UP)
val DOWN get() = HealthResponse(STATUS_DOWN)
}
}

View File

@ -0,0 +1,5 @@
package com.cubetiqs.web.modules
interface AppModule {
fun getModule(): Class<*>
}

View File

@ -0,0 +1,19 @@
package com.cubetiqs.web.property
import com.cubetiqs.web.stereotype.FunctionComponent
import org.springframework.beans.factory.annotation.Value
@FunctionComponent
class AppProperties(
@Value("\${cubetiq.app.name:CUBETIQ Web API}")
val appName: String,
@Value("\${cubetiq.app.description:CUBETIQ Web APIs Documentation}")
val appDescription: String,
@Value("\${cubetiq.app.version:v0.0.1}")
val appVersion: String,
@Value("\${cubetiq.app.license-url:https://cubetiqs.com}")
val appLicenseUrl: String,
)

View File

@ -0,0 +1,20 @@
package com.cubetiqs.web.stereotype
import org.springframework.context.annotation.Lazy
import org.springframework.core.annotation.AliasFor
import org.springframework.stereotype.Component
/**
* @author sombochea <Sambo Chea>
* @email sombochea@cubetiqs.com
* @date 18/05/21
* @since 1.0
*/
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS)
@Lazy(value = true)
@Component
annotation class FunctionComponent(
@get: AliasFor(annotation = Component::class)
val value: String = ""
)

View File

@ -0,0 +1,10 @@
package com.cubetiqs.web.util
object RouteConstants {
const val INDEX = "/"
const val ADMIN = "/admin"
}
object AppConstants {
val BASE_PACKAGE_API_DOCS get() = "com.cubetiqs.web"
}

View File

@ -0,0 +1,2 @@
server:
port: 8080

View File

@ -0,0 +1,22 @@
spring:
profiles:
active: ${APP_PROFILE:dev}
application:
name: cubetiq-api-service
cubetiq:
app:
data-dir: ${APP_DATA_DIR:${user.home}/${spring.application.name}}
name: CUBETIQ Web API
description: CUBETIQ Spring Web API's Documentation
logging:
file:
path: ${LOGGING_FILE_PATH:${cubetiq.app.data-dir}/logs/}
name: ${logging.file.path}/app.log
springdoc:
api-docs:
enabled: true
swagger-ui:
path: /swagger-ui

View File

@ -0,0 +1,13 @@
package com.cubetiqs.web
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
@SpringBootTest
class ApiApplicationTests {
@Test
fun contextLoads() {
}
}

2
apps/demo/.env Normal file
View File

@ -0,0 +1,2 @@
APP_PROFILE=demo
APP_DATA_DIR=/opt/cubetiq/data

View File

@ -0,0 +1,2 @@
server:
port: ${APP_PORT:8090}

22
apps/demo/build.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# Get Execute Script Directory
SCRIPT_DIR=$(dirname "$0")
# shellcheck disable=SC2039
source "$SCRIPT_DIR"/variable.sh
echo "===> Clean Gradle Build <==="
bash gradlew clean
echo "===> Moving App File <==="
bash "$SCRIPT_DIR"/move-file.sh
echo "===> Gradle Building Application <==="
bash gradlew build -x test
echo "===> Docker Building Image <==="
docker build . -t "$ROOT_HUB"
echo "===> Docker Pushing Image <==="
docker push "$ROOT_HUB"

10
apps/demo/move-file.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# Get Execute Script Directory
SCRIPT_DIR=$(dirname "$0")
source "$SCRIPT_DIR"/variable.sh
echo "===> Copy & Replace Application Profile <==="
rm -rf "$APP_MODULE_PATH"/src/main/resources/application-dev.yml
cp -f "$SCRIPT_DIR"/application-"$APP_PROFILE".yml "$APP_MODULE_PATH"/src/main/resources/

26
apps/demo/run.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# Get Execute Script Directory
SCRIPT_DIR=$(dirname "$0")
# shellcheck disable=SC2039
source "$SCRIPT_DIR"/variable.sh
CONTAINER_NAME="$CONTAINER"
APP_DATA_DIR=$(passwd)/"$CONTAINER_NAME"
echo "===> Docker Pulling New Image <==="
docker pull "$ROOT_HUB"
echo "===> Docker Removing Container <==="
docker rm -f "$CONTAINER_NAME"
echo "===> Docker Run Container: $CONTAINER_NAME <==="
docker run -d \
-p "$EXPOSE_PORT":8090 \
--env-file "$SCRIPT_DIR"/.env \
-e HIBERNATE_DDL="${HIBERNATE_DDL:-update}" \
-v "$APP_DATA_DIR"/data:/opt/cubetiq/data \
--restart=always \
--name "$CONTAINER_NAME" \
"$ROOT_HUB"

11
apps/demo/variable.sh Normal file
View File

@ -0,0 +1,11 @@
# Build variables
APP_MODULE_PATH=api
APP_PROFILE=demo
# Docker Image variables
VERSION=latest
IMAGE=api-demo
CONTAINER=$IMAGE
REGISTRY=registry.kh.cubetiqs.com
EXPOSE_PORT=8080
ROOT_HUB=$REGISTRY/$IMAGE:$VERSION

49
build.gradle.kts Normal file
View File

@ -0,0 +1,49 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.6.1" apply false
id("io.spring.dependency-management") version "1.0.11.RELEASE" apply false
kotlin("jvm") version "1.6.0" apply false
kotlin("plugin.spring") version "1.6.0" apply false
// kotlin("plugin.jpa") version "1.6.0" apply false
}
allprojects {
// Fixed Zero-Day CVE-2021-44228: https://cubetiq.atlassian.net/browse/CERT-1
// Fixed Zero-Day CVE-2021-45046: https://cubetiq.atlassian.net/browse/CERT-3
// Fixed Zero-Day CVE-2021-45105: https://cubetiq.atlassian.net/browse/CERT-4
ext["log4j2.version"] = "2.17.0"
repositories {
maven("https://m.ctdn.net")
}
group = "com.cubetiqs"
version = "0.0.1-SNAPSHOT"
val javaVersion = "11"
tasks.withType<JavaCompile> {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = javaVersion
}
}
}
subprojects {
apply {
plugin("io.spring.dependency-management")
}
the<io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension>().apply {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://mirror.ctdn.net/gradle/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
gradlew vendored Executable file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

5
settings.gradle.kts Normal file
View File

@ -0,0 +1,5 @@
rootProject.name = "spring-web-modules"
include(
"api"
)