Gradleのビルド:春ブートJarファイルからリソースファイルを除外

アリのn:

私は、彼らがプロビジョニングおよびビルド・パスの異なるバージョンは、いくつかの実行時の問題を作成することができた時に提供されますので、jarファイルからすべての設定ファイルを除外したいと思います。私は、次のGradleビルドスクリプトを使用していますが、何らかの理由で、私はまだ構築されたJarファイルにコピーするためのリソースディレクトリにあるものは何でも見ることができますが存在。これは予想通り提供Gradleのビルドが動作していないいくつかの理由のための手段。

apply plugin: 'distribution'

    distributions {
        main {
            baseName = "${project.name}"
            contents {
                into('/conf'){
                    from('src/main/resources')
                    exclude("application.yml")
                }
                into('/lib'){
                    from('build/libs')
                }
                into('/bin'){
                    from('../bin')
                }
            }
        }
    }


    processResources {
        # Not sure how I need to point to the resources, so I included both. However, none is working.
        exclude('resources/*')
        exclude('src/main/resources/*')
    }

    bootJar{
        # Not sure how I need to point to the resources, so I included both. However, none is working.
        exclude('resources/*')
        exclude('src/main/resources/*')    
    }

    distTar {
        dependsOn bootJar
    }

    tasks.withType(Tar) {
        compression = Compression.GZIP
        extension = "tar.gz"
    }

    configurations {
        customArch
    }

    artifacts {
        customArch file(distTar.archivePath)
    }
アリのn:

私が使ってJarファイルに表示されたリソースを除外することができたprocessResources.enabled = falseので、次のようにビルドファイルです。

apply plugin: 'distribution'

distributions {
    main {
        baseName = "${project.name}"
        contents {
            into('/conf'){
                from('src/main/resources')
                exclude("application.yml")
            }
            into('/lib'){
                from('build/libs')
            }
            into('/bin'){
                from('../bin')
            }
        }
    }
}

processResources.enabled = false

distTar {
    dependsOn bootJar
}

tasks.withType(Tar) {
    compression = Compression.GZIP
    extension = "tar.gz"
}

configurations {
    customArch
}

artifacts {
    customArch file(distTar.archivePath)
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=331383&siteId=1