Say you have a PL file you want to upload to Nexus with Gradle. How would such a script look like.
group 'be.mips' version = '1.4.0-SNAPSHOT'
In settings.gradle --> rootProject.name = 'stomp'
And let's say that the pl file is in a subdirectory dist (./dist/stomp.pl).
Now I want to publish this stomp.pl file to a nexus snapshot repository.
As long as you go with Java, then Gradle (just like Maven) works like a charm. But there's little documentation found what to do if you have a DLL, or a ZIP, or a PL (Progress Library).
I publish such artifacts for a long time. For example, ZIP archives with SQL files. Let me give you an example from real project:
build.gradle:
apply plugin: "base"
apply plugin: "maven"
apply plugin: "maven-publish"
repositories {
maven { url defaultRepository }
}
task assembleArtifact(type: Zip, group: 'DB') {
archiveName 'db.zip'
destinationDir file("$buildDir/libs/")
from "src/main/sql"
description "Assemble archive $archiveName into ${relativePath(destinationDir)}"
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact source: assembleArtifact, extension: 'zip'
}
}
repositories {
maven {
credentials {
username nexusUsername
password nexusPassword
}
url nexusRepo
}
}
}
assemble.dependsOn assembleArtifact
build.dependsOn assemble
publish.dependsOn build
gradle.properties:
# Maven repository for publishing artifacts
nexusRepo=http://privatenexus/content/repositories/releases
nexusUsername=admin_user
nexusPassword=admin_password
# Maven repository for resolving artifacts
defaultRepository=http://privatenexus/content/groups/public
# Maven coordinates
group=demo.group.db
version=SNAPSHOT
If you're using Kotlin DSL, declare the artifact as show below:
artifact(tasks.distZip.get())
where distZip
is the task that produces the zip file, which in the above example, is from the application plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With