Mryqu's Notes


  • 首页

  • 搜索
close

[Gradle] 输出依赖包

时间: 2015-04-16   |   分类: Tool   Gradle     |   阅读: 89 字 ~1分钟

下面我以https://spring.io/guides/gs/spring-boot/中的gs-spring-boot项目为例,使用Gradle输出依赖包。

首先对build.gradle做如下修改:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'gs-spring-boot'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

task copyToLib(type: Copy) {
    print configurations
    into "$buildDir/dep-libs"
    from configurations.runtime
}

build.dependsOn(copyToLib)

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    // tag::actuator[]
    compile("org.springframework.boot:spring-boot-starter-actuator")
    // end::actuator[]
    // tag::tests[]
    testCompile("org.springframework.boot:spring-boot-starter-test")
    // end::tests[]
}

首先可以在命令行中看到:

[configuration ':archives', configuration ':compile', configuration ':default', configuration ':runtime', configuration ':testCompile', configur:clean':testRuntime', configuration ':versionManagement']

跟下面Java插件- 依赖配置相比,少了一些,可能是根据build.gradle生成的configurations。 [Gradle] 输出依赖包 此时在gs-spring-boot\complete\build\dep-libs目录下有32个jar文件;如果改成from configurations.testCompile,则该目录下会有48个jar文件。

最后要说的的是,我输出这些依赖包的目的是为了可以摆脱Gradle,通过java命令执行程序或进行测试。

标题:[Gradle] 输出依赖包
作者:mryqu
声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!

#gradle# #dependencies# #jar# #output#
[JPA] 重温CascadeType
[Gradle] 执行Java类
  • 文章目录
  • 站点概览

Programmer & Architect

662 日志
27 分类
1472 标签
GitHub Twitter FB Page
© 2009 - 2023 Mryqu's Notes
Powered by - Hugo v0.120.4
Theme by - NexT
0%