#How to install Sonatype Nexus
##Create user
useradd -r -m nexus
passwd nexus
##Download and unpack Nexus
cd /opt
wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
tar xzf nexus-latest-bundle.tar.gz
##Change ownership
chown -R nexus:nexus /opt/nexus
chown -R nexus:nexus /opt/sonatype-work
##Configure
Edit /opt/nexus/bin/nexus
RUN_AS_USER=nexus
NEXUS_HOME=/opt/nexus
PIDDIR=/opt/nexus
##Autostart http://books.sonatype.com/nexus-book/reference/install-sect-service.html
ln -s /opt/nexus/bin/nexus /etc/init.d/
update-rc.d nexus defaults
service nexus start
##Publishing
Add the following to ~/.gradle/gradle.properties
NEXUS_USERNAME=username
NEXUS_PASSWORD=password
RELEASE_REPOSITORY_URL=http://localhost:8081/nexus/content/repositories/releases/
SNAPSHOT_REPOSITORY_URL=http://localhost:8081/nexus/content/repositories/snapshots/
See https://github.com/chrisbanes/gradle-mvn-push
Simplified version of gradle-mvn-push.gradle
apply plugin: 'maven'
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : ''
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL : ''
}
def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ''
}
def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ''
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
}
}
}
}
}
##Links