Grails 3 plugin using properties from application.yml - grails-plugin

I am creating a plugin using Grail 3 (3.2.11). My plugin needs to access different properties (e.g. URLs) for each environment (e.g. development, staging, production). When writing a Grails application I add the properties to the application.yml file. Where do they go in the plugin? I tried adding them to application.yml of the plugin and that does not work as expected. If I add them to the application.yml file of the application using the plugin they work. But I want the properties to be part of the plugin so each person who uses the plugin does not need to provide the properties. I would expect it to work like message properties. Where a plugin can have message properties and an application can override them by providing the same property in their local application message.properties. What am I not understanding.

In the same conf directory as application.yml you can place a plugin.yml (or plugin.groovy) which should allow you to change the plugin configuration similar to the way its done in the application's config file(s).

Related

How to view all properties from a configuration file in runtime manager

I use configuration files for all properties of my apps, that is working fine. Running them on cloud hub I would like to have these properties show up in the app settings of the runtime manager (for reviewing or editing the settings "on the fly" without a new deployment).
I know you can overwrite them via the settings, but I would like to see the list of all properties beforehand – like if you don't use configuration files but submit them via the deployment dialog.
Any way to archive this?
In Anypoint Runtime Manager you can only see the properties defined there. Properties files are not inspectable nor visible.

IntelliJ Spring properties auto completion in *.yml files

I've been trying to make IntelliJ treat *.yml files the same way it treats application.yml or bootstrap.yml.
What I mean is, that I have auto completion and syntax warnings when I edit for example a application.yml file, but none of these features when I edit a file called microservices-monitor-prod.yml which is located in a config server resource folder.
Is there any way to have the same IntelliJ features when editing such files ?
IntelliJ IDEA 2017.2 (currently available as RC) allows to choose custom naming schemes for Spring Boot configuration files (https://youtrack.jetbrains.com/issue/IDEA-133445)

IntelliJ & Wildfly - hot deploy webapp

I am using IntelliJ (14.0.3) and Wildfly (8).
When I recompile my Java classes, hot swapping is easy and everything works just fine. However, my HTML, JS and CSS files will not hot swap for me. I am sure it is just a configuration issue and was hoping for some help.
My HTML data is in:
<root>/<war_module>/src/main/webapp
My run/debug is setup for:
Before launch: Make, Build Artifacts
Make
Build 'mymodule:war' artifact
I had the exact same problem, this is how it worked for me:
After configuring your JBoss server (Wildfly), setup an artifact of type exploded, in my case I selected Web Application: Exploded, and then in the Output directory add .war to the end of the name.
In case you need a .ear, simply select JavaEE Application: exploded instead, but anyways always remember to add manually the extension.
After setting this artifact to work with your Application Server, in the edit configurations of your Wildfly server select the option Update resources in the list of options in the section On frame deactivation.
So every time you modify and save static content, it will update these changes as soon as you focus something else outside the IDE, like the browser.

Can Struts 1.x Resource Bundles be placed elsewhere than the classes directory?

This is for Struts 1.x (I'm using 1.3.10).
I've noticed that Struts is unable to pick up resource bundles in the ApplicationResources.properties file if it is not placed somewhere in the default classpath (e.g., com.abc.SomePackage).
For instance, if I put the ApplicationResources.properties file in a custom folder /WEB-INF/strutsResources and configure the struts-config.xml thus:
<message-resources parameter="/WEB-INF/strutsResources/ApplicationResources"/>
I've read that the resources need to be on the classpath so I've also tried adding the /WEB-INF/strutsResources folder to the classpath. It still does not pick up the resource keys.
I've double-checked that the strutsResources folder is actually deployed to the server (I'm using Glassfish v3), so the file is there, it's just not being parsed.
P.S.
If you're wondering why I'm trying to do this, I just wanted to organize my code a little better ("better," IMO). Since the ApplicationResources.properties file is not really a class, I wanted to place it in a resources folder by itself.
I've checked that placing the ApplicationResources file in a package in the src directory works just fine.
Ultimately, the answer is yes. You can play some interesting games by configuring a custom className and/or factory and get messages however you want (including from a database) and so on. This allows you to customize whatever you want*.
I agree the resources aren't a class, but putting them on the classpath is a common practice, and allows resources to be loaded as a resource, e.g., from inside a jar. I'm sympathetic, but I'd leave it as-is.
*Like reversing all the text; a fun prank to play on your co-workers and QA department.
Its best leave it on the classpath.
It's stadard practise to include properties files on the classpath, especially if you're planning on packaging it up in your WAR/EAR. You're keeping it under WEB-INF so you gain no benefit from moving it off the classpath, and you'll just confuse other developers who have to work on the project and you've had to put a hack in to make this work.
If you want to keep your files external to your deployable WAR/EAR then that's a valid reason for not using the classpath. Typically this will require some configuration as part of your deployment to specify where the file is to reside.
For example specify the location using
a JVM argument (e.g. -Dprops.file=/config/myapp.properites)
lookup from a JNDI resource
use a PropertiesFactoryBean if you're using the Spring framework (I
use Spring's ApplicationContext with Struts 1 MVC)
read properties from a database writing your own
ApplicationPropertiesDAO class that initialises itself durnig your
applications bootstrap process (e.g. Spring application contact,
Servlet in web.xml, Listener in web.xml, etc)

How do I get artifacts from one Maven module included in the resources of another in my build?

I have Maven modules that produce a Flex application as an SWF file. I want to include that file in a web application that is made with another Maven module from the same build. I'm wondering how and at which lifecycle phase I get Maven to grab the artifact from the other module and put it insode the appropriate folder of the webapp module. Would I use a separate assembly module?
The web app is running on a Jetty server in an OSGi environment (using Pax), the server side of the web app uses Struts. The final artifact as I see it would be a WAR file including my Action etc classes, JSP templates, static contents such as CSS or JS, and the SWF movies. I might be better off with these split over some other setup, but right now, I wouldn't know which.
I'm wondering how and at which lifecycle phase I get Maven to grab the artifact from the other module and put it insode the appropriate folder of the webapp module.
What about using dependency:unpack dependency:copy during prepare-package?