Skip to content

Commit

Permalink
prepare for v3
Browse files Browse the repository at this point in the history
  • Loading branch information
kashike committed May 26, 2024
1 parent 57207ca commit f611897
Show file tree
Hide file tree
Showing 50 changed files with 1,251 additions and 479 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ jib {
dependencies {
annotationProcessor("org.springframework.boot", "spring-boot-configuration-processor")
checkstyle(libs.stylecheck)
compileOnlyApi(libs.jspecify)
implementation(libs.jetbrains.annotations)
implementation(libs.springdoc.openapi.starter.webmvc.ui)
implementation("org.springframework.boot", "spring-boot-starter-data-mongodb")
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spring-boot = { id = "org.springframework.boot", version = "3.2.5" }
spring-dependency-management = { id = "io.spring.dependency-management", version = "1.1.5" }

[libraries]
jspecify = { module = "org.jspecify:jspecify", version = "0.3.0" }
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version = "24.1.0" }
springdoc-openapi-starter-webmvc-ui = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version = "2.5.0" }
stylecheck = { group = "ca.stellardrift", name = "stylecheck", version = "0.2.1" }
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package io.papermc.bibliothek;

import io.papermc.bibliothek.configuration.AppConfiguration;
import org.jspecify.annotations.NullMarked;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -32,8 +33,9 @@
@EnableConfigurationProperties({
AppConfiguration.class
})
@SpringBootApplication
@NullMarked
@ServletComponentScan
@SpringBootApplication
public class BibliothekApplication {
public static void main(final String[] args) {
SpringApplication.run(BibliothekApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.database.model;
package io.papermc.bibliothek.api.model;

import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.jspecify.annotations.NullMarked;

@Document(collection = "projects")
public record Project(
@Id ObjectId _id,
@Indexed String name,
String friendlyName
@NullMarked
public record Change(
String commit,
String summary,
String message
) {
}
32 changes: 32 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/model/Channel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.model;

import org.jspecify.annotations.NullMarked;

@NullMarked
public enum Channel {
DEFAULT,
EXPERIMENTAL;
}
33 changes: 33 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/model/Download.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.model;

import org.jspecify.annotations.NullMarked;

@NullMarked
public record Download(
String name,
String sha256
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.serialization;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import io.papermc.bibliothek.api.model.Channel;
import java.io.IOException;
import java.util.Locale;
import org.jspecify.annotations.NullMarked;

@NullMarked
public class LegacyChannelSerializer extends StdSerializer<Channel> {
public LegacyChannelSerializer() {
super(Channel.class);
}

@Override
public void serialize(final Channel value, final JsonGenerator gen, final SerializerProvider provider) throws IOException {
gen.writeString(value.name().toLowerCase(Locale.ROOT));
}
}
50 changes: 50 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/v2/model/Change.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.v2.model;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import org.jspecify.annotations.NullMarked;

@NullMarked
@Schema
public record Change(
@Schema(name = "commit")
String commit,
@Schema(name = "summary")
String summary,
@Schema(name = "message")
String message
) {
private Change(final io.papermc.bibliothek.api.model.Change that) {
this(that.commit(), that.summary(), that.message());
}

public static List<Change> map(final List<io.papermc.bibliothek.api.model.Change> list) {
return list
.stream()
.map(Change::new)
.toList();
}
}
49 changes: 49 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/v2/model/Download.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.v2.model;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
import java.util.stream.Collectors;
import org.jspecify.annotations.NullMarked;

@NullMarked
@Schema
public record Download(
@Schema(name = "name", pattern = "[a-z0-9._-]+", example = "paper-1.18-10.jar")
String name,
@Schema(name = "sha256", pattern = "[a-f0-9]{64}", example = "f065e2d345d9d772d5cf2a1ce5c495c4cc56eb2fcd6820e82856485fa19414c8")
String sha256
) {
private Download(final io.papermc.bibliothek.api.model.Download that) {
this(that.name(), that.sha256());
}

public static Map<String, Download> map(final Map<String, io.papermc.bibliothek.api.model.Download> map) {
return map.entrySet()
.stream()
.map(e -> Map.entry(e.getKey(), new Download(e.getValue())))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.v2.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.papermc.bibliothek.api.model.Channel;
import io.papermc.bibliothek.api.serialization.LegacyChannelSerializer;
import io.papermc.bibliothek.api.v2.model.Change;
import io.papermc.bibliothek.api.v2.model.Download;
import io.papermc.bibliothek.database.model.VersionEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.NullMarked;

@NullMarked
@Schema
public record BuildResponse(
@JsonProperty("project_id")
@Schema(name = "project_id", pattern = "[a-z]+", example = "paper")
String projectId,

@JsonProperty("project_name")
@Schema(name = "project_name", example = "Paper")
String projectName,

@JsonProperty("version")
@Schema(name = "version", pattern = VersionEntity.PATTERN, example = "1.18")
String version,

@JsonProperty("build")
@Schema(name = "build", pattern = "\\d+", example = "10")
int build,

@JsonProperty("time")
@Schema(name = "time")
Instant time,

@JsonProperty("channel")
@JsonSerialize(using = LegacyChannelSerializer.class)
@Schema(name = "channel")
Channel channel,

@JsonProperty("promoted")
@Schema(name = "promoted")
boolean promoted,

@JsonProperty("changes")
@Schema(name = "changes")
List<Change> changes,

@JsonProperty("downloads")
@Schema(name = "downloads")
Map<String, Download> downloads
) {
}
Loading

0 comments on commit f611897

Please sign in to comment.