Nexus 3.x creates a private repository and uploads jar packages using gradle

1, Create private warehouse

1. Open the Nexus homepage and log in, enter the setting interface, and click create

2. Select maven2 hosted warehouse

3. Enter the name of the created warehouse. If repeated deployment is allowed, you can change the Disable redeploy below to Allow Redeploy

2, Add private warehouse to Maven Public Library

1. Open the Maven public setting interface

2. Add the library we created to the Maven public group, and then you can find the index of the jar package we uploaded to our warehouse from the Maven public library.

3. Copy the address of Maven public to our project.

4.gradle example

repositories {
    maven {
        url "http://Domain name / repository / Maven public/“
    }
}

3, Example of using Gradle to upload jar package to private warehouse

Complete build.gradle file directly

group 'com.kingboy'
version '1.0'

apply plugin: 'java'
//This is the upload plug-in. It must have
apply plugin: 'maven-publish'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

ext {
    orikaVersion = '1.5.2'
    fastJsonVersion = '1.2.41'
    lombokVersion = '1.16.18'
    langVersion='3.7'
    collectsVersion='3.2.2'
    beanUtilsVersion='1.9.3'
    ioVersion='2.6'
}

dependencies {

    compile (
        "ma.glasnost.orika:orika-core:$orikaVersion",
        "org.projectlombok:lombok:$lombokVersion",
        "com.alibaba:fastjson:$fastJsonVersion",
        "org.apache.commons:commons-lang3:$langVersion",
        "commons-collections:commons-collections:$collectsVersion",
        "commons-beanutils:commons-beanutils:$beanUtilsVersion",
        "commons-io:commons-io:$ioVersion"
    )

}

//Package source code
task sourceJar(type: Jar) {
    from sourceSets.main.allJava
}

publishing {
    publications {
        maven(MavenPublication) {
            //Specify group/artifact/version information, which can be left blank. By default, the item group/name/version is used as groupId/artifactId/version
            groupId project.group
            artifactId project.name
            version project.version
            //Fill in components.web for war package and components.java for jar package
            from components.java

            //Configure upload source code
            artifact sourceJar {
                classifier "sources"
            }

        }
    }
    repositories {
        maven {
            //Specify the maven private server warehouse to upload
            url = "http://Your maven private server address / repository / maxlocky/“
            //Authenticated users and passwords
            credentials {
                username 'admin'
                password 'admin123'
            }
        }
    }
}

Keywords: Maven Gradle Java nexus

Added by capella07 on Sun, 03 May 2020 16:28:12 +0300