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