📝 修改文档.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Jiahang Li (visor.orionsec.cn ljh1553488six@139.com).
|
||||
* Copyright (c) 2023 - present Dromara (visor.dromara.org ljh1553488six@139.com).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Jiahang Li (visor.orionsec.cn ljh1553488six@139.com).
|
||||
* Copyright (c) 2023 - present Dromara (visor.dromara.org ljh1553488six@139.com).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Jiahang Li (visor.orionsec.cn ljh1553488six@139.com).
|
||||
* Copyright (c) 2023 - present Dromara (visor.dromara.org ljh1553488six@139.com).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,6 +27,8 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 添加 license 头
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/10/11 13:52
|
||||
@@ -34,7 +36,7 @@ import java.util.List;
|
||||
public class AddLicenseHeader {
|
||||
|
||||
private static final String LICENSE = "/*\n" +
|
||||
" * Copyright (c) 2023 - present Jiahang Li (visor.orionsec.cn ljh1553488six@139.com).\n" +
|
||||
" * Copyright (c) 2023 - present Dromara (visor.dromara.org ljh1553488six@139.com).\n" +
|
||||
" *\n" +
|
||||
" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
|
||||
" * you may not use this file except in compliance with the License.\n" +
|
||||
@@ -56,12 +58,14 @@ public class AddLicenseHeader {
|
||||
// 扫描文件
|
||||
List<File> files = Files1.listFilesFilter(PATH, file -> file.isFile()
|
||||
&& (file.getName().endsWith(".java") || file.getName().endsWith(".java.vm"))
|
||||
&& !file.getAbsolutePath().contains("generated-sources")
|
||||
&& !file.getAbsolutePath().contains("node_modules"), true, false);
|
||||
sw.tag("list");
|
||||
// 添加头
|
||||
files.forEach(AddLicenseHeader::addLicenseToFile);
|
||||
sw.tag(" add");
|
||||
sw.stop();
|
||||
System.out.println();
|
||||
System.out.println(sw);
|
||||
}
|
||||
|
||||
@@ -71,10 +75,11 @@ public class AddLicenseHeader {
|
||||
* @param file file
|
||||
*/
|
||||
private static void addLicenseToFile(File file) {
|
||||
String path = file.getAbsolutePath().substring(PATH.length());
|
||||
try {
|
||||
String line = FileReaders.readLine(file);
|
||||
if (line != null && line.trim().equals("/*")) {
|
||||
System.out.println("License already exists in " + file.getAbsolutePath());
|
||||
System.out.println("Exists " + path);
|
||||
return;
|
||||
}
|
||||
// 读取原始文件内容
|
||||
@@ -86,9 +91,9 @@ public class AddLicenseHeader {
|
||||
out.write(new String(bytes).replaceAll("\r\n", "\n").getBytes(StandardCharsets.UTF_8));
|
||||
// 写入
|
||||
FileWriters.writeFast(file, out.toByteArray());
|
||||
System.out.println("License added to " + file.getAbsolutePath());
|
||||
System.out.println("Added " + path);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to add license to " + file.getAbsolutePath());
|
||||
System.err.println("Failed " + path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user