chore: upgrade gradle and dependencies. (#688)

pull/691/head
Ryan Wang 2020-03-17 23:56:24 +08:00 committed by GitHub
parent d4cfc3ae7f
commit fc989c965c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 133 additions and 111 deletions

View File

@ -1,17 +1,15 @@
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id "io.freefair.lombok" version "3.6.6"
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'checkstyle'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'run.halo.app'
archivesBaseName = 'halo'
version = '1.3.0-beta.2'
sourceCompatibility = '1.8'
description = 'Halo, personal blog system developed in Java.'
description = 'Halo, An excellent open source blog publishing application.'
repositories {
maven {
@ -32,36 +30,39 @@ configurations {
runtimeClasspath {
extendsFrom developmentOnly
}
compileOnly {
extendsFrom annotationProcessor
}
}
bootJar {
manifest {
attributes('Implementation-Title': 'Halo Application',
'Implementation-Version': version)
'Implementation-Version': archiveVersion)
}
}
ext {
hutoolVersion = '5.0.3'
upyunSdkVersion = '4.0.1'
qiniuSdkVersion = '7.2.18'
aliyunSdkVersion = '3.4.2'
baiduSdkVersion = '0.10.36'
qcloudSdkVersion = '5.5.7'
swaggerVersion = '2.9.2'
commonsLangVersion = '3.8.1'
httpclientVersion = '4.5.7'
dataformatYamlVersion = '2.9.2'
jgitVersion = '5.3.0.201903130848-r'
flexmarkVersion = '0.42.12'
thumbnailatorVersion = '0.4.8'
image4jVersion = '0.7zensight1'
flywayVersion = '6.1.0'
h2Version = '1.4.196'
levelDbVersion = '0.12'
jsonVersion = '20190722'
fastJsonVersion = '1.2.56'
templateInheritance = "0.4.RELEASE"
set('hutoolVersion', "5.2.3")
set('upyunSdkVersion', "4.2.0")
set('qiniuSdkVersion', "7.2.28")
set('aliyunSdkVersion', "3.8.1")
set('baiduSdkVersion', "0.10.36")
set('qcloudSdkVersion', "5.6.18")
set('swaggerVersion', "2.9.2")
set('commonsLangVersion', "3.9")
set('httpclientVersion', "4.5.12")
set('dataformatYamlVersion', "2.10.3")
set('jgitVersion', "5.7.0.202003110725-r")
set('flexmarkVersion', "0.42.12")
set('thumbnailatorVersion', "0.4.11")
set('image4jVersion', "0.7zensight1")
set('flywayVersion', "6.3.1")
set('h2Version', "1.4.196")
set('levelDbVersion', "0.12")
set('jsonVersion', "20190722")
set('fastJsonVersion', "1.2.66")
}
dependencies {
@ -70,54 +71,56 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-undertow'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation "kr.pe.kwonnam.freemarker:freemarker-template-inheritance:$templateInheritance"
implementation "com.sun.mail:jakarta.mail"
implementation "cn.hutool:hutool-core:$hutoolVersion"
implementation "cn.hutool:hutool-crypto:$hutoolVersion"
implementation "cn.hutool:hutool-extra:$hutoolVersion"
implementation "com.upyun:java-sdk:$upyunSdkVersion"
implementation "com.qiniu:qiniu-java-sdk:$qiniuSdkVersion"
implementation "com.aliyun.oss:aliyun-sdk-oss:$aliyunSdkVersion"
implementation "com.baidubce:bce-java-sdk:$baiduSdkVersion"
implementation "com.qcloud:cos_api:$qcloudSdkVersion"
implementation "io.springfox:springfox-swagger2:$swaggerVersion"
implementation "io.springfox:springfox-swagger-ui:$swaggerVersion"
implementation "org.apache.commons:commons-lang3:$commonsLangVersion"
implementation "org.apache.httpcomponents:httpclient:$httpclientVersion"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$dataformatYamlVersion"
implementation "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion"
implementation "cn.hutool:hutool-core:${hutoolVersion}"
implementation "cn.hutool:hutool-crypto:${hutoolVersion}"
implementation "cn.hutool:hutool-extra:${hutoolVersion}"
implementation "com.upyun:java-sdk:${upyunSdkVersion}"
implementation "com.qiniu:qiniu-java-sdk:${qiniuSdkVersion}"
implementation "com.aliyun.oss:aliyun-sdk-oss:${aliyunSdkVersion}"
implementation "com.baidubce:bce-java-sdk:${baiduSdkVersion}"
implementation "com.qcloud:cos_api:${qcloudSdkVersion}"
implementation "io.springfox:springfox-swagger2:${swaggerVersion}"
implementation "io.springfox:springfox-swagger-ui:${swaggerVersion}"
implementation "org.apache.commons:commons-lang3:${commonsLangVersion}"
implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${dataformatYamlVersion}"
implementation "org.eclipse.jgit:org.eclipse.jgit:${jgitVersion}"
implementation "com.vladsch.flexmark:flexmark:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-attributes:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-autolink:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-emoji:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-escaped-character:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-gfm-tasklist:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-ins:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-media-tags:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-tables:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-toc:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-yaml-front-matter:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-ext-gitlab:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-html-parser:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-attributes:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-autolink:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-emoji:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-escaped-character:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-gfm-tasklist:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-ins:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-media-tags:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-tables:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-toc:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-yaml-front-matter:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-gitlab:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-html-parser:${flexmarkVersion}"
implementation "net.coobird:thumbnailator:$thumbnailatorVersion"
implementation "net.sf.image4j:image4j:$image4jVersion"
implementation "org.flywaydb:flyway-core:$flywayVersion"
implementation "net.coobird:thumbnailator:${thumbnailatorVersion}"
implementation "net.sf.image4j:image4j:${image4jVersion}"
implementation "org.flywaydb:flyway-core:${flywayVersion}"
implementation "org.json:json:$jsonVersion"
implementation "com.alibaba:fastjson:$fastJsonVersion"
implementation "org.json:json:${jsonVersion}"
implementation "com.alibaba:fastjson:${fastJsonVersion}"
implementation "org.iq80.leveldb:leveldb:$levelDbVersion"
runtimeOnly "com.h2database:h2:$h2Version"
implementation "org.iq80.leveldb:leveldb:${levelDbVersion}"
runtimeOnly "com.h2database:h2:${h2Version}"
runtimeOnly 'mysql:mysql-connector-java'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
developmentOnly 'org.springframework.boot:spring-boot-devtools'

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Mon Sep 09 12:27:59 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

22
gradlew vendored
View File

@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

18
gradlew.bat vendored
View File

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -1,2 +0,0 @@
# This file is generated by the 'io.freefair.lombok' Gradle plugin
config.stopBubbling = true

View File

@ -4,10 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import freemarker.core.TemplateClassResolver;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import freemarker.template.TemplateModel;
import kr.pe.kwonnam.freemarker.inheritance.BlockDirective;
import kr.pe.kwonnam.freemarker.inheritance.ExtendsDirective;
import kr.pe.kwonnam.freemarker.inheritance.PutDirective;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.jackson.JsonComponentModule;
import org.springframework.context.annotation.Bean;
@ -39,7 +35,10 @@ import run.halo.app.security.resolver.AuthenticationArgumentResolver;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import static run.halo.app.model.support.HaloConst.FILE_SEPARATOR;
import static run.halo.app.utils.HaloUtils.*;
@ -135,16 +134,6 @@ public class WebMvcAutoConfiguration extends WebMvcConfigurationSupport {
registry.addConverterFactory(new StringToEnumConverterFactory());
}
@Bean
public Map<String, TemplateModel> freemarkerLayoutDirectives() {
Map<String, TemplateModel> freemarkerLayoutDirectives = new HashMap<>(5);
freemarkerLayoutDirectives.put("extends", new ExtendsDirective());
freemarkerLayoutDirectives.put("block", new BlockDirective());
freemarkerLayoutDirectives.put("put", new PutDirective());
return freemarkerLayoutDirectives;
}
/**
* Configuring freemarker template file path.
*
@ -173,13 +162,6 @@ public class WebMvcAutoConfiguration extends WebMvcConfigurationSupport {
// Set predefined freemarker configuration
configurer.setConfiguration(configuration);
// Set layout variable
Map<String, Object> freemarkerVariables = new HashMap<>(3);
freemarkerVariables.put("layout", freemarkerLayoutDirectives());
configurer.setFreemarkerVariables(freemarkerVariables);
return configurer;
}

View File

@ -107,6 +107,7 @@ public class AliOssFileHandler implements FileHandler {
// Handle thumbnail
if (FileHandler.isImageType(uploadResult.getMediaType())) {
ImageReader image = ImageUtils.getImageReaderFromFile(file.getInputStream(), extension);
assert image != null;
uploadResult.setWidth(image.getWidth(0));
uploadResult.setHeight(image.getHeight(0));
if (ImageUtils.EXTENSION_ICO.equals(extension)) {

View File

@ -88,6 +88,7 @@ public class BaiduBosFileHandler implements FileHandler {
// Handle thumbnail
if (FileHandler.isImageType(uploadResult.getMediaType())) {
ImageReader image = ImageUtils.getImageReaderFromFile(file.getInputStream(), extension);
assert image != null;
uploadResult.setWidth(image.getWidth(0));
uploadResult.setHeight(image.getHeight(0));
if (ImageUtils.EXTENSION_ICO.equals(extension)) {

View File

@ -119,6 +119,7 @@ public class TencentCosFileHandler implements FileHandler {
// Handle thumbnail
if (FileHandler.isImageType(uploadResult.getMediaType())) {
ImageReader image = ImageUtils.getImageReaderFromFile(file.getInputStream(), extension);
assert image != null;
uploadResult.setWidth(image.getWidth(0));
uploadResult.setHeight(image.getHeight(0));
if (ImageUtils.EXTENSION_ICO.equals(extension)) {

View File

@ -1,7 +1,9 @@
package run.halo.app.handler.file;
import com.UpYun;
import com.upyun.RestManager;
import com.upyun.UpException;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
@ -17,6 +19,9 @@ import run.halo.app.utils.FilenameUtils;
import run.halo.app.utils.ImageUtils;
import javax.imageio.ImageReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
@ -50,11 +55,11 @@ public class UpOssFileHandler implements FileHandler {
String styleRule = optionService.getByPropertyOrDefault(UpOssProperties.OSS_STYLE_RULE, String.class, "");
String thumbnailStyleRule = optionService.getByPropertyOrDefault(UpOssProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
// Create up yun
UpYun upYun = new UpYun(bucket, operator, password);
upYun.setDebug(log.isDebugEnabled());
upYun.setTimeout(60);
upYun.setApiDomain(UpYun.ED_AUTO);
RestManager manager = new RestManager(bucket, operator, password);
manager.setTimeout(60 * 10);
manager.setApiDomain(RestManager.ED_AUTO);
Map<String, String> params = new HashMap<>();
try {
// Get file basename
@ -66,10 +71,10 @@ public class UpOssFileHandler implements FileHandler {
// Build file path
String upFilePath = StringUtils.appendIfMissing(source, "/") + md5OfFile + '.' + extension;
// Set md5Content
upYun.setContentMD5(md5OfFile);
params.put(RestManager.PARAMS.CONTENT_MD5.getValue(), md5OfFile);
// Write file
boolean uploadSuccess = upYun.writeFile(upFilePath, file.getInputStream(), true, null);
if (!uploadSuccess) {
Response result = manager.writeFile(upFilePath, file.getInputStream(), params);
if (!result.isSuccessful()) {
throw new FileOperationException("上传附件 " + file.getOriginalFilename() + " 到又拍云失败" + upFilePath);
}
@ -87,6 +92,7 @@ public class UpOssFileHandler implements FileHandler {
// Handle thumbnail
if (FileHandler.isImageType(uploadResult.getMediaType())) {
ImageReader image = ImageUtils.getImageReaderFromFile(file.getInputStream(), extension);
assert image != null;
uploadResult.setWidth(image.getWidth(0));
uploadResult.setHeight(image.getHeight(0));
if (ImageUtils.EXTENSION_ICO.equals(extension)) {
@ -111,18 +117,17 @@ public class UpOssFileHandler implements FileHandler {
String bucket = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_BUCKET).toString();
String operator = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_OPERATOR).toString();
// Create up yun
UpYun upYun = new UpYun(bucket, operator, password);
// Set api domain with ED_AUTO
upYun.setApiDomain(UpYun.ED_AUTO);
RestManager manager = new RestManager(bucket, operator, password);
manager.setTimeout(60 * 10);
manager.setApiDomain(RestManager.ED_AUTO);
try {
// Delete the file
boolean deleteResult = upYun.deleteFile(key);
if (!deleteResult) {
log.warn("Failed to delete file " + key + " from UpYun");
Response result = manager.deleteFile(key, null);
if (!result.isSuccessful()) {
log.warn("附件 " + key + " 从又拍云删除失败");
}
} catch (Exception e) {
} catch (IOException | UpException e) {
e.printStackTrace();
throw new FileOperationException("附件 " + key + " 从又拍云删除失败", e);
}
}