From 3aedda0e9390b1a94ac13ab7735fbc5883d7336a Mon Sep 17 00:00:00 2001 From: aNNiMON Date: Sat, 26 Aug 2023 15:59:36 +0300 Subject: [PATCH] Add multi-project structure --- .gitignore | 7 +--- build.gradle | 76 +++++------------------------------- modules/main/build.gradle | 25 ++++++++++++ ownlang-core/build.gradle | 36 +++++++++++++++++ ownlang-desktop/build.gradle | 41 +++++++++++++++++++ ownlang-parser/build.gradle | 20 ++++++++++ ownlang-utils/build.gradle | 20 ++++++++++ settings.gradle | 8 ++++ 8 files changed, 161 insertions(+), 72 deletions(-) create mode 100644 modules/main/build.gradle create mode 100644 ownlang-core/build.gradle create mode 100644 ownlang-desktop/build.gradle create mode 100644 ownlang-parser/build.gradle create mode 100644 ownlang-utils/build.gradle diff --git a/.gitignore b/.gitignore index d2384ba..8fda764 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,9 @@ /.gradle/ /.idea/ /.nb-gradle/ -/build/ +**/build/ /dist/ /out/ /store/ /optimizations/ -/nbproject/private/ -/src/main/generatedJava/ -OwnLang.iml -.nb-gradle-properties +OwnLang.iml \ No newline at end of file diff --git a/build.gradle b/build.gradle index fadfc0d..50fdc92 100644 --- a/build.gradle +++ b/build.gradle @@ -1,70 +1,12 @@ -plugins { - id 'java' -} +allprojects { + repositories { + mavenCentral() + } -group = 'com.annimon' -version = '2.0-SNAPSHOT' - -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' -if (!hasProperty('mainClass')) { - ext.mainClass = 'com.annimon.ownlang.Main' -} - -ext.generatedJavaDir = "${rootProject.projectDir}/src/main/generatedJava" -sourceSets.main.java.srcDirs += project.generatedJavaDir - -repositories { - mavenCentral() -} - -tasks.register('generateJavaSources') { - doLast { - def source = """ - package com.annimon.ownlang; - class Gen { - private Gen() {} - public static final String BUILD_DATE = "${new Date().format('YYMMdd')}"; - } - """.stripIndent() - def genFile = new File("${project.generatedJavaDir}/com/annimon/ownlang/Gen.java") - genFile.getParentFile().mkdirs() - genFile.write(source) + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + } } } -compileJava.dependsOn(generateJavaSources) - -tasks.register('run', JavaExec) { - dependsOn classes - mainClass = project.mainClass - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in - ignoreExitValue true -} - -tasks.register('runOptimizing', JavaExec) { - dependsOn classes - mainClass = project.mainClass - classpath = sourceSets.main.runtimeClasspath - ignoreExitValue true - args '-o 9 -m -a -f program.own'.split(' ') -} - - -dependencies { - implementation ('io.socket:socket.io-client:1.0.2') { - exclude group: 'org.json', module: 'json' - } - implementation 'org.json:json:20230227' - implementation 'org.yaml:snakeyaml:1.20' - implementation 'jline:jline:2.14.5' - - testImplementation platform('org.junit:junit-bom:5.9.2') - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2' - testImplementation 'org.junit.jupiter:junit-jupiter' - testImplementation 'org.openjdk.jmh:jmh-core:1.37' - testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.37' -} - -test { - useJUnitPlatform() -} \ No newline at end of file diff --git a/modules/main/build.gradle b/modules/main/build.gradle new file mode 100644 index 0000000..f4e3e04 --- /dev/null +++ b/modules/main/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'java-library' +} + +group = 'com.annimon.module' +version = '2.0-SNAPSHOT' + + +dependencies { + api project(":ownlang-core") + + implementation 'com.squareup.okhttp3:okhttp:3.8.1' + implementation ('io.socket:socket.io-client:1.0.2') { + exclude group: 'org.json', module: 'json' + } + implementation 'org.json:json:20230227' + implementation 'org.yaml:snakeyaml:1.20' + + testImplementation platform('org.junit:junit-bom:5.9.2') + testImplementation 'org.junit.jupiter:junit-jupiter' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/ownlang-core/build.gradle b/ownlang-core/build.gradle new file mode 100644 index 0000000..af68609 --- /dev/null +++ b/ownlang-core/build.gradle @@ -0,0 +1,36 @@ +plugins { + id 'java-library' +} + +group = 'com.annimon' +version = '2.0-SNAPSHOT' + +dependencies { + implementation 'org.json:json:20230227' + + testImplementation platform('org.junit:junit-bom:5.9.2') + testImplementation 'org.junit.jupiter:junit-jupiter' +} + +test { + useJUnitPlatform() +} + +ext.generatedJavaDir = "${project.buildDir}/gen/src/main/java" +sourceSets.main.java.srcDirs += project.generatedJavaDir + +tasks.register('generateJavaSources') { + doLast { + def source = """ + package com.annimon.ownlang; + class Gen { + private Gen() {} + public static final String BUILD_DATE = "${new Date().format('YYMMdd')}"; + } + """.stripIndent() + def genFile = new File("${project.generatedJavaDir}/com/annimon/ownlang/Gen.java") + genFile.getParentFile().mkdirs() + genFile.write(source) + } +} +compileJava.dependsOn(generateJavaSources) \ No newline at end of file diff --git a/ownlang-desktop/build.gradle b/ownlang-desktop/build.gradle new file mode 100644 index 0000000..93ff3a0 --- /dev/null +++ b/ownlang-desktop/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'java' + id 'application' +} + +group = 'com.annimon' +version = '2.0-SNAPSHOT' + +application { + mainClass ='com.annimon.ownlang.Main' +} + +dependencies { + implementation project(":ownlang-core") + implementation project(":ownlang-parser") + implementation project(":ownlang-utils") + implementation project(":modules:main") + + testImplementation platform('org.junit:junit-bom:5.9.2') + testImplementation 'org.junit.jupiter:junit-jupiter' +} + +test { + useJUnitPlatform() +} + +/*tasks.register('run', JavaExec) { + dependsOn classes + mainClass = project.mainClass + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + ignoreExitValue true +} + +tasks.register('runOptimizing', JavaExec) { + dependsOn classes + mainClass = project.mainClass + classpath = sourceSets.main.runtimeClasspath + ignoreExitValue true + args '-o 9 -m -a -f program.own'.split(' ') +}*/ \ No newline at end of file diff --git a/ownlang-parser/build.gradle b/ownlang-parser/build.gradle new file mode 100644 index 0000000..b380dd7 --- /dev/null +++ b/ownlang-parser/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java-library' +} + +group = 'com.annimon' +version = '2.0-SNAPSHOT' + +dependencies { + api project(":ownlang-core") + + testImplementation platform('org.junit:junit-bom:5.9.2') + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2' + testImplementation 'org.junit.jupiter:junit-jupiter' + testImplementation 'org.openjdk.jmh:jmh-core:1.37' + testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.37' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/ownlang-utils/build.gradle b/ownlang-utils/build.gradle new file mode 100644 index 0000000..389808e --- /dev/null +++ b/ownlang-utils/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java-library' +} + +group = 'com.annimon' +version = '2.0-SNAPSHOT' + +dependencies { + api project(":ownlang-parser") + implementation 'org.json:json:20230227' + implementation 'org.yaml:snakeyaml:1.20' + implementation 'jline:jline:2.14.5' + + testImplementation platform('org.junit:junit-bom:5.9.2') + testImplementation 'org.junit.jupiter:junit-jupiter' +} + +test { + useJUnitPlatform() +} diff --git a/settings.gradle b/settings.gradle index b699976..bd2b452 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,9 @@ rootProject.name = 'OwnLang' + +include 'ownlang-core' +include 'ownlang-parser' +include 'ownlang-desktop' +include 'ownlang-utils' + +include 'modules:main' +findProject(':modules:main')?.name = 'main' \ No newline at end of file