Our Project is ANT based and we are trying to migrate from log4j 1.X to log4j 2.x as immediate solution we wanna use Log4j 1.x bridge but for this we need to set the log4j1.compatibility to true . But I am not sure how to set this system property to true in an ant script. Need help in understanding this.
Related
I am using Grails 3.2 and I am wondering where I should put my application variables for different enviroments.
application.yml or build.gradle?
And, how should I define them?
You should put them in the application.yml as stated in the documents:
Configuration in Grails is generally split across 2 areas: build
configuration and runtime configuration.
Build configuration is
generally done via Gradle and the build.gradle file. Runtime
configuration is by default specified in YAML in the
grails-app/conf/application.yml file.
You can also choose to use the Grails 2.0-style Groovy configuration as mentioned in the next alinea:
If you prefer to use Grails 2.0-style Groovy configuration then you
can create an additional grails-app/conf/application.groovy file to
specify configuration using Groovy's ConfigSlurper syntax.
Documentation: http://docs.grails.org/3.2.0/guide/conf.html#environments
Grails supports the concept of per environment configuration. The application.yml and application.groovy files in the grails-app/conf directory can use per-environment configuration using either YAML or the syntax provided by ConfigSlurper. As an example consider the following default application.yml definition provided by Grails:
I am new to grails and have created my first project using grails-init. I now have a grails project that uses gradle as it's build tool. However, as I go through online tutorials I find that I am missing a lot of the files that are commonly cited. Files such as config.groovy and datasource.groovy.
I've tried re-creating the project, but I get the same structure and files. Can I just add these files manually? I have tried doing so, but they don't seem to be getting picked up when I run the application.
Config.groovy and DataSource.groovy are both applicable to Grails 2 applications but not Grails 3 applications. In Grails 3 the default place for the information that used to go in those files is application.yml.
Grails 3.1 have new features and structure changes. Now grails uses spring boot and Spring 4.2 and as mentioned, Config.groovy and Datasource.groovy can be configured using application.yml. You can found more information here Grails documentation
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>
After I upgraded to Grails 2.2.1 my inline plugin directives have stopped working.
For example the following does not resolve the plugin.
grails.plugin.location.'commons' = "../../common/commons-upgrade"
I followed the guide
http://grails.org/doc/latest/guide/upgradingFromPreviousVersionsOfGrails.html
which says to add the following
legacyResolve true to the BuildConfig.groovy but it still doesn't work.
Also the guide claims that
Grails 2.2 no longer uses the BuildConfig of the plugin for dependency resolution and only uses data provided by POMs
Although I have found that the application neither requires a POM and by default still uses the BuildConfig for plugin resolution. Given that Grails depends on some plugins by default I would expect the create-app to automatically generate a POM and for it to be used by default.
Can someone resolve my confusion with dependency resolution?
You can use
grails generate-pom
to create a pom for your plugin which can be used for deployment, however that doesn't fix the problem you're seeing at the moment.
The only way I've found to get around it is to set legacyResolve true in the build config as per http://grails.org/doc/2.2.1/guide/upgradingFromPreviousVersionsOfGrails.html
Hopefully that will be fixed soon.
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.