Archived
0
This repository has been archived on 2022-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
mc-server/build.gradle
DmitriyMX 64bac19696 Merge remote-tracking branch 'event' into world-loader-anvil
# Conflicts:
#	core/src/main/java/mc/core/CoreEventListener.java
2019-01-12 22:11:44 +03:00

161 lines
5.3 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import java.nio.file.Files
import java.nio.file.Paths
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath (group: 'org.sonarsource.scanner.gradle', name: 'sonarqube-gradle-plugin', version: '2.6.2')
}
}
/**
* Проверка кода в SonarQube.
* Для запуска локальной проверки кода, используются следующий command line:
* gradle sonarqube \
* -Dsonar.host.url=http://127.0.0.1:9000
* -Dsonar.login=<TOKEN>
* где
* - <TOKEN> - сгенерированный токен учетки "сонара"
*/
plugins {
id "org.sonarqube" version "2.6.2"
}
allprojects {
apply plugin: 'java'
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/groups/public/' }
}
}
subprojects {
group 'mc'
ext {
slf4j_version = '1.7.25'
spring_version = '5.1.0.RELEASE'
lombok_version = '1.18.4'
junit_version = '5.3.1'
}
configurations {
compile_excludeCopy
compile.extendsFrom compile_excludeCopy
}
dependencies {
/* Logger */
compile (group: 'org.slf4j', name: 'slf4j-api', version: slf4j_version)
compile (group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4j_version)
/* Spring */
compile (group: 'org.springframework', name: 'spring-context', version: spring_version)
/* Lombok */
annotationProcessor (group: 'org.projectlombok', name: 'lombok', version: lombok_version)
compile (group: 'org.projectlombok', name: 'lombok', version: lombok_version)
testAnnotationProcessor (group: 'org.projectlombok', name: 'lombok', version: lombok_version)
testCompile (group: 'org.projectlombok', name: 'lombok', version: lombok_version)
/* Testing */
testImplementation (group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junit_version)
testRuntimeOnly(group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junit_version)
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: junit_version)
testCompile (group: 'org.slf4j', name: 'slf4j-simple', version: slf4j_version)
testCompile (group: 'org.mockito', name: 'mockito-core', version: '1.10.19')
testCompile (group: 'org.springframework', name: 'spring-test', version: spring_version)
}
test {
useJUnitPlatform()
}
task copyDep(type: Copy) {
into 'libs'
from configurations.compile + configurations.runtime - configurations.compile_excludeCopy
}
task cleanDep(type: Delete) {
delete 'libs'
}
/**
* Сборка
*/
task deploy() {
dependsOn { jar }
doLast {
def deployDir = System.getProperty("deploy")
if (deployDir == null) {
println "Need param -Ddeploy=path/to/deploy"
throw new Exception("Need param -Ddir=path/to/deploy")
}
def target = Paths.get(deployDir, jar.archivePath.getName())
if (Files.notExists(target)) {
println jar.archivePath
Files.copy(jar.archivePath.toPath(), target)
}
def libsDir = System.getProperty("libs", deployDir+File.separator+"libs")
if (Files.notExists(Paths.get(libsDir))) {
(new File(libsDir)).mkdirs()
}
def libsCollection = configurations.compile + configurations.runtime - configurations.compile_excludeCopy
libsCollection.each{ libFile ->
target = Paths.get(libsDir, libFile.getName())
if (Files.notExists(target)) {
println libFile
Files.copy(libFile.toPath(), target)
}
}
}
}
}
/**
* Запуск сервера.
* Для указания рабочей папки, указываем JVM параметр
* -DworkDir=path\to\workdir
* Если используется отдельная папка для имплементации логгера, то указываем
* -DlogImplDir=path\to\logimpldir
* Если необходимо передать дополнительные JVM параметры серверу, то указываем их с двойной "D", например:
* -DDspringConfig=spring.xml
* -DDlog4j.configurationFile=log4j2.xml
*/
task runServer(type: JavaExec) {
main = 'mc.core.Main'
workingDir = System.getProperty("workDir", ".")
subprojects.findAll().each{ prj ->
classpath += prj.sourceSets.main.runtimeClasspath
}
if (System.getProperty("logImplDir") != null) {
classpath += files(fileTree(dir: new File(System.getProperty("logImplDir"))))
} else {
classpath += files(fileTree(dir: new File(workingDir, "log-impl")))
}
System.getProperties().stringPropertyNames().stream()
.filter{propName -> propName.startsWith("D")}
.forEach{propName -> jvmArgs += "-D" + propName.substring(1) + "=" + System.getProperty(propName)}
ignoreExitValue = true
}