Gradle buildscript无法“编译构建”我的应用程序

时间:2014-08-12 12:28:33

标签: compiler-construction build gradle

这是我的build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.0.1')
    }
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'

group = 'com.myapp'
version = '0.1.0'

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.5'
    testCompile 'junit:junit:4.11'
}

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

publishing {
    publications {
        main(MavenPublication) {
            from components.java
            artifact sourcesJar
        }
    }

    artifactory {
        contextUrl = 'http://myprivaterepo'
        resolve {
            repository {
                repoKey = 'myteam-snapshot'
            }
        }
        publish {
            repository {
                repoKey = 'myteam-snapshot'
            }
            defaults {
                publications 'main'
            }
        }
    }

当我运行gradle jar --stacktrace时(我试图在本地编译和打包JAR)我得到:

org.gradle.groovy.scripts.ScriptCompilationException: Could not compile build file 'C:\Users\myuser\com\myapp\build.gradle'.
    at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.wrapCompilationFailure(DefaultScriptCompilationHandler.java:151)
    at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileScript(DefaultScriptCompilationHandler.java:117)
    at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileToDir(DefaultScriptCompilationHandler.java:64)
    at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler$CacheInitializer.execute(FileCacheBackedScriptClassCompiler.java:95)
    at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler$CacheInitializer.execute(FileCacheBackedScriptClassCompiler.java:80)
    ...rest of stack trace omitted for brevity

有人能看到这里发生了什么吗?

1 个答案:

答案 0 :(得分:2)

您缺少发布结束的结束括号。或者你只是错过了复制粘贴。