第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在 Gradle 中創(chuàng)建具有附加編譯依賴項(xiàng)的生產(chǎn)配置

在 Gradle 中創(chuàng)建具有附加編譯依賴項(xiàng)的生產(chǎn)配置

寶慕林4294392 2021-12-10 15:32:18
我正在嘗試為我的生產(chǎn)版本定義構(gòu)建腳本。下面是項(xiàng)目結(jié)構(gòu),所有項(xiàng)目都是java插件。wrapper (parent)|--frontend (child)|  |--src|  |  |--js (raw ES6 modules)|  |  |--sass (raw)|  |--build|     |--lib|     |  |--production-front.jar|     |--dist|        |--js (bundled)|        |--css (compiled production)|--backend (child) (spring boot)   |--build      |--lib         |--RELEASE.jar現(xiàn)在這里發(fā)生的是默認(rèn)情況下 ( sourceSets.main.resources.srcDirs) ofbackend直接鏈接到:生的 :frontent/src/js生成 :frontent/build/dist/css.這樣,當(dāng)您運(yùn)行它時(shí),默認(rèn)情況下它將處于開發(fā)模式。這意味著它將:使用生成的scss->css 文件(這是資源,例如,如果您運(yùn)行后臺(tái) gulp-sass,每次更改 scss 時(shí)都會(huì)編譯它,css 將更新和繁榮,快速開發(fā)周期)。使用在瀏覽器中直接編譯的原始JS(JSPM、SystemJS、Babel) - 所以你只需要編輯:frontent/src/js和刷新頁面。好的,雖然 dev 是愛,但我還需要編譯以進(jìn)行生產(chǎn)。上面提到的項(xiàng)目結(jié)構(gòu)也顯示了:frontend生成的位置production-front.jar。這是帶有我的筆記的默認(rèn) java 構(gòu)建樹。編輯 我需要建立依賴項(xiàng),該依賴項(xiàng)將編譯production-front.jar為RELEASE.jar并省略提到的附加資源。請(qǐng)注意,我只需要忽略這些資源,而不是main.resources.srcDirs.什么是解決這個(gè)問題的正確方法(一種不執(zhí)行從 .jar 中刪除開發(fā)資源然后放入其他 production-front.jar 的任務(wù))?我無法理解如何制作在這里工作的多個(gè) sourceSets 或配置。
查看完整描述

1 回答

?
慕桂英4014372

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超13個(gè)贊

在過去一周非常深入的 Gradle 學(xué)習(xí)之后(創(chuàng)建這個(gè)主題是因?yàn)槲铱煲懒耍┪医K于找到了非常令人滿意的解決方案。


我想分享我的目標(biāo)和最終解決方案:


擁有盡可能小的 build.gradle

有發(fā)展的可能 build --continuous

使eclipse插件(可能還有其他 IDE)可以使用自己的構(gòu)建系統(tǒng)完美地反映純命令行 Gradle 開發(fā)。

這是一個(gè)多項(xiàng)目,其中一個(gè)是帶有 DevTools 的 Spring Boot 應(yīng)用程序。


wrapper (parent)

|--frontend (child)

|  |--src-client

|  |  |--static

|  |  |  |--img (images)

|  |  |  \--js (raw ES6 modules)

|  |  \--sass (raw, note not in static folder)

|  \--build

|     |--lib

|     |  \--front.jar

|     |--dist

|     |  |--js (bundled, minimized)

|     |  \--css (compiled production, minimized)

|     \--dev

|        \--css (compiled dev, compact readable format)

\--backend (child) (spring boot)

   |--src

   |  |--main/java

   |  |--main/resources

   |  \--test/java

   \--build

      \--lib

         \--application.jar

正如我所描述的,目標(biāo)是:


已經(jīng)bootRun與運(yùn)行原為js和源編譯CSS,而且與被包含在每個(gè)資源backend的main。

已經(jīng)bootJar編譯到生產(chǎn)中,依賴于已編譯front.jar而不是在開發(fā)中使用的所有內(nèi)容(上一點(diǎn))。

我使用了配置、sourceSets 和 bootRun 屬性的組合(+ 很多時(shí)間)。


以下是文件(精簡):


包裝器/build.gradle


wrapper.gradleVersion '5.0-milestone-1'


allprojects {

    apply plugin: 'eclipse'

}

包裝器/前/build.gradle


plugins {

    id 'java' // possibly use java-base or just custom zip task, since client doesn't actually compile java

}


jar {

    dependsOn buildProduction // task that compiles my stuff into build/dist

    baseName 'front'

    classifier 'SNAPSHOT-' + new Date().format('yyyyMMddHHmmss')

    from(buildDir.absolutePath + '/dist') {

        into 'static'

    }

}


// Note there is a lot of other tasks here that actually compile my stuff, like gulp-sass and JSPM bundling with babel transpiler.

包裝器/后端/build.gradle


buildscript {

    repositories {

        mavenCentral()

        maven { url 'https://repo.spring.io/milestone' }

    }

    dependencies {

        classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.1.0.RC1'

    }

}


apply plugin: 'java'

apply plugin: 'org.springframework.boot'

apply plugin: 'io.spring.dependency-management'


sourceCompatibility = 10 // eclipse has (or had) problems with Java 11

targetCompatibility = 10


sourceSets {

    // 'java' plugin adds default main sourceSet

    dev {

        resources.srcDirs = [

            project(':front').projectDir.absolutePath + '/src-client',

            project(':front').buildDir.absolutePath + '/dev'

        ]

    }

}


bootJar {

    baseName 'application'

    classifier 'SNAPSHOT-' + new Date().format('yyyyMMddHHmmssSSS')

    // I used bootArchives since it was already there and my stuff fits description, you can also define your own configuration and extend runtime one.

    classpath configurations.bootArchives

}


bootRun {

    sourceResources sourceSets.dev // I make bootRun (dev) use dev sourceSet

}


dependencies {

    runtime 'org.springframework.boot:spring-boot-devtools'

    // Since bootArchives configuration is used only by bootJar (not bootRun), this will be only in final fat .jar

    bootArchives project(':front')

    ...

}


repositories {

    mavenCentral()

    maven { url 'https://repo.spring.io/milestone' }

}

一些有幫助的鏈接:http : //mrhaki.blogspot.com/2014/09/gradle-goodness-adding-dependencies.html


請(qǐng)注意,客戶端的源文件夾稱為src-client:這是在 eclipse 中制作“完美鏡像”的關(guān)鍵。如果我們將它命名src為已經(jīng)main在backendeclipse 中使用的名稱,則會(huì)因名稱沖突而嘔吐(這可能可以通過配置 eclipse 插件來修復(fù),但話又說回來 - 我們希望保持簡單,沒有 IDE 配置)。


作為最終結(jié)果,我們通過 gradle 的連續(xù)構(gòu)建和 eclipse 中的完全鏡像行為獲得了非常好的命令行開發(fā),默認(rèn)其配置以相同的方式工作(但使用 eclipse 的構(gòu)建器而不是 gradle 的構(gòu)建器)。我們還在backend項(xiàng)目中獲得了很好的鏈接文件夾到從front. 同樣可能適用于 IDEA :)。


查看完整回答
反對(duì) 回復(fù) 2021-12-10
  • 1 回答
  • 0 關(guān)注
  • 196 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)