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 7b01b05
Show file tree
Hide file tree
Showing 51 changed files with 1,415 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));
}
}
68 changes: 68 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/v2/Constants2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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;

import org.intellij.lang.annotations.Language;
import org.jspecify.annotations.NullMarked;

@NullMarked
public final class Constants2 {
public static final String FIELD_BUILD = "build";
public static final String FIELD_BUILDS = "builds";
public static final String FIELD_CHANGES = "changes";
public static final String FIELD_CHANNEL = "channel";
public static final String FIELD_COMMIT = "commit";
public static final String FIELD_DOWNLOADS = "downloads";
public static final String FIELD_MESSAGE = "message";
public static final String FIELD_NAME = "name";
public static final String FIELD_PROJECTS = "projects";
public static final String FIELD_PROJECT_ID = "project_id";
public static final String FIELD_PROJECT_NAME = "project_name";
public static final String FIELD_PROMOTED = "promoted";
public static final String FIELD_SHA256 = "sha256";
public static final String FIELD_SUMMARY = "summary";
public static final String FIELD_TIME = "time";
public static final String FIELD_VERSION = "version";
public static final String FIELD_VERSIONS = "versions";
public static final String FIELD_VERSION_GROUP = "version_group";
public static final String FIELD_VERSION_GROUPS = "version_groups";

@Language("RegExp")
public static final String PATTERN_DOWNLOAD = "[a-z0-9._-]+";
@Language("RegExp")
public static final String PATTERN_PROJECT_ID = "[a-z]+";
@Language("RegExp")
public static final String PATTERN_SHA256 = "[a-f0-9]{64}";
@Language("RegExp")
public static final String PATTERN_VERSION = "[0-9.]+-?(?:pre|SNAPSHOT)?(?:[0-9.]+)?";

public static final String EXAMPLE_DOWNLOAD = "paper-1.18-10.jar";
public static final String EXAMPLE_PROJECT_ID = "paper";
public static final String EXAMPLE_PROJECT_NAME = "Paper";
public static final String EXAMPLE_SHA256 = "f065e2d345d9d772d5cf2a1ce5c495c4cc56eb2fcd6820e82856485fa19414c8";
public static final String EXAMPLE_VERSION = "1.18";

private Constants2() {
}
}
61 changes: 61 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/v2/model/Change2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.bibliothek.api.model.Change;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import org.jspecify.annotations.NullMarked;

import static io.papermc.bibliothek.api.v2.Constants2.FIELD_COMMIT;
import static io.papermc.bibliothek.api.v2.Constants2.FIELD_MESSAGE;
import static io.papermc.bibliothek.api.v2.Constants2.FIELD_SUMMARY;

@NullMarked
@Schema
public record Change2(
@JsonProperty(FIELD_COMMIT)
@Schema(name = FIELD_COMMIT)
String commit,

@JsonProperty(FIELD_SUMMARY)
@Schema(name = FIELD_SUMMARY)
String summary,

@JsonProperty(FIELD_MESSAGE)
@Schema(name = FIELD_MESSAGE)
String message
) {
private Change2(final Change that) {
this(that.commit(), that.summary(), that.message());
}

public static List<Change2> map(final List<Change> list) {
return list
.stream()
.map(Change2::new)
.toList();
}
}
61 changes: 61 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/v2/model/Download2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.bibliothek.api.model.Download;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
import java.util.stream.Collectors;
import org.jspecify.annotations.NullMarked;

import static io.papermc.bibliothek.api.v2.Constants2.EXAMPLE_DOWNLOAD;
import static io.papermc.bibliothek.api.v2.Constants2.EXAMPLE_SHA256;
import static io.papermc.bibliothek.api.v2.Constants2.FIELD_NAME;
import static io.papermc.bibliothek.api.v2.Constants2.FIELD_SHA256;
import static io.papermc.bibliothek.api.v2.Constants2.PATTERN_DOWNLOAD;
import static io.papermc.bibliothek.api.v2.Constants2.PATTERN_SHA256;

@NullMarked
@Schema
public record Download2(
@JsonProperty(FIELD_NAME)
@Schema(name = FIELD_NAME, pattern = PATTERN_DOWNLOAD, example = EXAMPLE_DOWNLOAD)
String name,

@JsonProperty(FIELD_SHA256)
@Schema(name = FIELD_SHA256, pattern = PATTERN_SHA256, example = EXAMPLE_SHA256)
String sha256
) {
private Download2(final Download that) {
this(that.name(), that.sha256());
}

public static Map<String, Download2> map(final Map<String, Download> map) {
return map.entrySet()
.stream()
.map(e -> Map.entry(e.getKey(), new Download2(e.getValue())))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
}
Loading

0 comments on commit 7b01b05

Please sign in to comment.