I use maven-publish plugin to publish project dependencies to private nexus repo and use offline.
But compile success if use mavenCentral(), fails if use private repo and got lot of packages not found error, where is the problem?
buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
wrapperVersion = '1.0.17.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
defaultTasks 'clean', 'publish'
def repo = "http://privateNexus/nexus/repository"
group = 'com.company'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
}
configurations { compile.exclude module: 'spring-boot-starter-tomcat' }
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.RELEASE'
}
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-config')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-jetty')
compile('org.springframework.boot:spring-boot-starter-actuator')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile('org.springframework.cloud:spring-cloud-starter-netflix-hystrix')
compile('org.springframework.cloud:spring-cloud-starter-netflix-hystrix-dashboard')
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version:'2.0.0.RELEASE'
compile group: 'io.springfox', name: 'springfox-swagger2', version:'2.8.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version:'2.8.0'
compile group: 'com.alibaba', name: 'fastjson', version:'1.1.41'
compile group: 'com.alibaba', name: 'druid', version:'1.1.9'
compile group: 'mysql', name: 'mysql-connector-java', version:'5.1.45'
compile group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version:'1.1.1'
compile group: 'tk.mybatis', name: 'mapper-spring-boot-starter', version:'2.0.0'
compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version:'1.2.3'
compile group: 'com.thoughtworks.xstream', name: 'xstream', version:'1.4.10'
compile group: 'commons-httpclient', name: 'commons-httpclient', version:'3.1'
compile group: 'commons-collections', name: 'commons-collections', version:'3.2.2'
compile group: 'commons-lang', name: 'commons-lang', version:'2.6'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.1'
compile group: 'log4j', name: 'log4j', version:'1.2.17'
compile group: 'org.apache.poi', name: 'poi-ooxml', version:'3.15'
compile group: 'redis.clients', name: 'jedis', version:'2.8.2'
compile group: 'commons-net', name: 'commons-net', version:'3.3'
compile group: 'net.oschina.zcx7878', name: 'fastdfs-client-java', version:'1.27.0.0'
compile group: 'io.jsonwebtoken', name: 'jjwt', version:'0.9.0'
compileOnly group: 'org.projectlombok', name: 'lombok', version:'1.16.20'
}
publishing {
repositories {
maven {
url repo + "/3rd-party"
credentials {
username 'user'
password 'password'
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
configurations.compile.resolvedConfiguration.resolvedArtifacts.eachWithIndex { resolvedArtifact, n ->
println resolvedArtifact
project.publishing {
publications {
"maven${n}"(MavenPublication) {
artifact(resolvedArtifact.file) {
groupId = resolvedArtifact.moduleVersion.id.group
artifactId = resolvedArtifact.moduleVersion.id.name
version = resolvedArtifact.moduleVersion.id.version
classifier = resolvedArtifact.classifier
}
}
}
}
}