I have a grails 2.5.3 app that uses Plugins and dependencies from maven. Now I'd like to use a Nexus server setup inside the company as a proxy for all the dependencies my app uses. However, I've never used Nexus before so I'm a bit confused as to how things would work.
I generated a POM.xml
for my grails app using grails create-pom com.mycompany
. The generated pom has the following artifactId
<groupId>com.mycompany</groupId>
<artifactId>myproj</artifactId>
<packaging>grails-app</packaging>
<version>1.0.0.R1</version>
Then I added the following to the POM.xml
<distributionManagement>
<repository>
<id>nexus</id>
<name>Nexus Repo</name>
<url>https://companynextus/content/repositories/myproj</url>
</repository>
</distributionManagement>
Then I run mvn deploy
Now I can see my entire WAR file and POM at https://companynextus/content/repositories/myproj/com/mycompany/myproj/1.0.0.R1/
At this point I just change my BuildConfig.groovy from:
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
}
To:
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsRepo "https://companynextus/content/repositories/myproj/com/mycompany/myproj/1.0.0.R1"
mavenRepo "https://companynextus/content/repositories/myproj/com/mycompany/myproj/1.0.0.R1"
}
But I get error while doing grails prod war
Resolve error obtaining dependencies: Could not find artifact org.grails.plugins:tomcat:zip:8.0.33 in https://companynextus/content/repositories/myproj/com/mycompany/myproj/1.0.0.R1(https://companynextus/content/repositories/myproj/com/mycompany/myproj/1.0.0.R1) (Use --stacktrace to see the full trace)
We created a nexus repository group (http://nexushost/content/groups/repo), that caches all external maven repos (maven central, grails repos), and our internal releases repo too.
As for deployment, we have one repo for snapshots (http://nexushost/content/repositories/snapshots), and one repo for releases (http://nexushost/content/repositories/releases/).
This is an excerpt of our BuildConfig with grails 2.5.1. It should not be very different with your version:
def env = System.getenv() + new HashMap(System.properties)
grails {
project {
repos {
SNAPSHOTS {
url = "http://nexushost/content/repositories/snapshots"
username = env.NEXUS_DEPLOY
password = env.NEXUS_DEPLOY_PASS
}
RELEASES {
url = "http://nexushost/content/repositories/releases/"
username = env.NEXUS_DEPLOY
password = env.NEXUS_DEPLOY_PASS
}
}
}
}
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
inherits("global") {
}
repositories {
inherits true
mavenLocal()
mavenRepo('http://nexushost/content/groups/repo') {
auth(
username: env.NEXUS_BUILD,
password: env.NEXUS_BUILD_PASS
)
}
mavenRepo('http://nexushost/content/repositories/snapshots') {
auth(
username: env.NEXUS_BUILD,
password: env.NEXUS_BUILD_PASS
)
updatePolicy 'always'
}
}
//....
}