I'm trying to set a variable/property within Gradle during a war build for deployment. However, when I try setting it, it seems it just gets set to null whenever I try accessing it from groovy. I'm building on a local machine with the command (I've tried both):
gradle build -Dgrails.env=development -Dtest.variable=/app/testing/development or gradle war -Dgrails.env=development -Dtest.variable=/app/testing/development
Then I deploy the WAR file to a Tomcat server.
But when I try accessing that variable by System.getProperty("test.variable") I am receiving a null error on that property. What do I need to do to set a command-line variable in Gradle and have it be accessible in Groovy when I try to deploy the WAR file on a server? I know the grails.env is working as it is reading the proper values in the application.yml file, but I cannot access the given property that I am trying to set.
Related
We've started using an AWS CodeArtifact Maven repository. Before connecting, developers must run a command ("aws") to acquire a temporary access token. How can I configure Maven to acquire and use this token automatically, without requiring running a script, configuring an IDE or changing the simple command line "mvn install"?
Maybe there's a trick I'm overlooking.
The token must be "interpolated" in the element <server>/<password> in settings.xml. This file will pre-process either an environment variable ({$env.token}) or a Java system property ({$token}). It will not process a project property.
The repository password cannot be specified within the POM file.
The settings.xml file cannot use project properties.
The exec-maven-plugin cannot set an environment variable in the parent process (Windows). It can write to a file.
The properties-maven-plugin cannot set a dynamic system property (e.g., from a file or script output).
The surefire plugin binds to the test phase and forks a JVM.
The Windows setx command does not affect the running process.
UPDATE: Maven downloads repository metadata before the first phase, so no plugin will solve the problem.
I write test automation. I'm using Log4j2 in my gradle project, and I do development with Intellij. My automation runs at the end of a build. And everything that happens when the automation runs is logged using Log4j2. I pass in the properties that Log4j2 needs via the build.gradle file. The config properties that I pass to Log4j2 are the location of the config file, where to put the output log file, and what logging level I want. But when I'm writing tests and running them manually in intellij, it's like I'm short-circuiting the build.gradle file, and I get no properties and no logging when I do. How do I fix that?
I want to deploy an application into wildfly as war packaged using maven. The challenge i am facing is , i need to create a directory in the server and add my application's property file and a log4j property file into it. This must be automated using maven build.
First i need to know if this is possible to create a folder in server which is not the project home directory, but elsewhere using maven while deploying it ?
If so , how do i create it, and how to add the property files into it which is in my project resource folder.
Note: My deployment is automated through Jenkins.
I have an application that programmatically runs Maven command "clean package" at runtime, using plugin maven-invoker.
To be able to run this application on Cloud Foundry, we need to set Maven Home on the invoker.
This question is similar to Maven Invoker: IllegalStateException, except that we are deploying on Cloud Foundry but don't know how to get the value for Maven Home.
Is it possible to get it from CF environment?
The Java build pack does not install Maven or set any Maven related environment variables. You can however set whatever environment variables that you like via cf set-env or in the env block of your manifest.yml file.
https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#env-block
Your app when running on CF will run as the vcap user and it runs out of /home/vcap/app (or reference $HOME env variable). If you need to pick a location to use for Maven home, I would suggest putting it under that directory.
I am using the tomcat plugin to start Tomcat server using a war file i have built using the war plugin.
Before the app starts i need to set some environment variables.
Is there a way to do that?
From what I can see in the Gradle Tomcat plugin docs, the plugin runs Tomcat in the Gradle process. Environment variables for that process can only be set from outside Gradle, in a manner appropriate for your environment/OS. Alternatively, you might want to look into the Gradle Cargo and Gradle Arquillian plugins, which can also run containers in an external process.
PS: Please don't double-post here and on http://forums.gradle.org.