多个可传递排除项不在gradle中工作

多个可传递排除项不在gradle中工作,gradle,Gradle,我正试图清理我的依赖关系,并消除我遇到的一些类集合。由于某种原因,我的排除不起作用 这是我的剧本 description = 'Onus Pride Collective System' buildscript { repositories { maven { url 'http://repo.springsource.org/plugins-release' } } dependencies { classpath 'org.sprin

我正试图清理我的依赖关系,并消除我遇到的一些类集合。由于某种原因,我的排除不起作用

这是我的剧本

description = 'Onus Pride Collective System'

buildscript {
    repositories {
        maven { url 'http://repo.springsource.org/plugins-release' }
    }
    dependencies {
        classpath 'org.springframework.build.gradle:docbook-reference-plugin:0.2.2'
    }
}

configurations.all {
    exclude group: 'servlet', module: 'servlet-api', version: '2.5'
    exclude group: 'ch.qos.logback'
    exclude group: 'log4j', module: 'log4j', version:'1.2.17'
    exclude group: 'org.springframework', module: 'spring-core', version: '3.2.3.RELEASE'
    exclude group: 'org.springframework', module: 'spring-tx', version: '3.0.7.RELEASE'
}

configure(allprojects) {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'

    group = 'com.onuspride'
    version = '0.0.1'

    sourceSets.test.resources.srcDirs = ['src/test/resources', 'src/test/java']
    test.systemProperty("java.awt.headless", "true")

    ext {
        akka = '2.2.3'
        akkaSeries = '_2.10'
        apacheLog4jVersion = '2.0-beta9'
        aspectjVersion = '1.7.2'
        cglibVersion = '2.2.2'
        commonsCodecVersion = '1.5'
        commonsDigesterVersion = '2.1'
        commonsFileuploadVersion = '1.3'
        commonsLang3Version = '3.1'
        elApiVersion = '1.0'
        fasterxmlJacksonVersion = '2.3.0'
        flexJsonVersion = '2.1'
        ginVersion = '2.0.0'
        googleAPIClient = '1.17.0-rc'
        googleAPIDrive = 'v2-rev110-1.17.0-rc'
        googleAPIOauth2 = 'v2-rev59-1.17.0-rc'
        googleJackson = '1.15.0-rc'
        guavaVersion = '14.0.1'
        guiceVersion = '3.0'
        gwtpVersion = '1.0.3'
        gwtqueryVersion = '1.3.2'
        gwtsecurityVersion = '1.2.3'
        gwtVersion = '2.5.1'
        hamcrestDateVersion = '0.9.5'
        hibernateValidator = '5.0.2.Final'
        ioSpray = '1.2.0'
        javaxServletVersion = '3.0.1'
        jedisVersion = '2.1.0'
        jettyVersion = '9.1.0.v20131115'
        jodaTimeVersion = '1.6'
        json4sVersion = '3.2.6'
        jspApiVersion = '2.1'
        jstlApiVersion = '1.2'
        jukitoVersion = '1.1'
        junitVersion = '4.11'
        lmaxDistruptorVersion = '3.2.0'
        neo4jVersion = '2.0.0'
        persistenceApiVersion = '1.0'
        scalaLangVersion = '2.10.2'
        slf4jVersion = '1.7.5'
        socialSigninTwitterVersion = '1.1.0-SNAPSHOT'
        springDataNeo4jVersion = '2.3.3.RELEASE'
        springDataRedis = '1.1.0.RELEASE'
        springJsResourcesVerison = '2.3.2.RELEASE'
        springJsVersion = '2.3.2.RELEASE'
        springScalaVersion = '1.0.0.RC1'
        springSecurityVersion = '3.2.0.RELEASE'
        springSocialGoogleVersion = '1.0.0.M3'
        springSocialVersion = '1.1.0.M4'
        springVersion = '3.2.6.RELEASE'
        tilesJspVersion = '2.2.2'
    }

    repositories {
        mavenCentral()
        mavenLocal()
        maven { url "http://maven.springframework.org/release" }
        maven { url "https://repo.springsource.org/milestone" }
        //maven { url "http://maven.springframework.org/milestone" }
        maven { url "http://gabiaxel.github.io/maven" }
        maven { url "http://download.java.net/maven/2" }
    }

}

configure(subprojects) { subproject ->

    jar {
        manifest.attributes['Implementation-Title'] = subproject.name
        manifest.attributes['Implementation-Version'] = subproject.version

        from("${rootProject.projectDir}/src/dist") {
            include "license.txt"
            include "notice.txt"
            into "META-INF"
            expand(copyright: new Date().format('yyyy'), version: project.version)
        }
    }

    javadoc {
        options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
        options.author = true
        options.header = project.name
        //options.overview = "${projectDir}/src/main/java/overview.html"
    }

    task sourcesJar(type: Jar, dependsOn:classes) {
        classifier = 'sources'
        from sourceSets.main.allJava
    }

    task javadocJar(type: Jar) {
        classifier = 'javadoc'
        from javadoc
    }

    artifacts {
        archives sourcesJar
        archives javadocJar
    }
}

project('inclusive') {
    apply plugin: 'scala'
    sourceCompatibility=1.7
    targetCompatibility=1.7

    description = 'Common library.  This is used to tie the various systems together.'
    dependencies {
        compile "joda-time:joda-time:$jodaTimeVersion"
        compile "org.scala-lang:scala-library:$scalaLangVersion"

        //compile "com.fasterxml.jackson.core:jackson-annotations:$fasterxmlJacksonVersion"
        //compile "org.apache.commons:commons-lang3:$commonsLang3Version"
        //compile "org.springframework.social:spring-social-core:$springSocialVersion"
        //compile "org.springframework.social:spring-social-security:$springSocialVersion"
    }
}

project('wisdom') {
    apply plugin: 'scala'
    //apply plugin: 'war'
    //apply plugin: 'jetty'
    sourceCompatibility=1.7
    targetCompatibility=1.7
    description = 'Common library.  This is used to tie the various systems together.'

    test.systemProperty("java.awt.headless", "true")

    dependencies {

        compile project (':inclusive')

        //compile "com.gwtplatform:gwtp-dispatch-client:$gwtpVersion"
        //compile "com.gwtplatform:gwtp-dispatch-server-spring:$gwtpVersion"
        //compile "commons-codec:commons-codec:$commonsCodecVersion"
        //compile "commons-digester:commons-digester:$commonsDigesterVersion"
        //compile "commons-fileupload:commons-fileupload:$commonsFileuploadVersion"
        //compile "javax.el:el-api:$elApiVersion"
        //compile "javax.persistence:persistence-api:$persistenceApiVersion"
        //compile "javax.servlet.jsp.jstl:jstl-api:$jstlApiVersion"
        //compile "javax.servlet.jsp:jsp-api:$jspApiVersion"
        compile "joda-time:joda-time:$jodaTimeVersion"
        //compile "net.sf.flexjson:flexjson:$flexJsonVersion"
        //compile "org.apache.commons:commons-lang3:$commonsLang3Version"
        //compile "org.apache.tiles:tiles-jsp:$tilesJspVersion"

        //
        //compile "org.hibernate:hibernate-validator:$hibernateValidator"
        //compile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
        //compile "org.slf4j:slf4j-log4j12:$slf4jVersion"
        //compile "org.springframework.security:spring-security-ldap:$springSecurityVersion"
        //compile "org.springframework.security:spring-security-taglibs:$springSecurityVersion"
        //compile "org.springframework.social:spring-social-config:$springSocialVersion"
        //compile "org.springframework.social:spring-social-core:$springSocialVersion"
        //compile "org.springframework.social:spring-social-facebook:$springSocialVersion"
        //compile "org.springframework.social:spring-social-google:$springSocialGoogleVersion"
        //compile "org.springframework.social:spring-social-security:$springSocialVersion"
        //compile "org.springframework.social:spring-social-twitter:$springSocialVersion"
        //compile "org.springframework.social:spring-social-web:$springSocialVersion"
        //compile "org.springframework.webflow:spring-js-resources:$springJsVersion"
        //compile "org.springframework:spring-aop:$springVersion"
        //compile "org.springframework:spring-aspects:$springVersion"
        //compile "org.springframework:spring-context:$springVersion"
        //runtime "javax.xml.bind:jaxb-api:2.2.9"
        //runtime "org.slf4j:slf4j-jdk14:1.7.5"


        //compile "cglib:cglib:$cglibVersion"
        //compile "com.fasterxml.jackson.core:jackson-core:$fasterxmlJacksonVersion"
        //compile "com.fasterxml.jackson.core:jackson-databind:$fasterxmlJacksonVersion"
        //compile "com.google.api-client:google-api-client:$googleAPIClient"
        //compile "com.google.apis:google-api-services-drive:$googleAPIDrive"
        //compile "com.google.apis:google-api-services-oauth2:$googleAPIOauth2"
        //compile "com.google.http-client:google-http-client-jackson:$googleJackson"
        //compile "com.jayway.jsonpath:json-path:0.8.1"
        //compile "com.sun.jersey:jersey-core:1.9"
        compile "com.typesafe.akka:akka-actor$akkaSeries:$akka"
        compile "com.typesafe.akka:akka-slf4j$akkaSeries:$akka"
        compile "io.spray:spray-can:$ioSpray"
        compile "io.spray:spray-routing:$ioSpray"
        //compile "io.spray:spray-servlet:1.2.0"
        //compile "javax.servlet:javax.servlet-api:$javaxServletVersion"
        compile "org.apache.logging.log4j:log4j-api:$apacheLog4jVersion"
        compile "org.apache.logging.log4j:log4j-core:$apacheLog4jVersion"
        compile "org.apache.logging.log4j:log4j-slf4j-impl:$apacheLog4jVersion"
        compile "com.lmax:disruptor:$lmaxDistruptorVersion"

        //compile "org.aspectj:aspectjrt:$aspectjVersion"
        //compile "org.aspectj:aspectjweaver:$aspectjVersion"
        //compile "org.eclipse.jetty:jetty-webapp:$jettyVersion"
        //compile "org.eclipse.jetty:jetty-jmx:$jettyVersion"
        compile "org.json4s:json4s-native_2.10:$json4sVersion"
        compile "org.scala-lang:scala-library:$scalaLangVersion"
        compile "org.springframework.data:spring-data-neo4j:$springDataNeo4jVersion"
        compile "org.springframework.scala:spring-scala_2.10:$springScalaVersion"
        //compile "org.springframework.data:spring-data-redis:$springDataRedis"
        //compile "org.springframework:spring-core:$springVersion"
        //compile "redis.clients:jedis:$jedisVersion"
        //compile "uk.co.modular-it:hamcrest-date:$hamcrestDateVersion"
        //compile group: 'org.neo4j', name: 'neo4j', version: "$neo4jVersion"
        //compile group: 'org.neo4j.app', name: 'neo4j-server', version: "$neo4jVersion", classifier: 'static-web'

        //testCompile "com.jayway.jsonpath:json-path-assert:0.8.1"
        //testCompile "com.typesafe.akka:akka-testkit$akkaSeries:$akka"
        //testCompile "io.spray:spray-testkit:$ioSpray"
        //testCompile "junit:junit:$junitVersion"
        //testCompile "org.mockito:mockito-all:1.9.5"
        //testCompile "org.springframework:spring-test:$springVersion"
    }

    tasks.withType(ScalaCompile) {
        scalaCompileOptions.useAnt = false
    }
}

configure(rootProject) {
    description = 'Spring Social'

    apply plugin: 'docbook-reference'

    reference {
        ext.sourceDir = file('src/reference/docbook')
    }

    // don't publish the default jar for the root project
    configurations.archives.artifacts.clear()

    dependencies { // for integration tests
    }

    task api(type: Javadoc) {
        group = 'Documentation'
        description = 'Generates aggregated Javadoc API documentation.'
        title = "${rootProject.description} ${version} API"
        options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
        options.author = true
        options.header = rootProject.description
        options.overview = 'src/api/overview.html'
        options.links(
                'http://docs.jboss.org/jbossas/javadoc/4.0.5/connector'
        )
        source subprojects.collect { project ->
            project.sourceSets.main.allJava
        }
        destinationDir = new File(buildDir, "api")
        classpath = files(subprojects.collect { project ->
            project.sourceSets.main.compileClasspath
        })
        maxMemory = '1024m'
    }

    task docsZip(type: Zip) {
        group = 'Distribution'
        classifier = 'docs'
        description = "Builds -${classifier} archive containing api and reference " +
                "for deployment at static.springframework.org/spring-social/docs."

        from('src/dist') {
            include 'changelog.txt'
        }

        from (api) {
            into 'api'
        }

        from (reference) {
            into 'reference'
        }
    }

    task schemaZip(type: Zip) {
        group = 'Distribution'
        classifier = 'schema'
        description = "Builds -${classifier} archive containing all " +
                "XSDs for deployment at static.springframework.org/schema."

        subprojects.each { subproject ->
            def Properties schemas = new Properties();

            subproject.sourceSets.main.resources.find {
                it.path.endsWith('META-INF/spring.schemas')
            }?.withInputStream { schemas.load(it) }

            for (def key : schemas.keySet()) {
                def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1')
                assert shortName != key
                File xsdFile = subproject.sourceSets.main.resources.find {
                    it.path.endsWith(schemas.get(key))
                }
                assert xsdFile != null
                into (shortName) {
                    from xsdFile.path
                }
            }
        }
    }

    task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
        group = 'Distribution'
        classifier = 'dist'
        description = "Builds -${classifier} archive, containing all jars and docs, " +
                "suitable for community download page."

        ext.baseDir = "${project.name}-${project.version}";

        from('src/dist') {
            include 'readme.txt'
            include 'license.txt'
            include 'notice.txt'
            into "${baseDir}"
            expand(copyright: new Date().format('yyyy'), version: project.version)
        }

        from(zipTree(docsZip.archivePath)) {
            into "${baseDir}/docs"
        }

        from(zipTree(schemaZip.archivePath)) {
            into "${baseDir}/schema"
        }

        subprojects.each { subproject ->
            into ("${baseDir}/libs") {
                from subproject.jar
                if (subproject.tasks.findByPath('sourcesJar')) {
                    from subproject.sourcesJar
                }
                if (subproject.tasks.findByPath('javadocJar')) {
                    from subproject.javadocJar
                }
            }
        }
    }

    artifacts {
        archives docsZip
        archives schemaZip
        archives distZip
    }

    task wrapper(type: Wrapper) {
        description = 'Generates gradlew[.bat] scripts'
        gradleVersion = '1.4'
    }

}

class Ajc extends DefaultTask {
    Ajc() {
        logging.captureStandardOutput(LogLevel.INFO)
    }

    @TaskAction
    def compile() {
        logger.info "Running ajc ..."

        ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath)
        ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.classesDir.absolutePath,
                source: project.sourceCompatibility,
                target: project.targetCompatibility,
                aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true', Xlint: "ignore") {
            sourceroots {
                sourceSet.java.srcDirs.each {
                    pathelement(location: it.absolutePath)
                }
            }
        }
    }
}

奇怪的是,它完全排除了ServletAPI2.5。但它忽略了其他因素。我仍然在我的依赖项(由neo带来)和spring的多个版本中获得了logback。我的脚本有什么问题吗?

这是一个多项目生成,但仅为根项目声明了排除。与几乎所有其他构建信息一样,配置是针对每个项目的。因此,必须为
所有项目
子项目
、或需要它们的特定项目(可能不是根项目)声明排除项。

请将构建脚本缩减到相关部分(或者更好,将其缩减到显示相同问题的最小脚本),并显示
gradle dependencyInsight--configuration compile--dependency logback
的输出。我得到
在配置:compile'
中找不到与给定输入匹配的依赖项。我得到了同样的东西,当我运行它的弹簧核心,我用了所有的地方。我不喜欢删减脚本,因为它是从spring Builder中复制出来的,我仍然不确定它到底在做什么,所以我不确定它是否相关。那么你如何判断你仍然得到了logback?(也可以尝试使用
--configuration runtime
),因为当我在intellij中刷新项目时,它就在那里。以及spring的多个副本。当我用
gradle-q dependencies-willigence:dependencies
转储整个依赖关系树时,它们就在那里。被列为Neo4j带来的。但是那里的jar真的破坏了我的slf4j配置。很漂亮,我把它放在
configure(subprojects){subproject->configurations.all{…}
中,它成功了。谢谢