-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: change Gradle DSL to Kotlin (#52)
* build: change Gradle DSL to Kotlin * chore: chmod +x for gradlew * ci: update sduoj-server building * ci: skip test * build: update Dockerfile * build: update Dockerfile * fix: missing spring-boot-plugin causes bytecode without MethodParameters * build: accpet gradle ToS automatically * build: switch to aliyun source
- Loading branch information
1 parent
cf86862
commit 4c199fd
Showing
20 changed files
with
235 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,62 @@ | ||
FROM ubuntu:18.04 | ||
MAINTAINER SDUOJ-Team | ||
|
||
ENV LANG C.UTF-8 | ||
|
||
COPY docker/sources.list /etc/apt/sources.list | ||
COPY docker/mavenSettings.xml /usr/share/maven/conf/settings.xml | ||
COPY docker/testlib /testlib.h | ||
COPY docker/checkers/ /checkers/ | ||
|
||
ADD https://github.com/SDUOJ/docker-compose-wait/releases/download/2.7.3/wait /wait | ||
RUN mkdir /sduoj \ | ||
&& chmod +x /wait | ||
|
||
# install OS softwares | ||
RUN apt-get update \ | ||
&& apt-get install -qq -y \ | ||
make=4.1-9.1ubuntu1 dosbox=0.74-4.3 cmake \ | ||
sudo git unzip wget libseccomp-dev libseccomp2 seccomp build-essential \ | ||
python3-pip python vim dos2unix openjdk-8-jdk \ | ||
&& mkdir /usr/share/maven/conf/logging \ | ||
&& ln -sf /usr/lib/jvm/java-8-openjdk-amd64/bin/java /usr/bin/java \ | ||
&& ln -sf /usr/lib/jvm/java-8-openjdk-amd64/bin/javac /usr/bin/javac | ||
|
||
# compile and install sduoj-sandbox | ||
RUN wget -q -O /sduoj/sandbox.zip https://codeload.github.com/SDUOJ/sduoj-sandbox/zip/master \ | ||
&& unzip -o -q -d /sduoj /sduoj/sandbox.zip \ | ||
&& rm /sduoj/sandbox.zip \ | ||
&& cd /sduoj/sduoj-sandbox* \ | ||
&& make \ | ||
&& make install | ||
|
||
# download source code | ||
RUN wget -q -O /sduoj/server.zip https://codeload.github.com/SDUOJ/sduoj-server/zip/master \ | ||
&& wget -q -O /sduoj/judger.zip https://codeload.github.com/SDUOJ/sduoj-judger/zip/master \ | ||
&& unzip -o -q -d /sduoj/dockerWorkspace /sduoj/server.zip \ | ||
&& unzip -o -q -d /sduoj/dockerWorkspace /sduoj/judger.zip \ | ||
&& rm /sduoj/server.zip \ | ||
&& rm /sduoj/judger.zip | ||
|
||
# compile and install sduoj-server | ||
RUN cd /sduoj/dockerWorkspace/sduoj-server* \ | ||
&& chmod +x ./mvnw \ | ||
&& ./mvnw install \ | ||
--projects sduoj-submit/sduoj-submit-interface \ | ||
--projects sduoj-problem/sduoj-problem-interface \ | ||
--projects sduoj-filesys/sduoj-filesys-interface \ | ||
--also-make \ | ||
--no-transfer-progress \ | ||
--batch-mode \ | ||
-Dmaven.test.skip=true \ | ||
-T `nproc`\ | ||
# compile sduoj-judger | ||
&& cd /sduoj/dockerWorkspace/sduoj-judger* \ | ||
&& chmod +x ./gradlew \ | ||
&& ./gradlew build \ | ||
&& mv ./sduoj-judger-service/build/libs/sduoj-judger.jar /sduoj/sduoj-judger.jar \ | ||
# clean | ||
&& rm -rf ~/.m2 \ | ||
&& rm -rf ~/.gradle \ | ||
&& rm -rf /sduoj/dockerWorkspace | ||
|
||
ENV NACOS_ADDR=nacos.oj.qd.sdu.edu.cn:8848 | ||
ENV ACTIVE=prod | ||
|
||
WORKDIR /sduoj | ||
|
||
CMD /wait \ | ||
&& java -jar sduoj-judger.jar \ | ||
--sduoj.config.nacos-addr=$NACOS_ADDR \ | ||
--sduoj.config.active=$ACTIVE \ | ||
>> /sduoj/sduoj.log | ||
FROM ubuntu:18.04 | ||
MAINTAINER SDUOJ-Team | ||
|
||
ENV LANG C.UTF-8 | ||
|
||
COPY docker/sources.list /etc/apt/sources.list | ||
COPY docker/testlib /testlib.h | ||
COPY docker/checkers/ /checkers/ | ||
|
||
ADD https://github.com/SDUOJ/docker-compose-wait/releases/download/2.7.3/wait /wait | ||
RUN mkdir -p /sduoj/dockerWorkspace \ | ||
&& chmod +x /wait | ||
|
||
# install OS softwares | ||
RUN apt-get update \ | ||
&& apt-get install -qq -y \ | ||
make=4.1-9.1ubuntu1 dosbox=0.74-4.3 cmake \ | ||
sudo git unzip wget libseccomp-dev libseccomp2 seccomp build-essential \ | ||
python3-pip python vim dos2unix openjdk-8-jdk \ | ||
&& ln -sf /usr/lib/jvm/java-8-openjdk-amd64/bin/java /usr/bin/java \ | ||
&& ln -sf /usr/lib/jvm/java-8-openjdk-amd64/bin/javac /usr/bin/javac | ||
|
||
# compile and install sduoj-sandbox | ||
RUN wget -q -O /sduoj/sandbox.zip https://codeload.github.com/SDUOJ/sduoj-sandbox/zip/master \ | ||
&& unzip -o -q -d /sduoj /sduoj/sandbox.zip \ | ||
&& rm /sduoj/sandbox.zip \ | ||
&& cd /sduoj/sduoj-sandbox* \ | ||
&& make \ | ||
&& make install | ||
|
||
# download source code | ||
RUN wget -q -O /sduoj/server.zip https://codeload.github.com/SDUOJ/sduoj-server/zip/master \ | ||
&& wget -q -O /sduoj/judger.zip https://codeload.github.com/SDUOJ/sduoj-judger/zip/master \ | ||
&& unzip -o -q -d /sduoj/dockerWorkspace /sduoj/server.zip \ | ||
&& unzip -o -q -d /sduoj/dockerWorkspace /sduoj/judger.zip \ | ||
&& rm /sduoj/server.zip \ | ||
&& rm /sduoj/judger.zip | ||
|
||
# compile and install sduoj-server | ||
RUN cd /sduoj/dockerWorkspace/sduoj-server* \ | ||
&& chmod +x ./gradlew \ | ||
&& ./gradlew publishToMavenLocal -x test \ | ||
# compile sduoj-judger | ||
&& cd /sduoj/dockerWorkspace/sduoj-judger* \ | ||
&& chmod +x ./gradlew \ | ||
&& ./gradlew build \ | ||
&& mv ./sduoj-judger-service/build/libs/sduoj-judger.jar /sduoj/sduoj-judger.jar \ | ||
# clean | ||
&& rm -rf ~/.m2 \ | ||
&& rm -rf ~/.gradle \ | ||
&& rm -rf /sduoj/dockerWorkspace | ||
|
||
ENV NACOS_ADDR=nacos.oj.qd.sdu.edu.cn:8848 | ||
ENV ACTIVE=prod | ||
|
||
WORKDIR /sduoj | ||
|
||
CMD /wait \ | ||
&& java -jar sduoj-judger.jar \ | ||
--sduoj.config.nacos-addr=$NACOS_ADDR \ | ||
--sduoj.config.active=$ACTIVE \ | ||
>> /sduoj/sduoj.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extensions.findByName("buildScan")?.withGroovyBuilder { | ||
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service") | ||
setProperty("termsOfServiceAgree", "yes") | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
plugins { | ||
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build. | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
// Use the plugin portal to apply community plugins in convention plugins. | ||
gradlePluginPortal() | ||
} | ||
|
||
val springBootVersion: String by project | ||
val dependencyManagementPluginVersion: String by project | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion") | ||
implementation("io.spring.gradle:dependency-management-plugin:$dependencyManagementPluginVersion") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
springBootVersion=2.1.12.RELEASE | ||
dependencyManagementPluginVersion=1.0.11.RELEASE |
40 changes: 0 additions & 40 deletions
40
buildSrc/src/main/groovy/cn.edu.sdu.qd.oj.judger.java-conventions.gradle
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
object Versions { | ||
val sduoj = "1.0.0-SNAPSHOT" | ||
|
||
val springCloud = "Greenwich.SR5" | ||
val springCloudAlibaba = "2.1.2.RELEASE" | ||
|
||
val lombok = "1.18.12" | ||
val commonsLang3 = "3.11" | ||
val fastjson = "1.2.73" | ||
val aspectj = "1.9.5" | ||
val guava = "29.0-jre" | ||
val slf4j = "1.7.30" | ||
val jackson = "2.9.10" // TODO: upgrade | ||
val httpclient = "4.5.12" | ||
} |
67 changes: 67 additions & 0 deletions
67
buildSrc/src/main/kotlin/cn.edu.sdu.qd.oj.judger.java-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
id("org.springframework.boot") | ||
id("io.spring.dependency-management") | ||
} | ||
|
||
group = "cn.edu.sdu.qd.oj.judger" | ||
version = Versions.sduoj | ||
|
||
java.sourceCompatibility = JavaVersion.VERSION_1_8 | ||
java.targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
|
||
repositories { | ||
maven { url = uri("https://maven.aliyun.com/repository/public/") } | ||
maven { url = uri("https://maven.aliyun.com/repository/spring/") } | ||
mavenLocal() | ||
// mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.projectlombok:lombok:${Versions.lombok}") | ||
annotationProcessor("org.projectlombok:lombok:${Versions.lombok}") | ||
} | ||
|
||
|
||
dependencyManagement { | ||
imports { | ||
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${Versions.springCloud}") | ||
mavenBom("com.alibaba.cloud:spring-cloud-alibaba-dependencies:${Versions.springCloudAlibaba}") | ||
} | ||
} | ||
|
||
allprojects { | ||
val projectName = this.name | ||
val isService = projectName.contains(Regex("-(service)$")) | ||
if (isService) { | ||
tasks.bootJar { | ||
enabled = true | ||
archiveName = projectName.replace("-service", "") + ".jar" | ||
} | ||
tasks.jar { | ||
enabled = false | ||
} | ||
} else { | ||
tasks.bootJar { | ||
enabled = false | ||
} | ||
tasks.jar { | ||
enabled = true | ||
} | ||
publishing { | ||
publications.create<MavenPublication>("maven") { | ||
artifact(tasks.jar) | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>() { | ||
options.encoding = "UTF-8" | ||
} |
Oops, something went wrong.