├── .gitignore ├── assignments-react-ui ├── .dockerignore ├── public │ ├── favicon.ico │ └── index.html ├── docker │ └── Dockerfile ├── src │ ├── index.js │ ├── listItems.js │ ├── NewAssignment.js │ ├── Assignments.js │ └── App.js ├── assignments-react-ui.iml ├── .gitignore ├── package.json └── README.md ├── README.md ├── assignments-gateway ├── http-client.env.json ├── docker │ └── Dockerfile ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── resources │ │ │ └── bootstrap.properties │ │ └── java │ │ │ └── iteach │ │ │ └── eaap │ │ │ └── assignments │ │ │ └── apigateway │ │ │ ├── Assignment.java │ │ │ ├── Submission.java │ │ │ ├── AssignmentGatewayApplication.java │ │ │ ├── AssignmentGatewayConfiguration.java │ │ │ └── SubmissionHandler.java │ └── test │ │ └── java │ │ └── iteach │ │ └── eaap │ │ └── assignments │ │ └── apigateway │ │ └── ApiGatewayApplicationTests.java ├── .gitignore ├── test.http ├── pom.xml ├── mvnw.cmd └── mvnw ├── docker ├── nacos_config_export_20200426220250.zip ├── nacos-docker-compose.yml ├── docker-compose.yml └── deploy-assignments.ps1 ├── assignments-management ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── resources │ │ │ └── bootstrap.properties │ │ └── java │ │ │ └── iteach │ │ │ └── eaap │ │ │ └── assignments │ │ │ └── management │ │ │ ├── domain │ │ │ ├── AssignmentException.java │ │ │ ├── AssignmentDeadlineException.java │ │ │ ├── AssignmentStatusException.java │ │ │ ├── Status.java │ │ │ ├── AssignmentId.java │ │ │ ├── Deadline.java │ │ │ └── Assignment.java │ │ │ ├── application │ │ │ ├── port │ │ │ │ ├── outbound │ │ │ │ │ └── AssignmentRepository.java │ │ │ │ └── inbound │ │ │ │ │ └── AssignmentUseCase.java │ │ │ └── AssignmentApplicationService.java │ │ │ ├── AssignmentManagementApplication.java │ │ │ └── adapter │ │ │ ├── inbound │ │ │ ├── AssignmentDTO.java │ │ │ └── AssignmentController.java │ │ │ └── outbound │ │ │ └── JpaAssignmentRepository.java │ └── test │ │ └── java │ │ └── iteach │ │ └── eaap │ │ └── assignments │ │ └── management │ │ └── AssignmentManagementApplicationTests.java ├── docker │ ├── Dockerfile │ ├── schema │ │ └── schema.sql │ └── wait-for-it.sh ├── test.http ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── assignments-submission ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── resources │ │ │ └── bootstrap.properties │ │ └── java │ │ │ └── iteach │ │ │ └── eaap │ │ │ └── assignments │ │ │ └── submission │ │ │ ├── domain │ │ │ ├── SubmissionException.java │ │ │ └── Submission.java │ │ │ ├── application │ │ │ ├── port │ │ │ │ ├── inbound │ │ │ │ │ ├── CreateSubmissionUseCase.java │ │ │ │ │ ├── QueryUserSubmissionUseCase.java │ │ │ │ │ └── QueryAssignmentSubmissionUseCase.java │ │ │ │ └── outbound │ │ │ │ │ ├── CreateSubmissionRepository.java │ │ │ │ │ ├── QueryUserSubmissionRepository.java │ │ │ │ │ └── QueryAssignmentSubmissionRepository.java │ │ │ ├── QueryUserSubmissionApplicationService.java │ │ │ ├── QueryAssignmentSubmissionApplicationService.java │ │ │ └── CreateSubmissionApplicationService.java │ │ │ ├── adapter │ │ │ ├── outbound │ │ │ │ ├── JpaCreateSubmissionRepository.java │ │ │ │ ├── JpaQueryUserSubmissionRepository.java │ │ │ │ └── JpaQueryAssignmentSubmissionRepository.java │ │ │ └── inbound │ │ │ │ ├── QueryUserSubmissionController.java │ │ │ │ ├── CreateSubmissionController.java │ │ │ │ └── QueryAssignmentSubmissionController.java │ │ │ └── AssignmentSubmissionApplication.java │ └── test │ │ └── java │ │ └── iteach │ │ └── eaap │ │ └── assignments │ │ └── submission │ │ └── AssignmentsSubmissionApplicationTests.java ├── docker │ ├── Dockerfile │ ├── schema │ │ └── schema.sql │ └── wait-for-it.sh ├── test.http ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw ├── k8s ├── react-ui.yaml ├── management.yaml ├── submission.yaml ├── submission-mysql.yaml ├── management-mysql.yaml └── gateway.yaml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /assignments-react-ui/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eaap-assignments 2 | 作业提交系统的微服务实现 3 | 4 | ## 使用 5 | 6 | -------------------------------------------------------------------------------- /assignments-gateway/http-client.env.json: -------------------------------------------------------------------------------- 1 | { 2 | "dev": { 3 | "assignmentId": "064fd8bf-7a6b-4dd8-a721-21e9e6bd0cf3" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /assignments-react-ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walshzhang/eaap-assignments/HEAD/assignments-react-ui/public/favicon.ico -------------------------------------------------------------------------------- /assignments-gateway/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre-alpine 2 | WORKDIR /app 3 | COPY app.jar . 4 | ENTRYPOINT ["java", "-jar", "/app/app.jar"] 5 | -------------------------------------------------------------------------------- /assignments-react-ui/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:stable-alpine 2 | COPY build /usr/share/nginx/html 3 | ENTRYPOINT ["nginx", "-g", "daemon off;"] 4 | -------------------------------------------------------------------------------- /docker/nacos_config_export_20200426220250.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walshzhang/eaap-assignments/HEAD/docker/nacos_config_export_20200426220250.zip -------------------------------------------------------------------------------- /assignments-gateway/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walshzhang/eaap-assignments/HEAD/assignments-gateway/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /assignments-management/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walshzhang/eaap-assignments/HEAD/assignments-management/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /assignments-submission/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walshzhang/eaap-assignments/HEAD/assignments-submission/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /assignments-submission/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=assignments-submission 2 | spring.cloud.nacos.config.server-addr=nacos-server:8848 3 | -------------------------------------------------------------------------------- /assignments-management/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | #spring.application.name=assignments-management 2 | #spring.cloud.nacos.config.server-addr=nacos-server:8848 3 | -------------------------------------------------------------------------------- /assignments-gateway/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | #spring.application.name=assignments-gateway 2 | #spring.cloud.nacos.config.server-addr=nacos-server:8848 3 | #spring.cloud.nacos.config.file-extension=yaml 4 | -------------------------------------------------------------------------------- /assignments-management/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre-alpine 2 | WORKDIR /app 3 | COPY app.jar . 4 | COPY wait-for-it.sh . 5 | RUN apk add bash 6 | ENTRYPOINT ["./wait-for-it.sh", "management-mysql:3306", "--", "java", "-jar", "/app/app.jar"] 7 | -------------------------------------------------------------------------------- /assignments-submission/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre-alpine 2 | WORKDIR /app 3 | COPY app.jar . 4 | COPY wait-for-it.sh . 5 | RUN apk add bash 6 | ENTRYPOINT ["./wait-for-it.sh", "submission-mysql:3306", "--", "java", "-jar", "/app/app.jar"] 7 | -------------------------------------------------------------------------------- /assignments-gateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /assignments-react-ui/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render( 6 | 7 | 8 | , 9 | document.getElementById('root') 10 | ); 11 | -------------------------------------------------------------------------------- /assignments-management/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /assignments-submission/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /assignments-submission/test.http: -------------------------------------------------------------------------------- 1 | POST http://localhost:29999/submissions 2 | Content-Type: application/json 3 | 4 | { 5 | "code": "printf('hello world');", 6 | "assignment": "8d0cca56-eb9f-4f7d-a9b3-b037150f77e1" 7 | } 8 | 9 | ### 10 | GET http://localhost:29999/submissions 11 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/domain/SubmissionException.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.domain; 2 | 3 | public class SubmissionException extends RuntimeException { 4 | public SubmissionException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/AssignmentException.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | public class AssignmentException extends RuntimeException { 4 | public AssignmentException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /assignments-submission/docker/schema/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE submissions 2 | ( 3 | id VARCHAR(36) not null, 4 | code TEXT not null, 5 | assignment VARCHAR(36) NOT NULL, 6 | user VARCHAR(36) NOT NULL, 7 | datetime DATETIME NOT NULL, 8 | PRIMARY KEY (id) 9 | ); 10 | -------------------------------------------------------------------------------- /assignments-management/docker/schema/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE assignments 2 | ( 3 | id VARCHAR(36) not null, 4 | title VARCHAR(50) not null, 5 | description TEXT not null, 6 | deadline DATETIME not null, 7 | status int not null, 8 | PRIMARY KEY (id) 9 | ); 10 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/AssignmentDeadlineException.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | public class AssignmentDeadlineException extends AssignmentException { 4 | public AssignmentDeadlineException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /docker/nacos-docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | nacos-server: 5 | image: nacos/nacos-server 6 | container_name: nacos-server 7 | environment: 8 | MODE: standalone 9 | ports: 10 | - 8848:8848 11 | 12 | networks: 13 | default: 14 | external: 15 | name: assignments 16 | -------------------------------------------------------------------------------- /assignments-gateway/src/main/java/iteach/eaap/assignments/apigateway/Assignment.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.apigateway; 2 | 3 | import lombok.Data; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | @Data 8 | public class Assignment { 9 | private String deadline; 10 | private String id; 11 | private String status; 12 | } 13 | -------------------------------------------------------------------------------- /assignments-gateway/src/main/java/iteach/eaap/assignments/apigateway/Submission.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.apigateway; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Submission { 7 | private String id; 8 | private String code; 9 | private String assignmentId; 10 | 11 | private Assignment assignment; 12 | } 13 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/port/inbound/CreateSubmissionUseCase.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application.port.inbound; 2 | 3 | import iteach.eaap.assignments.submission.domain.Submission; 4 | 5 | public interface CreateSubmissionUseCase { 6 | void createSubmission(Submission submission); 7 | } 8 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/AssignmentStatusException.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | /** 4 | * 注意可见修饰符为包可见 5 | * 6 | */ 7 | class AssignmentStatusException extends AssignmentException { 8 | public AssignmentStatusException(String message) { 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/port/outbound/CreateSubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application.port.outbound; 2 | 3 | import iteach.eaap.assignments.submission.domain.Submission; 4 | 5 | public interface CreateSubmissionRepository { 6 | void addSubmission(Submission submission); 7 | } 8 | -------------------------------------------------------------------------------- /assignments-gateway/src/test/java/iteach/eaap/assignments/apigateway/ApiGatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.apigateway; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApiGatewayApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/port/inbound/QueryUserSubmissionUseCase.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application.port.inbound; 2 | 3 | import java.util.List; 4 | 5 | import iteach.eaap.assignments.submission.domain.Submission; 6 | 7 | public interface QueryUserSubmissionUseCase { 8 | List queryAll(String userId); 9 | } 10 | -------------------------------------------------------------------------------- /assignments-management/src/test/java/iteach/eaap/assignments/management/AssignmentManagementApplicationTests.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AssignmentManagementApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /assignments-submission/src/test/java/iteach/eaap/assignments/submission/AssignmentsSubmissionApplicationTests.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AssignmentsSubmissionApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /assignments-management/test.http: -------------------------------------------------------------------------------- 1 | POST http://localhost:39999/assignments 2 | Content-Type: application/json 3 | 4 | { 5 | "title": "string", 6 | "description": "string", 7 | "deadline": "2020-04-16 08:32:23" 8 | } 9 | 10 | ### 11 | GET http://localhost:39999/assignments/8d0cca56-eb9f-4f7d-a9b3-b037150f77e1/status 12 | 13 | ### 14 | PUT http://localhost:39999/assignments/publish/8d0cca56-eb9f-4f7d-a9b3-b037150f77e1 15 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/port/outbound/QueryUserSubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application.port.outbound; 2 | 3 | import iteach.eaap.assignments.submission.domain.Submission; 4 | 5 | import java.util.List; 6 | 7 | public interface QueryUserSubmissionRepository { 8 | List queryAllByUserId(String userId); 9 | } 10 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/port/inbound/QueryAssignmentSubmissionUseCase.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application.port.inbound; 2 | 3 | import java.util.List; 4 | 5 | import iteach.eaap.assignments.submission.domain.Submission; 6 | 7 | public interface QueryAssignmentSubmissionUseCase { 8 | List querySubmissions(String assignmentId); 9 | } 10 | -------------------------------------------------------------------------------- /assignments-react-ui/assignments-react-ui.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/port/outbound/QueryAssignmentSubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application.port.outbound; 2 | 3 | import java.util.List; 4 | 5 | import iteach.eaap.assignments.submission.domain.Submission; 6 | 7 | public interface QueryAssignmentSubmissionRepository { 8 | List queryAllByAssignmentId(String assignmentId); 9 | } 10 | -------------------------------------------------------------------------------- /assignments-react-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | docker/build/ 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /k8s/react-ui.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: react-ui 5 | labels: 6 | app: react-ui 7 | spec: 8 | containers: 9 | - name: react-ui 10 | image: assignments/react-ui 11 | ports: 12 | - containerPort: 80 13 | --- 14 | apiVersion: v1 15 | kind: Service 16 | metadata: 17 | name: react-ui 18 | spec: 19 | type: NodePort 20 | ports: 21 | - port: 80 22 | targetPort: 80 23 | nodePort: 31000 24 | selector: 25 | app: react-ui 26 | -------------------------------------------------------------------------------- /assignments-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | docker/app.jar 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /assignments-submission/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | docker/app.jar 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /assignments-management/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | docker/app.jar 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | .idea/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/application/port/outbound/AssignmentRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.application.port.outbound; 2 | 3 | import iteach.eaap.assignments.management.domain.Assignment; 4 | import iteach.eaap.assignments.management.domain.AssignmentId; 5 | 6 | import java.util.List; 7 | 8 | public interface AssignmentRepository { 9 | List queryAll(); 10 | void add(Assignment assignment); 11 | void update(Assignment assignment); 12 | Assignment queryById(AssignmentId id); 13 | } 14 | -------------------------------------------------------------------------------- /assignments-gateway/src/main/java/iteach/eaap/assignments/apigateway/AssignmentGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.apigateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | //import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | //@EnableDiscoveryClient 9 | public class AssignmentGatewayApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(AssignmentGatewayApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/AssignmentManagementApplication.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | //import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | //@EnableDiscoveryClient 9 | public class AssignmentManagementApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(AssignmentManagementApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /assignments-react-ui/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | React App 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/adapter/outbound/JpaCreateSubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.adapter.outbound; 2 | 3 | import iteach.eaap.assignments.submission.application.port.outbound.CreateSubmissionRepository; 4 | import iteach.eaap.assignments.submission.domain.Submission; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | public interface JpaCreateSubmissionRepository extends CreateSubmissionRepository, JpaRepository { 8 | @Override 9 | default void addSubmission(Submission submission) { 10 | this.save(submission); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/application/port/inbound/AssignmentUseCase.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.application.port.inbound; 2 | 3 | import iteach.eaap.assignments.management.adapter.inbound.AssignmentDTO; 4 | 5 | import java.util.List; 6 | 7 | public interface AssignmentUseCase { 8 | String createAssignment(AssignmentDTO assignment); 9 | 10 | List getAllAssignments(); 11 | 12 | void publishAssignments(String id); 13 | 14 | void closeAssignment(String id); 15 | 16 | void removeAssignment(String id); 17 | 18 | String statusOf(String id); 19 | 20 | AssignmentDTO getAssignment(String id); 21 | } 22 | -------------------------------------------------------------------------------- /assignments-gateway/test.http: -------------------------------------------------------------------------------- 1 | POST http://localhost:19999/api/assignments 2 | Content-Type: application/json 3 | 4 | { 5 | "title": "assignment title from api gateway", 6 | "description": "assignment description from gateway", 7 | "deadline": "2020-04-30 08:32:23" 8 | } 9 | 10 | ### 11 | GET http://localhost:19999/api/assignments/{{assignmentId}}/status 12 | 13 | ### 14 | PUT http://localhost:19999/api/assignments/publish/{{assignmentId}} 15 | 16 | ### 17 | POST http://localhost:19999/api/submissions 18 | Content-Type: application/json 19 | 20 | { 21 | "code": "printf('hello world');", 22 | "assignment": "{{assignmentId}}" 23 | } 24 | 25 | ### 26 | GET http://localhost:19999/api/submissions 27 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/adapter/inbound/AssignmentDTO.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.adapter.inbound; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.Future; 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.Size; 9 | import java.time.LocalDateTime; 10 | 11 | @Data 12 | public class AssignmentDTO { 13 | private String id; 14 | @NotBlank 15 | private String title; 16 | @NotBlank 17 | @Size(min = 100) 18 | private String description; 19 | @Future 20 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 21 | private LocalDateTime deadline; 22 | private String status; 23 | } 24 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/Status.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | /** 4 | * 如果状态管理过于复杂,可以使用状态模式进行重构 5 | * 6 | */ 7 | public enum Status { 8 | CREATED, 9 | PUBLISHED, 10 | EXPIRED, 11 | CLOSED, 12 | REMOVED; 13 | 14 | public Status changeTo(Status newStatus) { 15 | // 如果当前状态处于 REMOVED,那么它不可以变成其他状态 16 | if(this == Status.REMOVED) { 17 | if(newStatus != Status.REMOVED) { 18 | throw new AssignmentStatusException("不能修改已删除作业的状态"); 19 | } 20 | } 21 | 22 | // 如果当前状态不是 CREATED, 那么不允许发布 23 | if(this != Status.CREATED) { 24 | if(newStatus == Status.PUBLISHED) { 25 | throw new AssignmentStatusException("不能发布一个不是已创建状态的作业"); 26 | } 27 | } 28 | 29 | // ..... 30 | 31 | return newStatus; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/adapter/inbound/QueryUserSubmissionController.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.adapter.inbound; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import iteach.eaap.assignments.submission.application.port.inbound.QueryUserSubmissionUseCase; 9 | import iteach.eaap.assignments.submission.domain.Submission; 10 | import lombok.AllArgsConstructor; 11 | 12 | @RestController 13 | @AllArgsConstructor 14 | class QueryUserSubmissionController { 15 | QueryUserSubmissionUseCase usecase; 16 | 17 | @GetMapping("/submissions") 18 | List submissions() { 19 | String userId = "1"; // TODO hard code 20 | return usecase.queryAll(userId); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/adapter/inbound/CreateSubmissionController.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.adapter.inbound; 2 | 3 | import iteach.eaap.assignments.submission.domain.Submission; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RequestBody; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import iteach.eaap.assignments.submission.application.port.inbound.CreateSubmissionUseCase; 9 | import lombok.AllArgsConstructor; 10 | 11 | @RestController 12 | @AllArgsConstructor 13 | class CreateSubmissionController { 14 | private CreateSubmissionUseCase usecase; 15 | 16 | @PostMapping("/submissions") 17 | void createSubmission(@RequestBody Submission submission) { 18 | usecase.createSubmission(submission); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/adapter/inbound/QueryAssignmentSubmissionController.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.adapter.inbound; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import iteach.eaap.assignments.submission.application.port.inbound.QueryAssignmentSubmissionUseCase; 9 | import iteach.eaap.assignments.submission.domain.Submission; 10 | import lombok.AllArgsConstructor; 11 | 12 | @RestController 13 | @AllArgsConstructor 14 | class QueryAssignmentSubmissionController { 15 | QueryAssignmentSubmissionUseCase usecase; 16 | 17 | @GetMapping("/submissions/{assignmentId}") 18 | List submissionsOf(String assignmentId) { 19 | return usecase.querySubmissions(assignmentId); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/adapter/outbound/JpaQueryUserSubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.adapter.outbound; 2 | 3 | import iteach.eaap.assignments.submission.application.port.outbound.QueryAssignmentSubmissionRepository; 4 | import iteach.eaap.assignments.submission.application.port.outbound.QueryUserSubmissionRepository; 5 | import iteach.eaap.assignments.submission.domain.Submission; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | 8 | import java.util.List; 9 | 10 | public interface JpaQueryUserSubmissionRepository extends QueryUserSubmissionRepository, JpaRepository { 11 | @Override 12 | default List queryAllByUserId(String userId) { 13 | return findAllByUser(userId); 14 | } 15 | 16 | List findAllByUser(String assignmentId); 17 | } 18 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/domain/Submission.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.domain; 2 | 3 | import java.time.LocalDateTime; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | import com.fasterxml.jackson.annotation.JsonAlias; 11 | import com.fasterxml.jackson.annotation.JsonFormat; 12 | import com.fasterxml.jackson.annotation.JsonIgnore; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @Entity 18 | @NoArgsConstructor 19 | @Table(name = "SUBMISSIONS") 20 | public class Submission { 21 | @Id 22 | private String id; 23 | private String code; 24 | private String user; 25 | private LocalDateTime datetime; 26 | private String assignment; 27 | 28 | public String getAssignmentId() { 29 | return assignment; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/AssignmentSubmissionApplication.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | @SpringBootApplication 11 | @EnableDiscoveryClient 12 | public class AssignmentSubmissionApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(AssignmentSubmissionApplication.class, args); 16 | } 17 | 18 | @Bean 19 | @LoadBalanced 20 | public RestTemplate restTemplate() { 21 | return new RestTemplate(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/adapter/outbound/JpaQueryAssignmentSubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.adapter.outbound; 2 | 3 | import iteach.eaap.assignments.submission.application.port.inbound.QueryAssignmentSubmissionUseCase; 4 | import iteach.eaap.assignments.submission.application.port.outbound.QueryAssignmentSubmissionRepository; 5 | import iteach.eaap.assignments.submission.domain.Submission; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | 8 | import java.util.List; 9 | 10 | public interface JpaQueryAssignmentSubmissionRepository extends QueryAssignmentSubmissionRepository, JpaRepository { 11 | @Override 12 | default List queryAllByAssignmentId(String assignmentId) { 13 | return findAllByAssignment(assignmentId); 14 | } 15 | 16 | List findAllByAssignment(String assignment); 17 | } 18 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/AssignmentId.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Embeddable; 5 | import java.io.Serializable; 6 | import java.util.UUID; 7 | 8 | /** 9 | * 值对象 10 | * 11 | */ 12 | @Embeddable 13 | public class AssignmentId implements Serializable { 14 | @Column(name = "id") 15 | private String value; 16 | 17 | public AssignmentId() { 18 | this.value = UUID.randomUUID().toString(); 19 | } 20 | 21 | public static AssignmentId of(String id) { 22 | AssignmentId assignmentId = new AssignmentId(); 23 | assignmentId.value = UUID.fromString(id).toString(); 24 | return assignmentId; 25 | } 26 | 27 | /** 28 | * 此处没有使用 getValue 29 | * 也没有使用 Lombok 30 | * 31 | */ 32 | public String value() { 33 | return this.value; 34 | } 35 | 36 | public AssignmentId nextId() { 37 | return new AssignmentId(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/QueryUserSubmissionApplicationService.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application; 2 | 3 | import java.util.List; 4 | 5 | import iteach.eaap.assignments.submission.application.port.outbound.QueryUserSubmissionRepository; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | import iteach.eaap.assignments.submission.application.port.inbound.QueryUserSubmissionUseCase; 10 | import iteach.eaap.assignments.submission.domain.Submission; 11 | import lombok.AllArgsConstructor; 12 | 13 | @Service 14 | @Transactional 15 | @AllArgsConstructor 16 | public class QueryUserSubmissionApplicationService implements QueryUserSubmissionUseCase { 17 | QueryUserSubmissionRepository repository; 18 | @Override 19 | public List queryAll(String userId) { 20 | return repository.queryAllByUserId(userId); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /assignments-react-ui/src/listItems.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ListItem from '@material-ui/core/ListItem'; 3 | import ListItemIcon from '@material-ui/core/ListItemIcon'; 4 | import ListItemText from '@material-ui/core/ListItemText'; 5 | import AssignmentIcon from '@material-ui/icons/Assignment'; 6 | 7 | import {Link} from 'react-router-dom' 8 | 9 | function ListItemLink(props) { 10 | const { icon, primary, to } = props; 11 | 12 | const renderLink = React.useMemo( 13 | () => React.forwardRef((itemProps, ref) => ), 14 | [to], 15 | ); 16 | 17 | return ( 18 |
  • 19 | 20 | {icon ? {icon} : null} 21 | 22 | 23 |
  • 24 | ); 25 | } 26 | 27 | export const mainListItems = ( 28 |
    29 | }/> 30 |
    31 | ); 32 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/QueryAssignmentSubmissionApplicationService.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.transaction.annotation.Transactional; 7 | 8 | import iteach.eaap.assignments.submission.application.port.outbound.QueryAssignmentSubmissionRepository; 9 | import iteach.eaap.assignments.submission.application.port.inbound.QueryAssignmentSubmissionUseCase; 10 | import iteach.eaap.assignments.submission.domain.Submission; 11 | import lombok.AllArgsConstructor; 12 | 13 | @Service 14 | @Transactional 15 | @AllArgsConstructor 16 | class QueryAssignmentSubmissionApplicationService implements QueryAssignmentSubmissionUseCase{ 17 | private QueryAssignmentSubmissionRepository repository; 18 | 19 | @Override 20 | public List querySubmissions(String assignmentId) { 21 | return repository.queryAllByAssignmentId(assignmentId); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /assignments-react-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assignments-react-ui", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.9.10", 7 | "@material-ui/icons": "^4.9.1", 8 | "@material-ui/lab": "^4.0.0-alpha.50", 9 | "@testing-library/jest-dom": "^4.2.4", 10 | "@testing-library/react": "^9.3.2", 11 | "@testing-library/user-event": "^7.1.2", 12 | "react": "^16.13.1", 13 | "react-dom": "^16.13.1", 14 | "react-router-dom": "^5.1.2", 15 | "react-scripts": "3.4.1" 16 | }, 17 | "scripts": { 18 | "start": "react-scripts start", 19 | "build": "react-scripts build", 20 | "test": "react-scripts test", 21 | "eject": "react-scripts eject" 22 | }, 23 | "eslintConfig": { 24 | "extends": "react-app" 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/adapter/outbound/JpaAssignmentRepository.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.adapter.outbound; 2 | 3 | import iteach.eaap.assignments.management.application.port.outbound.AssignmentRepository; 4 | import iteach.eaap.assignments.management.domain.Assignment; 5 | import iteach.eaap.assignments.management.domain.AssignmentId; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | 8 | import java.util.List; 9 | 10 | interface JpaAssignmentRepository extends AssignmentRepository, JpaRepository { 11 | @Override 12 | default void add(Assignment assignment) { 13 | this.save(assignment); 14 | } 15 | 16 | @Override 17 | default void update(Assignment assignment) { 18 | this.save(assignment); 19 | } 20 | 21 | @Override 22 | default List queryAll() { 23 | return this.findAll(); 24 | } 25 | 26 | @Override 27 | default Assignment queryById(AssignmentId id) { 28 | return this.findById(id).orElse(null); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 walsh zhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/Deadline.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Embeddable; 5 | import java.time.LocalDateTime; 6 | import java.time.temporal.ChronoUnit; 7 | 8 | /** 9 | * 值对象 10 | * 11 | */ 12 | @Embeddable 13 | public class Deadline { 14 | @Column(name = "deadline") 15 | private LocalDateTime datetime; 16 | 17 | public Deadline() {} 18 | 19 | public Deadline(LocalDateTime datetime) { 20 | this.datetime = datetime; 21 | } 22 | 23 | /** 24 | * 此处没有使用 setXxx 方法 25 | */ 26 | private void datetime(LocalDateTime datetime) { 27 | if(datetime.isBefore(LocalDateTime.now())) { 28 | throw new AssignmentDeadlineException("作业截止日期不能早于当前日期"); 29 | } 30 | 31 | // 作业不能超过一周 32 | LocalDateTime aWeekLater = LocalDateTime.now().plus(1, ChronoUnit.WEEKS); 33 | if(datetime.isAfter(aWeekLater)) { 34 | throw new AssignmentDeadlineException("作业截止日期不能超过一周"); 35 | } 36 | } 37 | 38 | public boolean isExpired() { 39 | return this.datetime.isBefore(LocalDateTime.now()); 40 | } 41 | 42 | public LocalDateTime value() { 43 | return this.datetime; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /k8s/management.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: management 5 | labels: 6 | app: management 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: management 11 | replicas: 2 12 | template: 13 | metadata: 14 | labels: 15 | app: management 16 | spec: 17 | containers: 18 | - name: management 19 | image: assignments/management 20 | imagePullPolicy: Never 21 | args: ["--spring.config.location=application.properties"] 22 | ports: 23 | - containerPort: 39999 24 | volumeMounts: 25 | - mountPath: /app/application.properties 26 | name: management-config 27 | subPath: application.properties 28 | volumes: 29 | - name: management-config 30 | configMap: 31 | name: management-config 32 | items: 33 | - key: application.properties 34 | path: application.properties 35 | --- 36 | apiVersion: v1 37 | kind: Service 38 | metadata: 39 | name: management 40 | spec: 41 | ports: 42 | - port: 39999 43 | targetPort: 39999 44 | selector: 45 | app: management 46 | --- 47 | apiVersion: v1 48 | kind: ConfigMap 49 | metadata: 50 | name: management-config 51 | data: 52 | application.properties: | 53 | spring.datasource.url=jdbc:mysql://management-mysql:3306/assignments 54 | spring.datasource.username=root 55 | spring.datasource.password=root 56 | server.port=39999 57 | -------------------------------------------------------------------------------- /k8s/submission.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: submission 5 | labels: 6 | app: submission 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: submission 11 | replicas: 1 12 | template: 13 | metadata: 14 | labels: 15 | app: submission 16 | spec: 17 | containers: 18 | - image: assignments/submission 19 | name: submission 20 | ports: 21 | - containerPort: 29999 22 | args: ["--spring.config.location=application.properties"] 23 | imagePullPolicy: Never 24 | volumeMounts: 25 | - mountPath: /app/application.properties 26 | name: management-config 27 | subPath: application.properties 28 | volumes: 29 | - name: submission-config 30 | configMap: 31 | name: submission-config 32 | items: 33 | - key: application.properties 34 | path: application.properties 35 | --- 36 | apiVersion: v1 37 | kind: Service 38 | metadata: 39 | name: submission 40 | spec: 41 | ports: 42 | - port: 29999 43 | targetPort: 29999 44 | selector: 45 | app: submission 46 | --- 47 | apiVersion: v1 48 | kind: ConfigMap 49 | metadata: 50 | name: management-config 51 | data: 52 | application.properties: | 53 | spring.datasource.url=jdbc:mysql://submission-mysql:3306/submissions 54 | spring.datasource.username=root 55 | spring.datasource.password=root 56 | server.port=29999 57 | -------------------------------------------------------------------------------- /k8s/submission-mysql.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: submission-mysql 5 | spec: 6 | selector: 7 | app: submission-mysql 8 | ports: 9 | - port: 3306 10 | --- 11 | apiVersion: apps/v1 12 | kind: Deployment 13 | metadata: 14 | name: submission-mysql 15 | spec: 16 | selector: 17 | matchLabels: 18 | app: submission-mysql 19 | replicas: 1 20 | template: 21 | metadata: 22 | labels: 23 | app: submission-mysql 24 | spec: 25 | containers: 26 | - name: submission-mysql 27 | image: mysql:8 28 | imagePullPolicy: Never 29 | ports: 30 | - containerPort: 3306 31 | env: 32 | - name: MYSQL_ROOT_PASSWORD 33 | value: 'root' 34 | - name: MYSQL_DATABASE 35 | value: submissions 36 | volumeMounts: 37 | - name: mysql-initdb 38 | mountPath: /docker-entrypoint-initdb.d 39 | volumes: 40 | - name: mysql-initdb 41 | configMap: 42 | name: submission-initdb-config 43 | --- 44 | apiVersion: v1 45 | kind: ConfigMap 46 | metadata: 47 | name: submission-initdb-config 48 | data: 49 | initdb.sql: | 50 | CREATE TABLE submissions 51 | ( 52 | id VARCHAR(36) not null, 53 | code TEXT not null, 54 | assignment VARCHAR(36) NOT NULL, 55 | user VARCHAR(36) NOT NULL, 56 | datetime DATETIME NOT NULL, 57 | PRIMARY KEY (id) 58 | ); 59 | -------------------------------------------------------------------------------- /k8s/management-mysql.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: management-mysql 5 | spec: 6 | selector: 7 | app: management-mysql 8 | ports: 9 | - port: 3306 10 | --- 11 | apiVersion: apps/v1 12 | kind: Deployment 13 | metadata: 14 | name: management-mysql 15 | spec: 16 | selector: 17 | matchLabels: 18 | app: management-mysql 19 | replicas: 1 20 | template: 21 | metadata: 22 | labels: 23 | app: management-mysql 24 | spec: 25 | containers: 26 | - name: management-mysql 27 | image: mysql:8 28 | imagePullPolicy: Never 29 | ports: 30 | - containerPort: 3306 31 | env: 32 | - name: MYSQL_ROOT_PASSWORD 33 | value: 'root' 34 | - name: MYSQL_DATABASE 35 | value: assignments 36 | volumeMounts: 37 | - name: mysql-initdb 38 | mountPath: /docker-entrypoint-initdb.d 39 | volumes: 40 | - name: mysql-initdb 41 | configMap: 42 | name: management-initdb-config 43 | --- 44 | apiVersion: v1 45 | kind: ConfigMap 46 | metadata: 47 | name: management-initdb-config 48 | data: 49 | initdb.sql: | 50 | CREATE TABLE assignments 51 | ( 52 | id VARCHAR(36) not null, 53 | title VARCHAR(50) not null, 54 | description TEXT not null, 55 | deadline DATETIME not null, 56 | status int not null, 57 | PRIMARY KEY (id) 58 | ); 59 | -------------------------------------------------------------------------------- /k8s/gateway.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: gateway 5 | labels: 6 | app: gateway 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: gateway 11 | replicas: 1 12 | template: 13 | metadata: 14 | labels: 15 | app: gateway 16 | spec: 17 | containers: 18 | - name: gateway 19 | image: assignments/gateway 20 | imagePullPolicy: Never 21 | args: ["--spring.config.location=application.yaml"] 22 | ports: 23 | - containerPort: 39999 24 | volumeMounts: 25 | - mountPath: /app/application.yaml 26 | name: management-config 27 | subPath: application.yaml 28 | volumes: 29 | - name: management-config 30 | configMap: 31 | name: management-config 32 | items: 33 | - key: application.yaml 34 | path: application.yaml 35 | --- 36 | apiVersion: v1 37 | kind: Service 38 | metadata: 39 | name: gateway 40 | spec: 41 | type: NodePort 42 | ports: 43 | - port: 19999 44 | targetPort: 19999 45 | nodePort: 30000 46 | selector: 47 | app: gateway 48 | 49 | --- 50 | apiVersion: v1 51 | kind: ConfigMap 52 | metadata: 53 | name: gateway-config 54 | data: 55 | application.yaml: | 56 | spring: 57 | cloud: 58 | gateway: 59 | globalcors: 60 | cors-configurations: 61 | '[/**]': 62 | allowedOrigins: "*" 63 | allowedMethods: "*" 64 | allowedHeaders: "*" 65 | nacos: 66 | discovery: 67 | server-addr: nacos-server:8848 68 | server: 69 | port: 19999 70 | -------------------------------------------------------------------------------- /assignments-react-ui/src/NewAssignment.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import TextField from "@material-ui/core/TextField"; 3 | import Card from "@material-ui/core/Card"; 4 | import CardContent from "@material-ui/core/CardContent"; 5 | import Button from "@material-ui/core/Button"; 6 | 7 | function addAssignment(data) { 8 | data = { 9 | title: "string", 10 | description: "string", 11 | deadline: "2020-04-30 08:32:23" 12 | } 13 | 14 | return fetch('http://localhost:9999/api/assignments', { 15 | method: 'post', 16 | headers: { 17 | 'content-type': 'application/json' 18 | }, 19 | body: JSON.stringify(data) 20 | }) 21 | } 22 | 23 | export default function NewAssignment() { 24 | return ( 25 | 26 | 27 | 31 | 43 | 49 | 50 | 51 | 52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /assignments-submission/src/main/java/iteach/eaap/assignments/submission/application/CreateSubmissionApplicationService.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.submission.application; 2 | 3 | import iteach.eaap.assignments.submission.application.port.outbound.CreateSubmissionRepository; 4 | import org.springframework.cloud.client.ServiceInstance; 5 | import org.springframework.cloud.client.discovery.DiscoveryClient; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | import iteach.eaap.assignments.submission.application.port.inbound.CreateSubmissionUseCase; 11 | import iteach.eaap.assignments.submission.domain.Submission; 12 | import iteach.eaap.assignments.submission.domain.SubmissionException; 13 | import lombok.AllArgsConstructor; 14 | 15 | import java.time.LocalDateTime; 16 | import java.util.UUID; 17 | 18 | @Service 19 | @Transactional 20 | @AllArgsConstructor 21 | class CreateSubmissionApplicationService implements CreateSubmissionUseCase { 22 | private final RestTemplate restTemplate; 23 | private final CreateSubmissionRepository repository; 24 | 25 | @Override 26 | public void createSubmission(Submission submission) { 27 | String url = "http://assignments-management/assignments/" + submission.getAssignment() + "/status"; 28 | String status = restTemplate.getForObject(url, String.class); 29 | 30 | assert status != null; 31 | if(!status.equalsIgnoreCase("published")) { 32 | throw new SubmissionException("提交失败"); 33 | } 34 | 35 | String userId = "1"; 36 | submission.setId(UUID.randomUUID().toString()); 37 | submission.setUser(userId); 38 | submission.setDatetime(LocalDateTime.now()); 39 | repository.addSubmission(submission); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | gateway-service: 5 | build: ../assignments-gateway/docker 6 | image: 'assignments/gateway' 7 | container_name: gateway-service 8 | ports: 9 | - 19999:19999 10 | depends_on: 11 | - submission-service 12 | - management-service 13 | management-service: 14 | build: ../assignments-management/docker 15 | image: 'assignments/management' 16 | container_name: management-service 17 | depends_on: 18 | - management-mysql 19 | management-service02: 20 | build: ../assignments-management/docker 21 | image: 'assignments/management' 22 | container_name: management-service02 23 | depends_on: 24 | - management-mysql 25 | management-mysql: 26 | image: 'mysql:8' 27 | container_name: management-mysql 28 | environment: 29 | MYSQL_ROOT_PASSWORD: 'root' 30 | MYSQL_DATABASE: assignments 31 | volumes: 32 | - ../assignments-management/docker/schema:/docker-entrypoint-initdb.d 33 | submission-service: 34 | build: ../assignments-submission/docker 35 | image: 'assignments/submission' 36 | container_name: submission-service 37 | depends_on: 38 | - submission-mysql 39 | submission-mysql: 40 | image: 'mysql:8' 41 | container_name: submission-mysql 42 | environment: 43 | MYSQL_ROOT_PASSWORD: 'root' 44 | MYSQL_DATABASE: submissions 45 | volumes: 46 | - ../assignments-submission/docker/schema:/docker-entrypoint-initdb.d 47 | assignments-ui: 48 | build: ../assignments-react-ui/docker 49 | image: 'assignments/react-ui' 50 | container_name: react-ui 51 | depends_on: 52 | - gateway-service 53 | ports: 54 | - 80:80 55 | 56 | networks: 57 | default: 58 | external: 59 | name: assignments 60 | 61 | -------------------------------------------------------------------------------- /assignments-gateway/src/main/java/iteach/eaap/assignments/apigateway/AssignmentGatewayConfiguration.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.apigateway; 2 | 3 | import org.springframework.cloud.gateway.route.RouteLocator; 4 | import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.HttpMethod; 8 | import org.springframework.web.reactive.function.server.RouterFunction; 9 | import org.springframework.web.reactive.function.server.RouterFunctions; 10 | import org.springframework.web.reactive.function.server.ServerResponse; 11 | 12 | import static org.springframework.web.reactive.function.server.RequestPredicates.GET; 13 | 14 | @Configuration 15 | public class AssignmentGatewayConfiguration { 16 | @Bean 17 | public RouteLocator routes(RouteLocatorBuilder builder) { 18 | return builder.routes() 19 | .route("assignment management service", predicate -> predicate 20 | .path("/api/assignments", "/api/assignments/**") 21 | .filters(filter -> filter.stripPrefix(1)) 22 | .uri("http://management:39999")) 23 | .route("assignment submission service", predicate -> predicate 24 | .path("/api/submissions").and() 25 | .method(HttpMethod.POST) 26 | .filters(filter -> filter.stripPrefix(1)) 27 | .uri("http://submission:29999")) 28 | .build(); 29 | } 30 | 31 | @Bean 32 | public RouterFunction orderHandlerRouting(SubmissionHandler handler) { 33 | return RouterFunctions.route(GET("/api/submissions"), handler::getSubmissions); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/domain/Assignment.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.domain; 2 | 3 | import iteach.eaap.assignments.management.adapter.inbound.AssignmentDTO; 4 | 5 | import javax.persistence.Embedded; 6 | import javax.persistence.EmbeddedId; 7 | import javax.persistence.Entity; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name = "assignments") 12 | public class Assignment { 13 | @EmbeddedId 14 | private AssignmentId id; 15 | private String title; 16 | private String description; 17 | @Embedded 18 | private Deadline deadline; 19 | private Status status; 20 | 21 | // JPA 22 | public Assignment() { 23 | 24 | } 25 | 26 | // Builder, Factory 创建型模式 27 | public Assignment(String title, String description, Deadline deadline) { 28 | this.id = new AssignmentId(); 29 | this.title = title; 30 | this.deadline = deadline; 31 | this.description = description; 32 | this.status = Status.CREATED; 33 | } 34 | 35 | // 迎合显示用的 36 | public AssignmentDTO makeAssignmentDTO() { 37 | AssignmentDTO dto = new AssignmentDTO(); 38 | dto.setTitle(this.title); 39 | dto.setDeadline(deadline.value()); 40 | dto.setDescription(this.description); 41 | dto.setId(id.value()); 42 | dto.setStatus(status.name()); 43 | return dto; 44 | } 45 | 46 | public void close() { 47 | status = status.changeTo(Status.CLOSED); 48 | } 49 | 50 | public void publish() { 51 | status = status.changeTo(Status.PUBLISHED); 52 | } 53 | 54 | public void remove() { 55 | status = status.changeTo(Status.REMOVED); 56 | } 57 | 58 | public Status status() { 59 | if(deadline.isExpired()) { 60 | status = status.changeTo(Status.EXPIRED); 61 | } 62 | 63 | return status; 64 | } 65 | 66 | public void changeStatus(Status newStatus) { 67 | this.status = this.status.changeTo(newStatus); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /assignments-gateway/src/main/java/iteach/eaap/assignments/apigateway/SubmissionHandler.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.apigateway; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.web.reactive.function.BodyInserters; 6 | import org.springframework.web.reactive.function.client.WebClient; 7 | import org.springframework.web.reactive.function.server.ServerRequest; 8 | import org.springframework.web.reactive.function.server.ServerResponse; 9 | import reactor.core.publisher.Flux; 10 | import reactor.core.publisher.Mono; 11 | 12 | @Service 13 | public class SubmissionHandler { 14 | // 当学生获取自己的作业信息时,需要查看作业是否提交,以及作业的基本信息 15 | // 由于使用了反应式异步编程,可同时获取多项数据 16 | public Mono getSubmissions(ServerRequest serverRequest) { 17 | Flux submissions = WebClient.create().get() 18 | .uri("http://submission-service:29999/submissions") 19 | .exchange() 20 | .flatMapMany(resp -> resp.bodyToFlux(Submission.class)); 21 | Flux assignments = WebClient.create().get() 22 | .uri("http://management-service:39999/assignments") 23 | .exchange() 24 | .flatMapMany(resp -> resp.bodyToFlux(Assignment.class)); 25 | submissions = submissions.map(submission -> { 26 | if (submission.getAssignmentId() == null) { 27 | return submission; 28 | } 29 | Assignment assignment = assignments 30 | .filter(a -> a.getId().equals(submission.getAssignmentId())) 31 | .blockFirst(); 32 | submission.setAssignment(assignment); 33 | return submission; 34 | }); 35 | 36 | return ServerResponse.ok() 37 | .contentType(MediaType.APPLICATION_JSON) 38 | .body(BodyInserters.fromPublisher(submissions, Submission.class)); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /docker/deploy-assignments.ps1: -------------------------------------------------------------------------------- 1 | $WorkspaceDir = Resolve-Path -Path .. 2 | $ManagementProjectDir = Join-Path $WorkspaceDir 'assignments-management' 3 | $SubmissionProjectDir = Join-Path $WorkspaceDir 'assignments-submission' 4 | $ReactUiProjctDir = Join-Path $WorkspaceDir 'assignments-react-ui' 5 | $GatewayProjectDir = Join-Path $WorkspaceDir 'assignments-gateway' 6 | 7 | function Build-Project 8 | { 9 | [CmdletBinding()] 10 | param ( 11 | [Parameter(Mandatory)] 12 | [string] $Project, 13 | 14 | [Parameter()] 15 | [ValidateSet('maven', 'node')] 16 | [string] $Type = 'maven' 17 | ) 18 | 19 | $ProjectName = Split-Path -Path $Project -Leaf 20 | Write-Host "building project $ProjectName ..." 21 | 22 | Set-Location $Project 23 | switch ($Type) 24 | { 25 | 'maven' { 26 | if (Test-Path -Path .\target -PathType Container) 27 | { 28 | Remove-Item -Path .\target -Force -Recurse 29 | } 30 | 31 | try 32 | { 33 | mvn clean package -DskipTests 34 | } 35 | catch 36 | { 37 | Write-Host $Error 38 | } 39 | 40 | if (Test-Path -Path .\docker\app.jar) 41 | { 42 | Remove-Item -Path .\docker\app.jar 43 | } 44 | 45 | Move-Item -Path .\target\*.jar -Destination .\docker\app.jar 46 | } 47 | 'node' { 48 | if (Test-Path -Path .\build -PathType Container) 49 | { 50 | Remove-Item -Path .\build -Force -Recurse 51 | } 52 | 53 | try 54 | { 55 | npm run build 56 | } 57 | catch 58 | { 59 | Write-Host $Error 60 | } 61 | 62 | if (Test-Path -Path .\docker\build -PathType Container) 63 | { 64 | Remove-Item -Path .\docker\build -Force -Recurse 65 | } 66 | 67 | Move-Item -Path build -Destination .\docker\build 68 | } 69 | Default { 70 | throw 'invalid project type' 71 | } 72 | } 73 | 74 | } 75 | 76 | Build-Project -Project $ManagementProjectDir -Type 'maven' 77 | Build-Project -Project $SubmissionProjectDir -Type 'maven' 78 | Build-Project -Project $GatewayProjectDir -Type 'maven' 79 | Build-Project -Project $ReactUiProjctDir -Type 'node' 80 | 81 | Set-Location "$WorkspaceDir/docker" 82 | 83 | docker-compose up --build -d 84 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/adapter/inbound/AssignmentController.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.adapter.inbound; 2 | 3 | import iteach.eaap.assignments.management.application.port.inbound.AssignmentUseCase; 4 | import lombok.AllArgsConstructor; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.validation.Errors; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.validation.Valid; 13 | import java.util.List; 14 | 15 | @RestController 16 | @AllArgsConstructor 17 | class AssignmentController { 18 | private final AssignmentUseCase usecase; 19 | 20 | // DTO(Data Transfer Object) 模式 21 | @PostMapping("/assignments") 22 | public ResponseEntity newAssignment( 23 | @RequestBody AssignmentDTO assignment, 24 | @Valid Errors errors) { 25 | if(errors.hasErrors()) { 26 | return ResponseEntity.badRequest().body(errors); 27 | } 28 | return ResponseEntity.status(HttpStatus.CREATED) 29 | .body(usecase.createAssignment(assignment)); 30 | } 31 | 32 | @GetMapping("/assignments") 33 | List getAllAssignments() { 34 | return usecase.getAllAssignments(); 35 | } 36 | 37 | @GetMapping("/assignments/{id}") 38 | AssignmentDTO getAssignment(@PathVariable String id) { 39 | return usecase.getAssignment(id); 40 | } 41 | 42 | @PutMapping("/assignments/publish/{id}") 43 | void publishAssignment(@PathVariable String id) { 44 | usecase.publishAssignments(id); 45 | } 46 | 47 | @PutMapping("/assignments/close/{id}") 48 | void closeAssignment(@PathVariable String id) { 49 | usecase.closeAssignment(id); 50 | } 51 | 52 | @DeleteMapping("/assignments/close/{id}") 53 | void removeAssignment(@PathVariable String id) { 54 | usecase.removeAssignment(id); 55 | } 56 | 57 | @GetMapping("/assignments/{id}/status") 58 | String getAssignmentStatus(@PathVariable String id, 59 | HttpServletRequest request) { 60 | System.out.println(request.getServerPort()); 61 | return usecase.statusOf(id); 62 | } 63 | 64 | @GetMapping("/dburl") 65 | String getMysqlUrl(@Value("${spring.datasource.url}") String url) { 66 | return url; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /assignments-management/src/main/java/iteach/eaap/assignments/management/application/AssignmentApplicationService.java: -------------------------------------------------------------------------------- 1 | package iteach.eaap.assignments.management.application; 2 | 3 | import iteach.eaap.assignments.management.adapter.inbound.AssignmentDTO; 4 | import iteach.eaap.assignments.management.application.port.inbound.AssignmentUseCase; 5 | import iteach.eaap.assignments.management.application.port.outbound.AssignmentRepository; 6 | import iteach.eaap.assignments.management.domain.*; 7 | import lombok.AllArgsConstructor; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.util.List; 12 | import java.util.stream.Collectors; 13 | 14 | @Service 15 | @Transactional 16 | @AllArgsConstructor 17 | class AssignmentApplicationService implements AssignmentUseCase { 18 | private final AssignmentRepository repository; 19 | 20 | @Override 21 | public String createAssignment(AssignmentDTO assignment) { 22 | String title = assignment.getTitle(); 23 | String description = assignment.getDescription(); 24 | Deadline deadline = new Deadline(assignment.getDeadline()); 25 | 26 | Assignment entity = new Assignment(title, description, deadline); 27 | repository.add(entity); 28 | return entity.makeAssignmentDTO().getId(); 29 | } 30 | 31 | @Override 32 | public List getAllAssignments() { 33 | return repository.queryAll().stream() 34 | .map(Assignment::makeAssignmentDTO) 35 | .collect(Collectors.toList()); 36 | } 37 | 38 | private Assignment assignmentFor(String id) { 39 | Assignment assignment = repository.queryById(AssignmentId.of(id)); 40 | 41 | if(assignment == null) { 42 | throw new AssignmentException("没有找到指定 id 的作业:" + id); 43 | } 44 | 45 | return assignment; 46 | } 47 | 48 | @Override 49 | public void publishAssignments(String id) { 50 | Assignment assignment = assignmentFor(id); 51 | assignment.changeStatus(Status.PUBLISHED); 52 | repository.update(assignment); 53 | } 54 | 55 | @Override 56 | public void closeAssignment(String id) { 57 | Assignment assignment = assignmentFor(id); 58 | assignment.changeStatus(Status.CLOSED); 59 | repository.update(assignment); 60 | } 61 | 62 | @Override 63 | public void removeAssignment(String id) { 64 | Assignment assignment = assignmentFor(id); 65 | assignment.changeStatus(Status.REMOVED); 66 | repository.update(assignment); 67 | } 68 | 69 | @Override 70 | public String statusOf(String id) { 71 | return assignmentFor(id).status().toString(); 72 | } 73 | 74 | @Override 75 | public AssignmentDTO getAssignment(String id) { 76 | Assignment assignment = assignmentFor(id); 77 | return assignment.makeAssignmentDTO(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /assignments-react-ui/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
    10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
    13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
    18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
    23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
    26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `yarn build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /assignments-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | iteach.eaap.assignments 12 | assignments-gateway 13 | 0.1 14 | assignments-gateway 15 | API 网关服务 16 | 17 | 18 | 1.8 19 | Hoxton.SR3 20 | 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-gateway 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-test 44 | test 45 | 46 | 47 | org.junit.vintage 48 | junit-vintage-engine 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.cloud 58 | spring-cloud-dependencies 59 | ${spring-cloud.version} 60 | pom 61 | import 62 | 63 | 64 | com.alibaba.cloud 65 | spring-cloud-alibaba-dependencies 66 | 2.2.0.RELEASE 67 | pom 68 | import 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | 82 | 83 | 84 | maven-ali 85 | http://maven.aliyun.com/nexus/content/groups/public// 86 | 87 | true 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /assignments-management/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | iteach.eaap.assignments 12 | assignments-management 13 | 0.0.1 14 | assignments-management 15 | 作业管理服务 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | mysql 33 | mysql-connector-java 34 | runtime 35 | 36 | 37 | org.projectlombok 38 | lombok 39 | true 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | org.junit.vintage 58 | junit-vintage-engine 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-maven-plugin 69 | 70 | 71 | 72 | 73 | 74 | 75 | maven-ali 76 | http://maven.aliyun.com/nexus/content/groups/public// 77 | 78 | true 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | com.alibaba.cloud 87 | spring-cloud-alibaba-dependencies 88 | 2.2.0.RELEASE 89 | pom 90 | import 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /assignments-submission/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | iteach.eaap.assignments 12 | assignments-submission 13 | 0.0.1 14 | assignments-submission 15 | 作业提交服务 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | mysql 33 | mysql-connector-java 34 | runtime 35 | 36 | 37 | org.projectlombok 38 | lombok 39 | true 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-test 58 | test 59 | 60 | 61 | org.junit.vintage 62 | junit-vintage-engine 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | 77 | 78 | 79 | maven-ali 80 | http://maven.aliyun.com/nexus/content/groups/public// 81 | 82 | true 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /assignments-gateway/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /assignments-management/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /assignments-submission/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /assignments-react-ui/src/Assignments.js: -------------------------------------------------------------------------------- 1 | import React, {useEffect, useState} from 'react'; 2 | import Link from '@material-ui/core/Link'; 3 | import {makeStyles} from '@material-ui/core/styles'; 4 | import Table from '@material-ui/core/Table'; 5 | import TableBody from '@material-ui/core/TableBody'; 6 | import TableCell from '@material-ui/core/TableCell'; 7 | import TableHead from '@material-ui/core/TableHead'; 8 | import TableRow from '@material-ui/core/TableRow'; 9 | import Checkbox from "@material-ui/core/Checkbox"; 10 | import Paper from "@material-ui/core/Paper"; 11 | import InputBase from "@material-ui/core/InputBase"; 12 | import IconButton from "@material-ui/core/IconButton"; 13 | import SearchIcon from "@material-ui/icons/Search"; 14 | import Button from "@material-ui/core/Button"; 15 | import Grid from "@material-ui/core/Grid"; 16 | import ButtonGroup from "@material-ui/core/ButtonGroup"; 17 | import {Link as RouteLink} from 'react-router-dom' 18 | import Snackbar from "@material-ui/core/Snackbar"; 19 | import MuiAlert from '@material-ui/lab/Alert'; 20 | 21 | const useStyles = makeStyles((theme) => ({ 22 | seeMore: { 23 | marginTop: theme.spacing(3), 24 | }, 25 | search: { 26 | padding: '2px 4px', 27 | display: 'flex', 28 | alignItems: 'center', 29 | width: 400, 30 | }, 31 | toolbar: { 32 | display: 'flex', 33 | // flexDirection: 'column' 34 | }, 35 | input: { 36 | marginLeft: theme.spacing(1), 37 | flex: 1 38 | }, 39 | table: { 40 | marginTop: theme.spacing(1) 41 | }, 42 | checkbox: { 43 | width: 60 44 | } 45 | })); 46 | 47 | function Alert(props) { 48 | return ; 49 | } 50 | 51 | export default function Assignments() { 52 | const classes = useStyles(); 53 | const [snack, setSnack] = useState({open: false, message: ''}) 54 | 55 | const formatStatus = function (key) { 56 | const status = {created: '已创建', published: '已发布', removed: '已删除', closed: '已关闭', expired: '已过期'} 57 | return status[key.toLowerCase()]; 58 | } 59 | 60 | const publish = function (assignment) { 61 | fetch(`http://localhost:19999/api/assignments/publish/${assignment.id}`, { 62 | method: 'put' 63 | }).then(response => { 64 | setSnack({...snack, open: true, level: 'success', message: '发布成功'}) 65 | }) 66 | .catch(error => { 67 | setSnack({...snack, level: 'error', open: true, message: '发布失败'}) 68 | }) 69 | } 70 | 71 | const [assignments, setAssignments] = useState([]); 72 | 73 | useEffect(() => { 74 | const fetchData = async () => { 75 | const response = await fetch("http://localhost:19999/api/assignments"); 76 | const assignments = await response.json(); 77 | setAssignments(assignments); 78 | } 79 | 80 | fetchData() 81 | }, [snack]) 82 | 83 | return ( 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 标题 106 | 截止日期 107 | 状态 108 | 是否提交 109 | 操作 110 | 111 | 112 | 113 | {assignments.map((assignment) => ( 114 | 115 | 116 | 117 | 118 | 119 | 120 | {assignment.title} 121 | 122 | 123 | {assignment.deadline} 124 | {formatStatus(assignment.status)} 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | ))} 137 | 138 |
    139 |
    140 | setSnack({...snack, open: false})} 142 | autoHideDuration={3000} 143 | open={snack.open}> 144 | setSnack({...snack, open: false})}> 145 | {snack.message} 146 | 147 | 148 |
    149 | ); 150 | } 151 | -------------------------------------------------------------------------------- /assignments-react-ui/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import clsx from 'clsx'; 3 | import {makeStyles} from '@material-ui/core/styles'; 4 | import CssBaseline from '@material-ui/core/CssBaseline'; 5 | import Drawer from '@material-ui/core/Drawer'; 6 | import AppBar from '@material-ui/core/AppBar'; 7 | import Toolbar from '@material-ui/core/Toolbar'; 8 | import List from '@material-ui/core/List'; 9 | import Typography from '@material-ui/core/Typography'; 10 | import Divider from '@material-ui/core/Divider'; 11 | import IconButton from '@material-ui/core/IconButton'; 12 | import Badge from '@material-ui/core/Badge'; 13 | import Container from '@material-ui/core/Container'; 14 | import Grid from '@material-ui/core/Grid'; 15 | import MenuIcon from '@material-ui/icons/Menu'; 16 | import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; 17 | import NotificationsIcon from '@material-ui/icons/Notifications'; 18 | import {mainListItems} from './listItems'; 19 | import Assignments from './Assignments'; 20 | import NewAssignment from './NewAssignment' 21 | import {HashRouter as Router, Route, Redirect, Switch} from "react-router-dom"; 22 | 23 | const drawerWidth = 240; 24 | 25 | const useStyles = makeStyles((theme) => ({ 26 | root: { 27 | display: 'flex', 28 | }, 29 | toolbar: { 30 | paddingRight: 24, // keep right padding when drawer closed 31 | }, 32 | toolbarIcon: { 33 | display: 'flex', 34 | alignItems: 'center', 35 | justifyContent: 'flex-end', 36 | padding: '0 8px', 37 | ...theme.mixins.toolbar, 38 | }, 39 | appBar: { 40 | zIndex: theme.zIndex.drawer + 1, 41 | transition: theme.transitions.create(['width', 'margin'], { 42 | easing: theme.transitions.easing.sharp, 43 | duration: theme.transitions.duration.leavingScreen, 44 | }), 45 | }, 46 | appBarShift: { 47 | marginLeft: drawerWidth, 48 | width: `calc(100% - ${drawerWidth}px)`, 49 | transition: theme.transitions.create(['width', 'margin'], { 50 | easing: theme.transitions.easing.sharp, 51 | duration: theme.transitions.duration.enteringScreen, 52 | }), 53 | }, 54 | menuButton: { 55 | marginRight: 36, 56 | }, 57 | menuButtonHidden: { 58 | display: 'none', 59 | }, 60 | title: { 61 | flexGrow: 1, 62 | }, 63 | drawerPaper: { 64 | position: 'relative', 65 | whiteSpace: 'nowrap', 66 | width: drawerWidth, 67 | transition: theme.transitions.create('width', { 68 | easing: theme.transitions.easing.sharp, 69 | duration: theme.transitions.duration.enteringScreen, 70 | }), 71 | }, 72 | drawerPaperClose: { 73 | overflowX: 'hidden', 74 | transition: theme.transitions.create('width', { 75 | easing: theme.transitions.easing.sharp, 76 | duration: theme.transitions.duration.leavingScreen, 77 | }), 78 | width: theme.spacing(7), 79 | [theme.breakpoints.up('sm')]: { 80 | width: theme.spacing(9), 81 | }, 82 | }, 83 | appBarSpacer: theme.mixins.toolbar, 84 | content: { 85 | flexGrow: 1, 86 | height: '100vh', 87 | overflow: 'auto', 88 | }, 89 | container: { 90 | paddingTop: theme.spacing(4), 91 | paddingBottom: theme.spacing(4), 92 | }, 93 | paper: { 94 | padding: theme.spacing(2), 95 | display: 'flex', 96 | overflow: 'auto', 97 | flexDirection: 'column', 98 | }, 99 | fixedHeight: { 100 | height: 240, 101 | }, 102 | })); 103 | 104 | export default function App() { 105 | const classes = useStyles(); 106 | const [open, setOpen] = React.useState(true); 107 | const handleDrawerOpen = () => { 108 | setOpen(true); 109 | }; 110 | const handleDrawerClose = () => { 111 | setOpen(false); 112 | }; 113 | 114 | return ( 115 | 116 |
    117 | 118 | 119 | 120 | 127 | 128 | 129 | 130 | 作业提交系统 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 146 |
    147 | 148 | 149 | 150 |
    151 | 152 | {mainListItems} 153 |
    154 |
    155 |
    156 | 157 | 158 | 159 | 160 | 161 | 162 | ( 163 | 164 | )}/> 165 | 166 | 167 | 168 | 169 |
    170 |
    171 |
    172 | ); 173 | } 174 | -------------------------------------------------------------------------------- /assignments-management/docker/wait-for-it.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Use this script to test if a given TCP host/port are available 3 | 4 | WAITFORIT_cmdname=${0##*/} 5 | 6 | echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } 7 | 8 | usage() 9 | { 10 | cat << USAGE >&2 11 | Usage: 12 | $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] 13 | -h HOST | --host=HOST Host or IP under test 14 | -p PORT | --port=PORT TCP port under test 15 | Alternatively, you specify the host and port as host:port 16 | -s | --strict Only execute subcommand if the test succeeds 17 | -q | --quiet Don't output any status messages 18 | -t TIMEOUT | --timeout=TIMEOUT 19 | Timeout in seconds, zero for no timeout 20 | -- COMMAND ARGS Execute command with args after the test finishes 21 | USAGE 22 | exit 1 23 | } 24 | 25 | wait_for() 26 | { 27 | if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then 28 | echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" 29 | else 30 | echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" 31 | fi 32 | WAITFORIT_start_ts=$(date +%s) 33 | while : 34 | do 35 | if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then 36 | nc -z $WAITFORIT_HOST $WAITFORIT_PORT 37 | WAITFORIT_result=$? 38 | else 39 | (echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 40 | WAITFORIT_result=$? 41 | fi 42 | if [[ $WAITFORIT_result -eq 0 ]]; then 43 | WAITFORIT_end_ts=$(date +%s) 44 | echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" 45 | break 46 | fi 47 | sleep 1 48 | done 49 | return $WAITFORIT_result 50 | } 51 | 52 | wait_for_wrapper() 53 | { 54 | # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 55 | if [[ $WAITFORIT_QUIET -eq 1 ]]; then 56 | timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & 57 | else 58 | timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & 59 | fi 60 | WAITFORIT_PID=$! 61 | trap "kill -INT -$WAITFORIT_PID" INT 62 | wait $WAITFORIT_PID 63 | WAITFORIT_RESULT=$? 64 | if [[ $WAITFORIT_RESULT -ne 0 ]]; then 65 | echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" 66 | fi 67 | return $WAITFORIT_RESULT 68 | } 69 | 70 | # process arguments 71 | while [[ $# -gt 0 ]] 72 | do 73 | case "$1" in 74 | *:* ) 75 | WAITFORIT_hostport=(${1//:/ }) 76 | WAITFORIT_HOST=${WAITFORIT_hostport[0]} 77 | WAITFORIT_PORT=${WAITFORIT_hostport[1]} 78 | shift 1 79 | ;; 80 | --child) 81 | WAITFORIT_CHILD=1 82 | shift 1 83 | ;; 84 | -q | --quiet) 85 | WAITFORIT_QUIET=1 86 | shift 1 87 | ;; 88 | -s | --strict) 89 | WAITFORIT_STRICT=1 90 | shift 1 91 | ;; 92 | -h) 93 | WAITFORIT_HOST="$2" 94 | if [[ $WAITFORIT_HOST == "" ]]; then break; fi 95 | shift 2 96 | ;; 97 | --host=*) 98 | WAITFORIT_HOST="${1#*=}" 99 | shift 1 100 | ;; 101 | -p) 102 | WAITFORIT_PORT="$2" 103 | if [[ $WAITFORIT_PORT == "" ]]; then break; fi 104 | shift 2 105 | ;; 106 | --port=*) 107 | WAITFORIT_PORT="${1#*=}" 108 | shift 1 109 | ;; 110 | -t) 111 | WAITFORIT_TIMEOUT="$2" 112 | if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi 113 | shift 2 114 | ;; 115 | --timeout=*) 116 | WAITFORIT_TIMEOUT="${1#*=}" 117 | shift 1 118 | ;; 119 | --) 120 | shift 121 | WAITFORIT_CLI=("$@") 122 | break 123 | ;; 124 | --help) 125 | usage 126 | ;; 127 | *) 128 | echoerr "Unknown argument: $1" 129 | usage 130 | ;; 131 | esac 132 | done 133 | 134 | if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then 135 | echoerr "Error: you need to provide a host and port to test." 136 | usage 137 | fi 138 | 139 | WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} 140 | WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} 141 | WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} 142 | WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} 143 | 144 | # Check to see if timeout is from busybox? 145 | WAITFORIT_TIMEOUT_PATH=$(type -p timeout) 146 | WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) 147 | 148 | WAITFORIT_BUSYTIMEFLAG="" 149 | if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then 150 | WAITFORIT_ISBUSY=1 151 | # Check if busybox timeout uses -t flag 152 | # (recent Alpine versions don't support -t anymore) 153 | if timeout &>/dev/stdout | grep -q -e '-t '; then 154 | WAITFORIT_BUSYTIMEFLAG="-t" 155 | fi 156 | else 157 | WAITFORIT_ISBUSY=0 158 | fi 159 | 160 | if [[ $WAITFORIT_CHILD -gt 0 ]]; then 161 | wait_for 162 | WAITFORIT_RESULT=$? 163 | exit $WAITFORIT_RESULT 164 | else 165 | if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then 166 | wait_for_wrapper 167 | WAITFORIT_RESULT=$? 168 | else 169 | wait_for 170 | WAITFORIT_RESULT=$? 171 | fi 172 | fi 173 | 174 | if [[ $WAITFORIT_CLI != "" ]]; then 175 | if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then 176 | echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" 177 | exit $WAITFORIT_RESULT 178 | fi 179 | exec "${WAITFORIT_CLI[@]}" 180 | else 181 | exit $WAITFORIT_RESULT 182 | fi 183 | -------------------------------------------------------------------------------- /assignments-submission/docker/wait-for-it.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Use this script to test if a given TCP host/port are available 3 | 4 | WAITFORIT_cmdname=${0##*/} 5 | 6 | echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } 7 | 8 | usage() 9 | { 10 | cat << USAGE >&2 11 | Usage: 12 | $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] 13 | -h HOST | --host=HOST Host or IP under test 14 | -p PORT | --port=PORT TCP port under test 15 | Alternatively, you specify the host and port as host:port 16 | -s | --strict Only execute subcommand if the test succeeds 17 | -q | --quiet Don't output any status messages 18 | -t TIMEOUT | --timeout=TIMEOUT 19 | Timeout in seconds, zero for no timeout 20 | -- COMMAND ARGS Execute command with args after the test finishes 21 | USAGE 22 | exit 1 23 | } 24 | 25 | wait_for() 26 | { 27 | if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then 28 | echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" 29 | else 30 | echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" 31 | fi 32 | WAITFORIT_start_ts=$(date +%s) 33 | while : 34 | do 35 | if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then 36 | nc -z $WAITFORIT_HOST $WAITFORIT_PORT 37 | WAITFORIT_result=$? 38 | else 39 | (echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 40 | WAITFORIT_result=$? 41 | fi 42 | if [[ $WAITFORIT_result -eq 0 ]]; then 43 | WAITFORIT_end_ts=$(date +%s) 44 | echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" 45 | break 46 | fi 47 | sleep 1 48 | done 49 | return $WAITFORIT_result 50 | } 51 | 52 | wait_for_wrapper() 53 | { 54 | # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 55 | if [[ $WAITFORIT_QUIET -eq 1 ]]; then 56 | timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & 57 | else 58 | timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & 59 | fi 60 | WAITFORIT_PID=$! 61 | trap "kill -INT -$WAITFORIT_PID" INT 62 | wait $WAITFORIT_PID 63 | WAITFORIT_RESULT=$? 64 | if [[ $WAITFORIT_RESULT -ne 0 ]]; then 65 | echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" 66 | fi 67 | return $WAITFORIT_RESULT 68 | } 69 | 70 | # process arguments 71 | while [[ $# -gt 0 ]] 72 | do 73 | case "$1" in 74 | *:* ) 75 | WAITFORIT_hostport=(${1//:/ }) 76 | WAITFORIT_HOST=${WAITFORIT_hostport[0]} 77 | WAITFORIT_PORT=${WAITFORIT_hostport[1]} 78 | shift 1 79 | ;; 80 | --child) 81 | WAITFORIT_CHILD=1 82 | shift 1 83 | ;; 84 | -q | --quiet) 85 | WAITFORIT_QUIET=1 86 | shift 1 87 | ;; 88 | -s | --strict) 89 | WAITFORIT_STRICT=1 90 | shift 1 91 | ;; 92 | -h) 93 | WAITFORIT_HOST="$2" 94 | if [[ $WAITFORIT_HOST == "" ]]; then break; fi 95 | shift 2 96 | ;; 97 | --host=*) 98 | WAITFORIT_HOST="${1#*=}" 99 | shift 1 100 | ;; 101 | -p) 102 | WAITFORIT_PORT="$2" 103 | if [[ $WAITFORIT_PORT == "" ]]; then break; fi 104 | shift 2 105 | ;; 106 | --port=*) 107 | WAITFORIT_PORT="${1#*=}" 108 | shift 1 109 | ;; 110 | -t) 111 | WAITFORIT_TIMEOUT="$2" 112 | if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi 113 | shift 2 114 | ;; 115 | --timeout=*) 116 | WAITFORIT_TIMEOUT="${1#*=}" 117 | shift 1 118 | ;; 119 | --) 120 | shift 121 | WAITFORIT_CLI=("$@") 122 | break 123 | ;; 124 | --help) 125 | usage 126 | ;; 127 | *) 128 | echoerr "Unknown argument: $1" 129 | usage 130 | ;; 131 | esac 132 | done 133 | 134 | if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then 135 | echoerr "Error: you need to provide a host and port to test." 136 | usage 137 | fi 138 | 139 | WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} 140 | WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} 141 | WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} 142 | WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} 143 | 144 | # Check to see if timeout is from busybox? 145 | WAITFORIT_TIMEOUT_PATH=$(type -p timeout) 146 | WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) 147 | 148 | WAITFORIT_BUSYTIMEFLAG="" 149 | if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then 150 | WAITFORIT_ISBUSY=1 151 | # Check if busybox timeout uses -t flag 152 | # (recent Alpine versions don't support -t anymore) 153 | if timeout &>/dev/stdout | grep -q -e '-t '; then 154 | WAITFORIT_BUSYTIMEFLAG="-t" 155 | fi 156 | else 157 | WAITFORIT_ISBUSY=0 158 | fi 159 | 160 | if [[ $WAITFORIT_CHILD -gt 0 ]]; then 161 | wait_for 162 | WAITFORIT_RESULT=$? 163 | exit $WAITFORIT_RESULT 164 | else 165 | if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then 166 | wait_for_wrapper 167 | WAITFORIT_RESULT=$? 168 | else 169 | wait_for 170 | WAITFORIT_RESULT=$? 171 | fi 172 | fi 173 | 174 | if [[ $WAITFORIT_CLI != "" ]]; then 175 | if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then 176 | echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" 177 | exit $WAITFORIT_RESULT 178 | fi 179 | exec "${WAITFORIT_CLI[@]}" 180 | else 181 | exit $WAITFORIT_RESULT 182 | fi 183 | -------------------------------------------------------------------------------- /assignments-gateway/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /assignments-management/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /assignments-submission/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /assignments-gateway/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /assignments-management/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /assignments-submission/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | --------------------------------------------------------------------------------