I’m using Gradle 2.3. When building my mule 3.7 zip artifact, assuming all the tests pass and assembly of the war is successful, I’d like to copy my ZIP to my local $MULE_HOME/apps directory. So I have defined this in my build.gradle script:
task deploylocal() << {
println "Copy from ${buildDir} into $System.env.MULE_HOME/apps"
copy{
from "${buildDir}"
into "$System.env.MULE_HOME/apps"
include '*.zip'
}
}
Then, execute the gradle command:
gradle build deploylocal
You can achieve this by using mule-gradle-plugin. Refer "Special Features" section.
The build can be configured to deploy the resulting artifact on a mule
standalone server:
mule.installPath = '/path/to/mule/home'
Alternatively it can be configured through the MULE_HOME environment variable.
Finally to deploy:
$ gradle deployLocally
More details can be found at mule-gradle-plugin documentation
Hope this helps.
Related
I have a gradle 6.x project, where I use the distribution plugin to create .zip distribution.
https://docs.gradle.org/6.9/userguide/distribution_plugin.html
I use the following command to create a ZIP dist:
gradle distZip
However, I have some jar files that I need to put inside a distribution, and when only running this command, it creates a basically empty zip file, because these jars would be located at /build/... .
How can I tell the distZip task, to build these jars before packaging, preferably without running tests?
Thanks!
When I do a ./gradlew publishToMavenLocal it publishes to my default maven home directory of: ~/.m2.
I would instead like to publish to a custom maven repository path.
To do with with mvn command line, you can specify the command line -Dmaven.repo.local=$HOME/.my/other/repository
(See: https://stackoverflow.com/a/7071791/1174024)
But what about when publishing with Gradle? Is there a way to publish to a custom path by using an environment variable, or something similar?
You can add a system property maven.repo.local with the path.
Example:
./gradlew -Dmaven.repo.local=/path/to/local/repo publishToMavenLocal
Source: https://github.com/gradle/gradle/blob/0cb6116e150ec397f2e6c935ab4a851b48d2cf67/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/mvnsettings/DefaultLocalMavenRepositoryLocator.java#L46
Note that the same thing does NOT work if you specify as a gradle project -P property. Only reads system properties.
I am using maven and jboss plugin. When I run this command
mvn clean install jboss-as:deploy
I will deploy in currently running jboss but I want to know which jar file it deploy..jar file generated in target folder or jar file in local repository?
By default it gets the bits from target folder. Look at targetDir property of the plugin.
You can find the details in the plugin documentation.
I am trying to deploy a dropwizard app on heroku which fails to launch.
Its works fine locally using "gradle run server config.yml"
I am using gradle for build and when I push to heroku the build is successful.
My gradle stage task dependsOn clean and jar(fat jar creation)
My Procfile has:
web: java $JAVA_OPTS -jar dropwizard-app/build/libs/dropwizard-app.jar server dropwizard-app/config.yml
The above fails with "Unable to access jarfile dropwizard-app/build/libs/dropwizard-app.jar"
I have tried unsuccessfully with
web: java $JAVA_OPTS -jar build/libs/dropwizard-app.jar server config.yml
I have also tried to execute using gradle command
web: gradle run server config.yml
This gives an error
bash: gradle command not found
My gradle tasks are as follows:
task stage(dependsOn: ['clean', 'jar'])
run {
args 'server', 'config.yml'
}
jar {
manifest {
attributes 'Title': 'dropwizard-app', 'Version': version,'Main-Class': mainClassName
}
archiveName 'dropwizard-app'
dependsOn configurations.runtime
from {
configurations.compile.collect {it.isDirectory()? it: zipTree(it)}
}
}
Am I missing out something here?
How do I launch my dropwizard application?
Got it working.
As mentioned above I was trying to execute dropwizard-app.jar
but the jar created on heroku was not of mentioned name, it took the default archive name
starting with build-'some autogenerated value'.jar
So I added a settings.gradle to my project:
rootProject.name = 'dropwizard-app'
Now the jar created was dropwizard-app-1.0.jar
as I have set the version attribute to 1.0 in build.gradle
I used heroku run bash
to check the files on heroku
I wrote a Maven-based deployment guide describing how to deploy a Dropwizard to Heroku which may offer some help. While it doesn't cover gradle, it does point out some common gotchas with the Heroku environment.
For example, your Procfile should look like this:
web java $JAVA_OPTS -Ddw.http.port=$PORT -Ddw.http.adminPort=$PORT -jar path/to/dw/module/target/example-develop-SNAPSHOT.jar server path/to/dw/module/config-heroku.yml
I am learning to use git and gradle to build Spring 3.2 on my local system.
I cloned the git repo and used the gradlew command to start the build like so:
gradlew build
I also have the GRADLE_HOME set up and added GRADLE_HOME/bin to my PATH variable.
Every time I start up the build I see a .gradle directory being created in my directory C:\Users\Ayusman and it seems to download gradle binaries.
My questions:
Since I already have gradle installed on my system; why does it have to download gradle?
Can I force gradle to put my dependencies in a specific directory instead of the users folder (like I can specify in maven)?
Can gradle be pointed to pull from a local repo instead of internet?
ad 1. In order to build with your locally installed Gradle, you have to invoke gradle rather than gradlew. The purpose of gradlew (called the Gradle Wrapper) is for everybody to use the same Gradle version and not having to install Gradle manually.
ad 2. To change where Gradle puts dependencies (and other global information), you can set the GRADLE_USER_HOME environment variable.
ad 3. You just need to add another repository declaration to build.gradle. Something like:
allprojects {
repositories {
maven {
url "http://..."
}
}
}
If you want to use this repository for all your builds, you can put the same declaration into ~/.gradle/init.gradle.
Because gradlew invokes the gradle wrapper, which downloads the version of gradle that the build script has been written for, instead of using your version, which might not be compatible. It does that only once, and then reuses the downloaed version. If you want to use your version of gradle, use the gradle command rather than gradlew, but it might not work if you don't have the appropriate version.
AFAIK, this is done by defining the GRADLE_USER_HOME environment variable.
See http://www.gradle.org/docs/current/userguide/userguide_single.html#sec:repositories