gradle 使用本地maven 仓库 和 提交代码到maven

/*
 * This build file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * user guide available at https://docs.gradle.org/3.5.1/userguide/java_library_plugin.html
 */

// Apply the java-library plugin to add support for Java Library

apply plugin: 'java-library'
apply plugin: 'maven-publish'
//只有group 和 version 可以编辑。。project.name 不能修改。。。
project.group="zkdg"

project.version="0.1-SNAPSHOT"

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    maven { url 'file:///E:/whm/repository/'} //使用file协议,本地仓库
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
 
   // jcenter()
}

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:21.0'
    compile 'emark:emark-manager:0.0.1-SNAPSHOT'
    compile 'org.springframework:spring-context:4.3.9.RELEASE'
    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
    
}

//maven-publish 插件  提交到本地仓库
publishing {
    publications {
        maven(MavenPublication) {
            groupId project.group
            artifactId project.name
            version project.version
            //若是war包,就写components.web,若是jar包,就写components.java 
            from components.java
        }
    }
    repositories {
        maven {
    
            if (project.version.endsWith('-SNAPSHOT')) {
                url = "file:///E:/whm/repository/"
            } else {
                url = "release版本的仓库地址"
            }
    
           // credentials {
             //   username 'nexus仓库用户名'
             //   password 'nexus仓库密码'
          //  }
        }
        }
}
gradle publishMavenPublicationToMavenRepository 运行命令(如果失败,请去掉gradle)
复制代码

令人蛋疼的是gradle 无法下载文件到maven 仓库。。。。而是以缓存 存在。。。真够不习惯的,我还是用maven 吧。。而且 gradle 网上资料也有点少----

不过gradle的语法真的很美,看起来很漂亮。。不过目前来说还不是很好用-----

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值