I have two configurations I need to change after building a prod war with grails 1.3.2. I know the project can be setup in ways to do this externally in the first place, but that's not an option at this moment.
1) Need to change environments.production.hibernate.default_schema defined in DataSource.groovy
2) Need to change environments.production.grails.serverURL defined in Config.groovy
Is there any way to edit the war or pass overriding arguments when running the war in JBoss?
If you want to change these properties in a production application with out redeployment your out of luck. Your only option is using external properties files which will require a rebuild and redeployment of the app. See the following link. http://www.comitservices.com/wp/?p=133
Related
I'm using payara micro to run my war application. Because one of the services I need to access requires metro ws, I need to provide a wsit client file to the application.
When I add it inside the war, it works fine, but since I need this file to be different depending on the environment I'm deploying, I need to inject the correct one as an external dependency to the server and I only know the right one at deployment stage. Meanwhile I already created all the artifacts and the docker image.
How can I add this file to the application without opening the war adding it manually and re build the war? I'm looking for a solution like the external modules for wildly.
I tried the --addLibs but it requires a jar.
This problem was solved by putting the right file inside the image during the deploy stage. This way we use always the same filename, but different files for each environment.
For some time we had TFS2017 run our unit test (xUnit) in the build proces. Every test project has it own app.config file declaring some appSettings.
Our code is looking at those app settings like ConfigurationManager.AppSettings["someSetting"]
Recently, some developers upgraded from VS2015 to VS2017 (not sure if it is related), our test started to fail.
Turns out that the the appSettings where loaded from vstest.console.exe.configinstead of the app.config file included in the test project.
While we where able to add our settings to vstest.console.exe.config this is not our preferred solution, we would like to have the test using the app.config file again.
Any ideas on how to accomplish this? I have no idea what changed in the first place.
Make sure WorkingFolder is not changed. It should be relative to the folder containing the test.dll.
Also, you can try the <exec> task in MSBuild to run the console runner.
When running multiple assemblies, you can specify the configuration file for each assembly using ItemGroup metadata. The <xunit> task looks for metadata named ConfigFile on each item in your item group. Configuration files are ignored when AppDomains is set to false.
I'm trying to add a new environment to our Grails WAR (let's call it "staging"). I can manage the configuration in Config.groovy and DataSource.groovy and access the right configuration at run-time with -Dgrails.env, but how do I build this WAR?
The Grails documentation does not cover this case and the links on the page seem to be outdated.
You are so very close to having the right combination in your question, this should work:
grails -Dgrails.env=staging war
Actually, the documentation for the war command even uses 'staging' as the environment used.
The same goes for any environment-specific command:
grails -Dgrails.env=<environment name> <command>
I've got a Tomcat6 server that runs multiple Instances for two separate grail apps.
When I compile my WAR file for deployment normally
run-app -Dgrails.env=production war test.war
It deploys correctly and everything works as it is suppose too.
The problem is, I don't want the JAR files included in my WAR.
So I use the following command line instead
run-app -Dgrails.env=production war test.war --nojars
Now when my grails app deploys (it doesn't) I get a java.lang.NoSuchMethodError
I have copied the lib folder (from my initial test.war) to the following locations
${catalina.base}/shared/lib
${catalina.home}/shared/lib
${catalina.home}/lib
None of these work.
My catalina.properties all point to the correct locations.
Any ideas?
A few ideas:
BuildConfig.groovy has inherits global, which has the app inherit all of the grails/plugins dependencies. If you change this, it may affect both your build and packaging - plus I have yet to encounter any documentation on what type of other things you can do with the inherits DSL
Grails deployment documentation suggests there is a way to customize which dependencies make it into the war file: http://grails.org/doc/latest/guide/17.%20Deployment.html
Event hooks give you access to provide a closure routine into various stages of the grails lifecycle. Can it strip out framework jars from the final war? Haven't tried that either - only using it to re-write various config files for additional envrionment configuration. However it does look like packaging events are exposed to this API:
http://grails.org/doc/latest/guide/4.%20The%20Command%20Line.html
How do I create a grails war file so that it doesn't have the version number
(e.g. foo-0.1.war)
attached to the end when I execute the 'grails war' command?
In case anybody comes upon this article and is using Grails 1.3.x, the configuration option has changed from grails.war.destFile in Config.groovy to being grails.project.war.file in BuildConfig.groovy.
Also the file name is relative to the project workspace, so it should have a value like:
grails.project.war.file = "target/${appName}.war"
This is according to the latest Grails documentation.
I think you can specify the war name in the war command.
grails war foo.war
Also check the latest Grails documentation for where to set this as a configuration option. See the other answers for details.
From the Grails Documentation, Chapter 17, Deployment
There are also many ways in which you can customise the WAR file that is
created. For example, you can specify
a path (either absolute or relative)
to the command that instructs it where
to place the file and what name to
give it:
grails war /opt/java/tomcat-5.5.24/foobar.war
Alternatively, you can add a line to
Config.groovy that changes the default
location and filename:
grails.war.destFile = "foobar-prod.war"
Of course, any command line argument
that you provide overrides this
setting.
Rolling up the other excellent answers. There are several options:
Explicitly set it on the command line: grails war foo.war
Set the app.version property to empty in application.properties will cause the war to be named foo.war.
Explicitly set the name of the war using the grails.war.destFile property in Config.groovy
Grails 3.x has switched to gradle and uses the war plugin. You can just specify name like this in the build.gradle file:
war {
archiveName 'foo.war'
}
Another way to generate war files without version number is to keep the property, app.version, empty in the application.properties
I am kind of late to the party... but anyway:
I think the reason behind removing the version number is to eliminate the need to rename the war file so it deploys on "correct" context path /appName. If that's the case then a better option is to use a versioned war filename so you can deploy multiple versions at the same time on tomcat using the following naming pattern in grails-app/conf/BuildConfig.groovy:
grails.project.war.file = "target/${appName}##${appVersion}.war"
As explained in http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment
This method applies to wars in general, not only grails' wars.