Search code examples
javamavennexussonatype

Sonatype Nexus, disallow downloading of source for certain account


We are hosting our own private maven repository using Sonatype Nexus for our company project. Now our customer wants to involve in developing our new project which depends on some jars on our Nexus server. However, we do not want our customer to download the source of the jars on Nexus. Is there a setting on Nexus that can specify an account to not download the source jar? (We build our project with Gradle, we can specify the account in the build.gradle file that we give out)


Solution

  • You can do this by creating a read privilege which uses the "all but sources (maven2)" repository target. This target uses the following regular expression:

    (?!.*-sources.*).*
    

    If your source jars do not use the standard maven "sources" classifier create a new target using a regular expression that matches your source jars.