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的语法真的很美,看起来很漂亮。。不过目前来说还不是很好用-----

  • 相关阅读:
    Leetcode645.Set Mismatch错误的集合
    Leetcode622.Design Circular Queue设计循环队列
    Leetcode628.Maximum Product of Three Numbers三个数的最大乘积
    Leetcode633.Sum of Square Numbers平方数之和
    Leetcode617.Merge Two Binary Trees合并二叉树
    Leetcode606.Construct String from Binary Tree根据二叉树创建字符串
    SQL Sever实验二 交互式 SQL
    [bzoj2124]等差子序列_线段树_hash
    [bzoj4084][Sdoi2015]双旋转字符串_hash
    [bzoj1708][Usaco2007 Oct]Money奶牛的硬币_动态规划_背包dp
  • 原文地址:https://www.cnblogs.com/whm-blog/p/7090422.html
Copyright © 2011-2022 走看看