Grails - How to include subdirectories of lib in classpath? - grails

I have an application deployed and I need to include new jars during runtime.
I am currently doing it by placing the jars in the lib directory, but if I place them in some subdirectory of lib they are not loaded.
Is it possible to do it?

Related

How to add properties file to classpath in Grails

What does it mean when it says to add a file to the classpath? Something like this:
// The configuration file we created. It must be in the classpath.
outEncryptionProps.put(WSHandlerConstants.ENC_PROP_FILE, "client_encryption.properties");
I use GGTS and I have other files other than properties file that I need to add to my project's classpath.
The classpath is a collection of jars and directories that are used to resolve classes and resources. In practice for files like this putting them in the classpath means that you should put it in a directory that's included in the classpath, or a directory whose contents are copied to a classpath folder during compilation.
In Grails you can put non-source files in grails-app/conf, src/java, or src/groovy and they'll be copied into the classpath.

How to add a “non-mavenized” jar dependency to a grails project (Grails 3.x)

I'm trying to find documentation and code samples on how to add a local / non-maven jar file to my Grails 3.x project?
I found the separate thread How to add a non-maven jar to grails - but that's only to grails 2.3, and the file structure and configuration has undergone a big overhaul in 3.x.
Any help and (especially) code samples would be wonderful! The .jar is in the local project directory, and I intend to package with the .war for deployment.
Additionally, once i add the dependency, should i just be able to call it's methods from the controller & service files? or do i need to include them in those as well?
thx!
Grails 3 uses Gradle, so there's nothing Grails specific about including a local jar. It's as easy as adding a file dependency to the dependencies block of your build.gradle file.
Per the Gradle documentation on File Dependencies:
To add some files as a dependency for a configuration, you simply pass a file collection as a dependency:
dependencies {
...
compile files('libs/a.jar', 'libs/b.jar')
// or
compile fileTree(dir: 'libs', include: '*.jar')
}
The above example shows two ways to include jars that exist in a local libs/ directory; you can do either/or. The jar(s) can be anywhere on the filesystem, just make sure you point to the correct path.
To use the classes from the dependency in your application, you'll include them in your services, controllers and all other classes like you normally would. Say libs/a.jar has a class org.example.Something, you'd add an import to the top of your Grails class like so:
import org.example.Something

How to add custom Grails plugin artefact directory

I have a Grails application and a custom plugin with separate code included in the main application in BuildConfig.groovy using grails.plugin.location.'my-plugin' = '../my-plugin'. Now I'm looking for a way to customize what artefact directories will be exported in the plugin. I want to place a custom resource file (e.g. SQL script) into src/resources directory of the plugin and I need to see the file on classpath of the main application. I know files in grails-app/conf and other directories get included along with the plugin source, but can the convention of resource directories be altered?

maven: how to packag many modules into a compressed distribution file

I have a mavem pom project with a set of modules under it.
parent-pom
|---child-module-a
|---child-module-b
|---child-module-c
|---child-module-package
In the child-module-package, I want to create a compressed file consisting of files from other child modules.
the other module target jars
files from src/main/resources of other modules and put to "conf" directory in the final compressed jars.
include dependency jars of other child-modules in the "lib" directory.
create a manifest file.
Is there a plugin(s) that would allow me to do all the above?
Is the maven-assembly-plugin sufficient to do this?

Can a Rails plugin be packaged as a WAR/JAR file?

Can a plugin be packaged as a JAR/WAR file similar to the way in which an entire Rails app can be packaged for deployment on JRuby?
either you want warbler or you want to make a jar.
If you need an empty rails app with that plugin, create an empty project, install the plugin and, edit config/warble.rb to copy the gems you need
If you need a jar with class files from that plugin; you need jrubyc to compile the rb files to class files that you can then turn into a jar with the java jar command. Put that jar into WEB-INF/lib of any Java app that needs those ruby classes.

Resources