Archived
0

Merge branch 'gradle/split-project' into develop

This commit is contained in:
2021-04-26 15:29:44 +03:00
41 changed files with 129 additions and 154 deletions

View File

@@ -6,4 +6,12 @@
---
* Java 11
* Java 11
---
## Запуск
```shell
gradle :server:run
```

View File

@@ -1,61 +0,0 @@
/*
Запуск
gradle run
*/
import ru.dmitriymx.gradle.plugin.LibsPlugin
import ru.dmitriymx.gradle.plugin.LogicPlugin
plugins {
id 'java'
id 'application'
}
apply plugin: LibsPlugin
apply plugin: LogicPlugin
project.group = logic.getProperty1('project.group')
project.version = logic.getProperty1('project.version')
jar.archiveBaseName.set(logic.getProperty1('project.name'))
compileJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
options.encoding = 'UTF-8'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
annotationProcessor libs.lombok
compileOnly libs.lombok
compileOnly libs.annotations
implementation libs.logger.slf4j
implementation libs.logger.logback
implementation libs.dagger2.implementation
annotationProcessor libs.dagger2.annotationProcessor
implementation platform('io.projectreactor:reactor-bom:2020.0.6')
implementation 'io.projectreactor:reactor-core'
implementation 'io.netty:netty-all:4.1.22.Final'
implementation libs.guava
testImplementation libs.junit5.api
testImplementation libs.junit5.params
testRuntimeOnly libs.junit5.engine
testImplementation libs.lang3
}
application {
mainClassName = 'mc.server.Main'
}
test {
useJUnitPlatform()
}

View File

@@ -1,46 +0,0 @@
package ru.dmitriymx.gradle.extention;
import java.util.List;
public class LibsExtention {
public final String lombok = "org.projectlombok:lombok:1.18.12";
public final String annotations = "com.google.code.findbugs:jsr305:3.0.2";
public final String guava = "com.google.guava:guava:30.1-jre";
public final String lang3 = "org.apache.commons:commons-lang3:3.11";
public final LoggerLibs logger = new LoggerLibs();
public final Dagger2Libs dagger2 = new Dagger2Libs();
public final Junit5Libs junit5 = new Junit5Libs();
public static final class LoggerLibs {
private final String slf4j_version = "1.7.30";
private final String logback_version = "1.2.3";
public final List<String> slf4j = List.of(
"org.slf4j:slf4j-api:" + slf4j_version,
"org.slf4j:jcl-over-slf4j:" + slf4j_version
);
public final List<String> logback = List.of(
"ch.qos.logback:logback-core:" + logback_version,
"ch.qos.logback:logback-classic:" + logback_version
);
}
public static final class Dagger2Libs {
private final String dagger2_version = "2.33";
public final String implementation = "com.google.dagger:dagger:" + dagger2_version;
public final String annotationProcessor = "com.google.dagger:dagger-compiler:" + dagger2_version;
}
public static final class Junit5Libs {
private final String junit_version = "5.5.2";
public final String api = "org.junit.jupiter:junit-jupiter-api:" + junit_version;
/** runtimeOnly */
public final String engine = "org.junit.jupiter:junit-jupiter-engine:" + junit_version;
public final String params = "org.junit.jupiter:junit-jupiter-params:" + junit_version;
}
}

View File

@@ -1,19 +0,0 @@
package ru.dmitriymx.gradle.extention;
import org.gradle.api.Project;
public class LogicExtention {
private final Project project;
public LogicExtention(Project project) {
this.project = project;
}
public String getProperty1(String propertyName1, String propertyName2) {
return (String) (project.hasProperty(propertyName1) ? project.property(propertyName1) : project.property(propertyName2));
}
public String getProperty1(String propertyName) {
return (String) (project.hasProperty(propertyName) ? project.property(propertyName) : null);
}
}

View File

@@ -1,13 +0,0 @@
package ru.dmitriymx.gradle.plugin;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import ru.dmitriymx.gradle.extention.LibsExtention;
public class LibsPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getExtensions().create("libs", LibsExtention.class);
}
}

View File

@@ -1,13 +0,0 @@
package ru.dmitriymx.gradle.plugin;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import ru.dmitriymx.gradle.extention.LogicExtention;
public class LogicPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getExtensions().create("logic", LogicExtention.class, project);
}
}

40
libs.gradle Normal file
View File

@@ -0,0 +1,40 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GrUnresolvedAccess
//file:noinspection GroovyConstructorNamedArguments
def slf4j_version = '1.7.30'
def logback_version = '1.2.3'
def dagger2_version = '2.33'
def junit_version = '5.5.2'
ext {
libs = [
lombok : 'org.projectlombok:lombok:1.18.12',
annotations: 'com.google.code.findbugs:jsr305:3.0.2',
guava : 'com.google.guava:guava:30.1-jre',
lang3 : 'org.apache.commons:commons-lang3:3.11',
]
libs.logger = [
slf4j : ["org.slf4j:slf4j-api:${slf4j_version}",
"org.slf4j:jcl-over-slf4j:${slf4j_version}"],
logback: ["ch.qos.logback:logback-core:${logback_version}",
"ch.qos.logback:logback-classic:${logback_version}"]
]
libs.dagger2 = [
implementation : "com.google.dagger:dagger:${dagger2_version}",
annotationProcessor: "com.google.dagger:dagger-compiler:${dagger2_version}"
]
libs.test = [
logger: "org.slf4j:slf4j-simple:${slf4j_version}"
]
libs.test.junit5 = [
api : "org.junit.jupiter:junit-jupiter-api:${junit_version}",
//runtime only
engine: "org.junit.jupiter:junit-jupiter-engine:${junit_version}",
params: "org.junit.jupiter:junit-jupiter-params:${junit_version}"
]
}

42
logic.gradle Normal file
View File

@@ -0,0 +1,42 @@
//file:noinspection GrUnresolvedAccess
apply plugin: 'java'
apply from: rootDir.toPath().resolve('libs.gradle').toFile()
String getProperty1(String propertyName1, String propertyName2) {
return (String) (project.hasProperty(propertyName1) ? project.property(propertyName1) : project.property(propertyName2))
}
project.group = getProperty1('module.group', 'project.group')
project.version = getProperty1('module.version', 'project.version')
jar.archiveBaseName.set(getProperty1('module.name', 'project.name'))
compileJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
options.encoding = 'UTF-8'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
annotationProcessor libs.lombok
compileOnly libs.lombok
compileOnly libs.annotations
implementation libs.logger.slf4j
implementation libs.dagger2.implementation
annotationProcessor libs.dagger2.annotationProcessor
testImplementation libs.test.junit5.api
testImplementation libs.test.junit5.params
testRuntimeOnly libs.test.junit5.engine
testRuntimeOnly libs.test.logger
}
test {
useJUnitPlatform()
}

8
protocol/build.gradle Normal file
View File

@@ -0,0 +1,8 @@
apply from: rootDir.toPath().resolve('logic.gradle').toFile()
dependencies {
implementation 'io.netty:netty-all:4.1.22.Final'
implementation libs.guava
testImplementation libs.lang3
}

View File

@@ -0,0 +1,3 @@
# suppress inspection "UnusedProperty" for whole file
module.name=protocol
module.version=1.0-SNAPSHOT

View File

@@ -1,6 +1,5 @@
package mc.protocol.io;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

23
server/build.gradle Normal file
View File

@@ -0,0 +1,23 @@
/*
Запуск
gradle :server:run
*/
apply from: rootDir.toPath().resolve('logic.gradle').toFile()
apply plugin: 'application'
application {
mainClassName = 'mc.server.Main'
}
dependencies {
implementation project(':protocol')
implementation libs.logger.logback
implementation platform('io.projectreactor:reactor-bom:2020.0.6')
implementation 'io.projectreactor:reactor-core'
implementation 'io.netty:netty-all:4.1.22.Final'
implementation libs.guava
}

3
server/gradle.properties Normal file
View File

@@ -0,0 +1,3 @@
# suppress inspection "UnusedProperty" for whole file
module.name=server
module.version=1.0-SNAPSHOT

View File

@@ -10,4 +10,5 @@ rootProject.projectDir.toPath().resolve('gradle.properties').readLines().forEach
rootProject.name = map.get('project.name')
include('protocol')
include('server')