gradle打包并将源码上传到私服

gradle打包并将源码上传到私服

主要依赖Maven Publish Plugin插件,Maven Publish Plugin

build.gradle:


apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin:'java-library'
apply plugin:'maven-publish'

group = 'com.xxx'
version = '0.0.1-SNAPSHOT'
description = """"""

sourceCompatibility = 1.8
targetCompatibility = 1.8

tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
}


// 上传source
task sourcesJar(type: Jar) {
    from sourceSets.main.allJava
    classifier = 'sources'
}

task javadocJar(type: Jar) {
    from javadoc
    classifier = 'javadoc'
}

publishing {
	publications {
		mavenJava(MavenPublication) {
			groupId = "$project.group"
			artifactId = "$project.name"
			version = "$project.version"
			from components.java
			artifact sourcesJar
      artifact javadocJar
		}
	}
	repositories {
		maven {
			def snapshotsRepoUrl = "http://192.168.0.1:8000/nexus/content/repositories/snapshots"
			url "$snapshotsRepoUrl"
			credentials {
				username = 'dev'
				password = 'dev'
			}
		}
	}
}

你可能感兴趣的:(gradle)