zoukankan      html  css  js  c++  java
  • 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的语法真的很美,看起来很漂亮。。不过目前来说还不是很好用-----

  • 相关阅读:
    Linux下的lds链接脚本详解
    STM32启动过程解读与跟踪验证
    STM32的启动过程分析
    STM32启动过程--启动文件--分析
    STM32之中断
    STM32F4XX启动文件分析
    Synergy CORTEX M 启动流程
    AT 指令和常见错误码
    Tomcat部署时war和war exploded区别
    C++虚函数表解析***
  • 原文地址:https://www.cnblogs.com/whm-blog/p/7090422.html
Copyright © 2011-2022 走看看