From 3b1b756f1a619e60b2243d28817c39e0a7a0cb0c Mon Sep 17 00:00:00 2001
From: senzhi <10983298651@qq.com>
Date: Wed, 21 Jan 2026 14:20:58 +0800
Subject: [PATCH] fix:修改项目为组件
---
build.gradle | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/build.gradle b/build.gradle
index 1b477a2..9d144ab 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
plugins {
id 'java'
+ id 'maven-publish' // or 'maven'
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
@@ -11,13 +12,14 @@
mavenLocal()
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/center' }
+ mavenCentral()
}
bootJar.enabled = true
jar.enabled = true
group = 'com.eternal'
-version = '0.0.1-SNAPSHOT'
+version = '1.0.0'
java {
sourceCompatibility = '1.8'
@@ -42,10 +44,45 @@
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
-test {
- useJUnitPlatform()
+// 编译相关参数
+compileJava {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ options.encoding = 'UTF-8'
+ options.compilerArgs = [
+ '-Xlint:all', '-Xlint:-processing'
+ ]
+}
+// 定义 sourcesJar 任务
+task sourcesJar(type: Jar, dependsOn: classes) {
+ archiveClassifier.set('sources')
+ from sourceSets.main.allSource
+}
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ from components.java
+ // 如果需要发布源码 JAR 文件
+ artifact sourcesJar
+ }
+ }
+ repositories {
+ maven {
+ name = 'localRepo'
+ url = "file://${buildDir}/repo"
+ }
+ maven {
+ name = 'releases'
+ allowInsecureProtocol = true // 显式允许不安全的 HTTP 协议
+ url = 'http://1.95.69.137:9081/repository/maven-releases/'
+ credentials {
+ username = "admin"
+ password = "admin123"
+ }
+ }
+ }
}
-tasks.withType(JavaCompile) {
- options.encoding = "UTF-8"
-}
\ No newline at end of file
+tasks.named('test') {
+ useJUnitPlatform()
+}
--
Gitblit v1.9.3