首页 文章

Gradle多项目不下载依赖项

提问于
浏览
0

我有一个多项目gradle,但在我的控制器模块gradle似乎没有下载spring-boot依赖(或任何其他什么 - 所以) . 根gradle构建运行顺利,完全没有错误,但我无法将任何依赖类导入到我的源代码中 .

这是gradle文件:

多项目的根build.gradle

apply plugin: 'idea'

subprojects {
    apply plugin: 'idea'
}

// Ensure the IWS Workspace file is also deleted (this is not the default)
task cleanIdea(dependsOn: [cleanIdeaProject, cleanIdeaWorkspace, cleanIdeaModule],
               type: Delete,
               overwrite: true,
               description: 'Cleans IDEA project files (IML, IPR, IWS)',
               group: 'IDE')

task clean(description: 'Deletes the build directory produced by Gradle and the out directory produced by IntelliJ IDEA.',
           group: 'build') << {
    delete "${buildDir}", 'out'
}

内部项目build.gradle

def version = '0.0.1'

buildscript {
    repositories {
        maven { url "http://repo.spring.io/libs-snapshot" }
        mavenCentral()
    }

    dependencies {
        classpath('org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE')
        //classpath 'com.github.ben-manes:gradle-versions-plugin:0.3'
    }
}

apply plugin: 'java'            // http://www.gradle.org/docs/current/userguide/java_plugin.html
apply plugin: 'application'     // http://www.gradle.org/docs/current/userguide/application_plugin.html
apply plugin: 'war'             // http://www.gradle.org/docs/current/userguide/war_plugin.html
apply plugin: 'spring-boot'

springBoot {
    mainClass = "com.mozart.Mozart"
}


idea.module {
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-snapshot" }
}

configurations {
    all {
        exclude(group: 'commons-logging')  // Never include commons-logging (use SLF4J instead)
        exclude(group: 'log4j')  // Never include log4j (use SLF4J instead)
    }
}

jar.manifest {
    attributes("Implementation-Title": "Mozart Web Site", "Implementation-Version": version)
}

processResources << {
    // Workaround for Tomcat. Tomcat requires META-INF to be a non-empty subdirectory of
    // build/classes/main in order for Servlet 3.0 Application Initializer scanning to work
    copy {
        // http://gradle.org/docs/current/userguide/working_with_files.html
        from "src/main/resources/META-INF/dummy-file-required-by-tomcat.txt"
        into "${sourceSets.main.output.classesDir}/META-INF"
    }
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
}

task runService(description: 'Starts up the service using Tomcat.',
        group: 'application') << {
    logging.setLevel(LogLevel.INFO)
    ant.java(classname: 'com.thoughtworks.learnangularjs.server.TomcatServer',
            classpath: sourceSets.test.runtimeClasspath.asPath,
            fork: true,
            failonerror: true)
}

编辑:settings.gradle

rootProject.name = 'MozartWeb'
include 'MozartModel', 'MozartWebSite', 'MozartWebSiteClient'

任何帮助将不胜感激 .

1 回答

  • 0

    好的好的!所以不要介意我!考虑到我将项目导入IntelliJ,我认为我不需要明确地称之为gradle想法......但就是这样! = /

    在检查调试时,我发现依赖关系已经解决了......

    14:50:40.050 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration MozartWeb:MozartWebSite:unspecified(classpath).
    14:50:40.050 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency MozartWeb:MozartWebSite:unspecified(classpath) -> org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE(classpath)
    14:50:40.051 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE
    14:50:40.051 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE using repositories [maven, MavenRepo]
    14:50:40.051 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache module-metadata.bin (C:\Users\Igor\.gradle\caches\modules-2\metadata-2.16\module-metadata.bin)
    14:50:40.052 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.IvyXmlModuleDescriptorParser] post 1.3 ivy file: using exact as default matcher
    14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE' in 'maven'
    14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Using org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE from Maven repository 'maven'
    14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE(default).
    14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE(default) -> org.springframework.boot:spring-boot-loader-tools:1.3.0.RELEASE(compile,runtime)
    14:50:40.054 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version org.springframework.boot:spring-boot-loader-tools:1.3.0.RELEASE
    

    但是类路径搞砸了......

    14:50:40.066 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in C:\Users\Igor\AppData\Local\Temp\gradle7086690745953254784.bin. Wrote root MozartWeb:MozartWebSite:unspecified:classpath.
    

    希望这有助于其他人坚持这种愚蠢的事情 .

    C ya

相关问题