gradle打包jar包并上传至nexus私服

apply plugin: 'java'

apply plugin: 'groovy'

apply plugin: 'maven'

apply plugin: 'idea'

apply plugin:'java-library'

apply plugin:'maven-publish'

group 'com.ittx'

version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

targetCompatibility = 1.8

jar {

String someString = ''

configurations.runtime.each { someString = someString + " lib\\" + it.name }

}

tasks.withType(JavaCompile) {

options.encoding = 'UTF-8'

}

repositories{

mavenLocal()

}

task sourcesJar2(type: Jar, dependsOn: classes) {

classifier='sources'

from sourceSets.main.allSource

}

artifacts {

archives sourcesJar2

}

 

def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath

def remoteMaveRepo = 'http://192.16.100.10:8081/repository/maven-snapshots/'

uploadArchives {

repositories {

mavenDeployer {

repository(url: localMavenRepo)

snapshotRepository(url: remoteMaveRepo) {

authentication(userName: "admin", password: "123546")

}

println "开始打包:project:$project.name,version:$version"

pom.version = "$version"

pom.artifactId = "$archivesBaseName"

pom.groupId = "$project.group"

}

}

}

你可能感兴趣的:(java)