jruby-gradle / jruby-gradle-plugin

A Gradle plugin for working with JRuby projects for fun and profit. Mostly profit.
http://jruby-gradle.org
Other
93 stars 38 forks source link

capturing all source #314

Open amiracam opened 7 years ago

amiracam commented 7 years ago

I have a directory structure as such

src
   -- entrypoint.rb
   -- db
          -- db_manager.rb

and of course I could have multiple directories under src as well other source files

I would like to capture all of my source not just the entrypoint.rb i.e. the initScript, ideally I would like to precompile my ruby such as one can with Warbler , I could not find any references in the docs.

I then tried using "include" within the jrubyJar spec which did not fail to build but failed to provide the desired results.

rubyJar { / We want to use this Ruby script as our start point when the jar executes / jrubyVersion '9.1.13.0' include "${projectDir}/src/db/*" initScript "${projectDir}/src/entrypoint.rb"

}

and variations of , all which failed

Please advise , thanks

jacaetevha commented 5 years ago

Any comment here? I've got the same question. I have files in src/main/ruby and src/main/resources that I want to include in the resulting JAR file, but I want them to be included at the root of the JAR, not in one of the included directories (e.g. jars, bin).

jacaetevha commented 5 years ago

I just implemented this as a post-build step:


task copyResourcesToTmp(type: Copy) {
  from "src/main/resources/"
  into "${buildDir}/tmp/other-resources"

  from "src/main/ruby/"
  into "${buildDir}/tmp/other-resources"
}

task updateJarWithResources(type: Exec) {
  def jarFile = "${buildDir}/libs/${project.name}-jruby.jar"
  def isWindows = System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')
  def command = isWindows ? 'cmd' : 'sh'
  def commandSwitch = isWindows ? '/c' : '-c'

  workingDir "${buildDir}/tmp/other-resources"
  commandLine command, commandSwitch, "jar uf ${jarFile} ./*"
}

updateJarWithResources.dependsOn copyResourcesToTmp
jrubyJar.finalizedBy(updateJarWithResources)