Gradle 프로젝트 종속성에서 META-INF를 어떻게 제외합니까?

브라이언 그레이엄 :

나는 두 형제의 프로젝트를 가지고 ProjectAProjectB그 둘을 받고있다 Parent. 상위는 기본적으로 폴더 일 뿐이며 두 하위 프로젝트에 대한 공통 build.gradle 설정이 있습니다.

ProjectB는 컴파일 타임에 ProjectA의 코드에 의존하지만 ProjectA는 별도로 빌드되며 META-INF 디렉토리를 포함합니다. ProjectB를 빌드 할 때 java.lang.SecurityException : Invalid signature file digest for Manifest main attributes를 얻습니다 . 아래에서 볼 수 있듯이 ProjectB에서 zipTree 호출을 제거했으며이 문제를 해결하는 방법을 잘 모르겠습니다. 도움을 주시면 대단히 감사하겠습니다.

두 프로젝트 모두 자체 JAR을 빌드해야하며 ProjectA는 아래에 표시된 두 종속성을 음영 처리해야합니다.

부모 settings.gradle :

rootProject.name = "Parent"
include ":ProjectA", ":ProjectB"

부모 build.gradle :

allprojects {
    buildscript {
        repositories {
            jcenter()
            maven {
                name = "forge"
                url = "https://files.minecraftforge.net/maven"
            }
            maven {
                name = "sponge"
                url = "https://repo.spongepowered.org/maven"
            }
        }
        dependencies {
            classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
            classpath "org.spongepowered:mixingradle:0.6-SNAPSHOT"
        }
    }

    repositories {
        mavenCentral()
        maven {
            name = 'spongepowered-repo'
            url = 'https://repo.spongepowered.org/maven'
        }
        maven {
            name = 'jitpack-repo'
            url = 'https://jitpack.io'
        }
    }

    configurations {
        shade
        compile.extendsFrom(shade)
    }
}

ProjectA build.gradle :

apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: 'org.spongepowered.mixin'

version = project.modVersion
group = project.modGroup

minecraft {
    version = "${project.mcVersion}-${project.forgeVersion}"
    runDir = "run"

    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not always work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = project.mcpVersion
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    replace("@MOD_VERSION@", project.modVersion)
    replace("@MOD_ID@", project.modId)
    replace("@MOD_NAME@", project.modBaseName)
    replace("@MOD_ACCEPTED@", "[${project.modAcceptedVersions}]")
    replaceIn "${project.modBaseName}.java"
}

mixin {
    defaultObfuscationEnv searge
    add sourceSets.main, "mixins.${project.modId}.refmap.json"
}

dependencies {
    shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
        // Mixin includes a lot of dependencies that are too up-to-date
        exclude module: 'launchwrapper'
        exclude module: 'guava'
        exclude module: 'gson'
        exclude module: 'commons-io'
        exclude module: 'log4j-core'
    }

    shade group: 'org.yaml', name: 'snakeyaml', version: '1.6'
}

jar {
    from(configurations.shade.collect { it.isDirectory() ? it : zipTree(it) })
    //from (configurations.provided.collect { entry -> zipTree(entry) })

    manifest {
        attributes(
                'FMLAT': "${project.modId}_at.cfg",
                'MixinConfigs': "mixins.${project.modId}.json",
                'TweakOrder': '0',
                'TweakClass': "${project.modGroup}.${project.modId}.tweaker.${project.modBaseName}Tweaker",
                'Main-Class': 'OpenErrorMessage'
        )
    }
}

processResources {
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include "**/*.info"
        include "**/*.properties"

        // replace version and mcversion
        expand "version": project.version, "mcversion": project.minecraft.version
    }

    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude "**/*.info"
        exclude "**/*.properties"
    }
}

ProjectB build.gradle :

apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'

version = project.modVersion
group = project.modGroup

minecraft {
    version = "${project.mcVersion}-${project.forgeVersion}"
    runDir = "run"

    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not always work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = project.mcpVersion
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    replace("@MOD_VERSION@", project.modVersion)
    replace("@MOD_ID@", project.modId)
    replace("@MOD_NAME@", project.modBaseName)
    replace("@MOD_ACCEPTED@", "[${project.modAcceptedVersions}]")
    replaceIn "${project.modBaseName}.java"
}

mixin {
    defaultObfuscationEnv searge
    add sourceSets.main, "mixins.${project.modId}.refmap.json"
}

dependencies {
    /*shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
        // Mixin includes a lot of dependencies that are too up-to-date
        exclude module: 'launchwrapper'
        exclude module: 'guava'
        exclude module: 'gson'
        exclude module: 'commons-io'
        exclude module: 'log4j-core'
    }*/

    compile project(":SkyblockRecords")
}

jar {
    archiveName = "${project.modBaseName}-${project.version}-for-MC-1.12.x.jar"

    /*from(configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }) {
        exclude 'META-INF', 'META-INF/**'
    }*/

    manifest {
        attributes(
                'FMLAT': "${project.modId}_at.cfg",
                'MixinConfigs': "mixins.${project.modId}.json",
                'TweakOrder': '0',
                'TweakClass': "${project.modGroup}.${project.modId}.tweaker.${project.modBaseName}Tweaker",
                'Main-Class': 'OpenErrorMessage'
        )
    }
}

processResources {
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include "**/*.info"
        include "**/*.properties"

        // replace version and mcversion
        expand "version": project.version, "mcversion": project.minecraft.version
    }

    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude "**/*.info"
        exclude "**/*.properties"
    }
}
브라이언 그레이엄 :

질문에 대한 Bjorn Vester의 의견 덕분에 문제를 해결했습니다. 대답은 항아리의 구성 음영 수집 호출을 ProjectA로 이동하는 것입니다.

// Move this to the jar section of ProjectA
from(configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }) {
    exclude 'META-INF', 'META-INF/**'
}

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

내 Gradle 프로젝트에 형제 프로젝트를 포함하려면 어떻게해야합니까?

Gradle에 다중 모듈 프로젝트를 어떻게 포함합니까?

서브 프로젝트가 메인 프로젝트에 의존하는 Gradle 프로젝트를 어떻게 구성합니까?

프로젝트는 Gradle 기반 프로젝트가 아닙니다. 루트 디렉토리에서 프로젝트를 열려면 어떻게합니까?

Gradle Android 프로젝트를 위해 IntelliJ 13에서 Android 테스트 모듈을 어떻게 생성합니까?

내 Gradle Java 프로젝트에 외부 .jar을 어떻게 포함합니까?

종속성을 포함하여 Git에서 프로젝트를 얻으려면 어떻게해야합니까?

스프링 부트 gradle 프로젝트의 .jar 루트에 폴더를 어떻게 구축합니까?

Gradle : Android 빌드에서 종속 Java 프로젝트의 로컬 jar을 어떻게 포함합니까?

영어가 아닌 시스템에서 Gradle 프로젝트를 어떻게 초기화합니까?

하위 모듈로도 작동하도록 Gradle 프로젝트에서 종속성을 어떻게 구성합니까?

bazel에서 외부 종속성과 내 프로젝트를 동시에 작업하려면 어떻게해야합니까?

기존 Gradle 프로젝트 (Java)에 Cucumber 테스트를 추가하려면 어떻게해야합니까?

Gradle: 하위 프로젝트에서 변수를 어떻게 재정의합니까?

프로젝트에서 특정 경로를 제외하도록 Android의 ktlint에 어떻게 지시합니까?

Gradle의 종속성에서 프로젝트 제외

Gradle Kotlin DSL을 사용하여 Eclipse 프로젝트를 생성하려면 어떻게 해야 합니까?

Maven 프로젝트의 배포에 종속성의 테스트 jar를 어떻게 포함합니까?

내 React 프로젝트에서 외부 API를 어떻게 사용합니까?

Gradle 또는 Maven을 사용하지 않는 프로젝트에 OkHttp를 어떻게 포함합니까?

Gradle 하위 프로젝트 : 메인 프로젝트에서만`check`를 실행하려면 어떻게해야합니까?

내 프로젝트 외부에서 정적 페이지를 어떻게 제공합니까?

Eclipse에서 프로젝트를 어떻게 결합합니까?

로컬 속성으로 gradle에서 micronaut를 어떻게 실행합니까?

Buildship에서 : Gradle 프로젝트를 빌드 된 jar로 어떻게 대체 할 수 있습니까?

종속성이있는 프로젝트에 ProGuard를 추가하려면 어떻게해야합니까?

Gradle에서 해결 된 종속성의 버전 번호를 어떻게 제거합니까?

다른 하위 프로젝트에서 가져온 종속성을 어떻게 제외 할 수 있습니까?

Gradle 프로젝트에서 Trove4j 라이브러리를 어떻게 사용할 수 있습니까?

TOP 리스트

뜨겁다태그

보관