我正在嘗試創建一個 Jar 用作 Maven 存盤庫
我已經把所有東西都建好了,所有的課程都準備好了。唯一的問題是 gradlew ./build 包含來自測驗檔案夾的類和資源。我不希望這些作為 jar 的一部分,尤其是正在測驗的資源檔案。
所以我的問題是,如何從我的 jar 構建任務中排除這些檔案。我試過了
tasks.named('jar'){
exclude('PATH/src/test/')
在我的 build.gradle 中,但這不起作用
我是 gradle 和 maven 的新手,所以任何見解都會有所幫助。謝謝!
參考資料
構建.gradle
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id 'maven-publish'
}
group = 'com.project.tools'
version = '1.0.0'
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:31.0.1-jre'
implementation platform('io.cucumber:cucumber-bom:7.1.0')
implementation 'io.cucumber:cucumber-java'
implementation 'io.cucumber:cucumber-junit-platform-engine'
implementation 'io.cucumber:cucumber-junit'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
}
tasks.named('jar'){
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}
檔案結構
project/
├─ tools/
│ ├─ build/
│ │ ├─ classes/
│ │ │ ├─ new_folder/
│ │ │ │ ├─ main/
│ │ │ │ ├─ test/ #I Don't Want This Here, This Classes Do Not Need To Be Accessible
│ │ ├─ generated/
│ │ ├─ libs/
│ │ ├─ reports/
│ │ ├─ resources/
│ │ │ ├─ test/ #Would rather not have this entire folder
│ │ │ │ ├─ com.project.tools/
│ │ │ │ ├─ test.properties # Definitely Do Not Want This Included
│ │ ├─ test-results/
│ │ ├─ tmp/
│ ├─ src/
│ │ ├─ main/
│ │ │ ├─ java/
│ │ │ │ ├─ com.project.tools/
│ │ │ │ │ ├─ MyClasses.java
│ │ │ ├─ resources/
│ │ ├─ test/
│ │ │ ├─ java/
│ │ │ │ ├─ com.project.tools/
│ │ │ │ │ ├─ MyTestClasses.java
│ │ │ ├─ resources/
│ ├─ build.gradle
uj5u.com熱心網友回復:
Gradle 默認做正確的事,不需要手動test從jar.
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/503842.html
