Configurations - Sonatype Nexus Repository - Sonatype Community

Configurations

post by nagendra.raja on Jun 7, 2024

Raja Nagendra Kumar

It would be too smart way to give the details of integration against each integration as part of Browse view…

It is quite painful to know all such configurations… unless it has been fixed only for the commercial version…


post by laurencet on Jun 7, 2024

Laurence Taylor

For most of the format’s if you click that ‘copy’ button in the url column it will show you a link to our docs page for configuring the repository for that specific format. E.g. maven will show:


post by nagendra.raja on Jun 7, 2024

Configuration details that are more helpful say for maven…

nexus
*
${env.NEXUS_URL}/maven-public/
<servers>

releases
${env.NEXUS_USERNAME}
${env.NEXUS_PASSWORD}
snapshots
${env.NEXUS_USERNAME}
${env.NEXUS_PASSWORD}
</servers>
<profiles>
  nexus
  central
  ${env.NEXUS_URL}/maven-central/
  true
  true
  releases
  ${env.NEXUS_URL}/maven-releases/
  true
  false
</profiles>
<activeProfiles>
nexus
</activeProfiles>

and pom

...
  releases
  ${env.NEXUS_URL}/maven-releases/
  snapshots
  ${env.NEXUS_URL}/maven-snapshots/
...

for gradle kotlin DSL

import org.gradle.api.artifacts.dsl.RepositoryHandler

plugins {
    `java`
    `maven-publish`
}

repositories {
    configureNexusRepo(this)
}

publishing {
    publications {
        create(“mavenJava”) {
            from(components[“java”])
        }
    }
}
repositories {
maven {
    name = “releases”
    url = uri(“${System.getenv(“NEXUS_URL”)}/maven-releases/”)  
    credentials {
        username = System.getenv(“NEXUS_USERNAME”) ?: “"
        password = System.getenv(“NEXUS_PASSWORD”) ?: “"
    }
    isAllowInsecureProtocol = true
}
maven {
  name = “snapshots”
  url = uri(“${System.getenv(“NEXUS_URL”)}/maven-snapshots/”)  
  credentials {
    username = System.getenv(“NEXUS_USERNAME”) ?: “"
    password = System.getenv(“NEXUS_PASSWORD”) ?: “"
  }
  isAllowInsecureProtocol = true
}
}

// Extension function to configure the Nexus repository with insecure protocol allowed

fun RepositoryHandler.configureNexusRepo(handler: RepositoryHandler) {
    handler.maven {
        url = uri(“${System.getenv(“NEXUS_URL”)}/maven-public/”)  
        credentials {
            username = System.getenv(“NEXUS_USERNAME”) ?: “"
            password = System.getenv(“NEXUS_PASSWORD”) ?: “"
        }
        isAllowInsecureProtocol = true
    }
}

post by mboulianne on Jun 10, 2024

Martha B

Is your idea to have code samples like the ones you shared added to the documentation?

For example, the link in the modal links to this help doc for Maven: Configurations


post by nagendra.raja on Jun 10, 2024

True, against each repo we configure, not just the URL but how to change respective pom.xml, gradle build or package.json etc so that now that build start using local nexus etc…