refactor: adapt to halo 2.0

This commit is contained in:
guqing
2022-12-01 13:48:12 +08:00
parent 781a010a8f
commit 9732cd5f82
7 changed files with 23 additions and 26 deletions

View File

@@ -32,7 +32,7 @@ jobs:
with:
name: plugin-alioss
path: |
build/libs/*-plain.jar
build/libs/*.jar
retention-days: 1
github-release:
@@ -78,4 +78,4 @@ jobs:
release_id: releaseId,
name: artifactName,
data: await fs.readFile(artifactPathName)
});
});

2
.gitignore vendored
View File

@@ -69,3 +69,5 @@ nbdist/
application-local.yml
application-local.yaml
application-local.properties
/workplace/

View File

@@ -1,7 +1,5 @@
plugins {
id 'org.springframework.boot' version '3.0.0-M4'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id "io.github.guqing.plugin-development" version "0.0.5-SNAPSHOT"
id "io.github.guqing.plugin-development" version "0.0.6-SNAPSHOT"
id 'java'
}
@@ -9,15 +7,11 @@ group 'run.halo.alioss'
sourceCompatibility = JavaVersion.VERSION_17
repositories {
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/releases' }
maven { url 'https://repo.spring.io/milestone' }
mavenCentral()
}
bootJar {
enabled = false
}
jar {
enabled = true
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -29,21 +23,23 @@ jar {
}
dependencies {
compileOnly "org.pf4j:pf4j:3.6.0"
compileOnly "io.swagger.core.v3:swagger-core-jakarta:2.2.0"
compileOnly 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly platform("run.halo.dependencies:halo-dependencies:1.0.0")
compileOnly files("lib/halo-2.0.0-SNAPSHOT-plain.jar")
implementation 'org.springframework.boot:spring-boot-starter-test'
implementation "com.aliyun.oss:aliyun-sdk-oss:3.15.0"
implementation "javax.xml.bind:jaxb-api:2.3.1"
implementation "javax.activation:activation:1.1.1"
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.3"
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testImplementation platform("run.halo.dependencies:halo-dependencies:1.0.0")
testImplementation files("lib/halo-2.0.0-SNAPSHOT-plain.jar")
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
}
test {

Binary file not shown.

View File

@@ -192,11 +192,11 @@ public class AliOssAttachmentHandler implements AttachmentHandler {
boolean shouldHandle(Policy policy) {
if (policy == null || policy.getSpec() == null ||
policy.getSpec().getTemplateRef() == null) {
policy.getSpec().getTemplateName() == null) {
return false;
}
var templateRef = policy.getSpec().getTemplateRef();
return "alioss".equals(templateRef.getName());
String templateName = policy.getSpec().getTemplateName();
return "alioss".equals(templateName);
}
record ObjectDetail(String bucketName, String objectName, ObjectMetadata objectMetadata) {

View File

@@ -4,8 +4,8 @@ metadata:
name: PluginAliOSS
spec:
enabled: true
version: 1.0.0-alpha.2
requires: "*"
version: 1.0.0
requires: ">=2.0.0"
author:
name: Halo OSS Team
website: https://github.com/halo-dev

View File

@@ -9,7 +9,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import run.halo.app.core.extension.attachment.Policy;
import run.halo.app.core.extension.attachment.Policy.PolicySpec;
import run.halo.app.extension.Ref;
class AliOssAttachmentHandlerTest {
@@ -26,13 +25,13 @@ class AliOssAttachmentHandlerTest {
var spec = mock(PolicySpec.class);
when(policy.getSpec()).thenReturn(spec);
when(spec.getTemplateRef()).thenReturn(Ref.of("alioss"));
when(spec.getTemplateName()).thenReturn("alioss");
assertTrue(handler.shouldHandle(policy));
when(spec.getTemplateRef()).thenReturn(Ref.of("invalid"));
when(spec.getTemplateName()).thenReturn("invalid");
assertFalse(handler.shouldHandle(policy));
// policy is null
assertFalse(handler.shouldHandle(null));
}
}
}