Skip to content

Commit

Permalink
Added gems and tasks for gems.
Browse files Browse the repository at this point in the history
  • Loading branch information
UweKubosch committed Apr 12, 2024
1 parent d40c02d commit b10c06f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ There is a reference application at https://github.com/DatekWireless/slim-spring
### build.gradle

```groovy
plugins {
id "com.github.jruby-gradle.base" version "2.1.0-alpha.2"
}
dependencies {
implementation 'no.datek:slim-spring-webmvc:0.+'
}
Expand Down
44 changes: 43 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ plugins {
id "org.springframework.boot" version "2.7.18"
id 'maven-publish'
id 'signing'
id "com.github.jruby-gradle.base" version "2.1.0-alpha.2"
}

group 'no.datek'
version '0.19.0'
version '0.19.1'
final String JRUBY_VERSION = '9.4.6.0';

repositories {
Expand Down Expand Up @@ -90,3 +91,44 @@ publishing {
}
}
}

import com.github.jrubygradle.JRubyExec

tasks.register('installGems', JRubyExec) {
group 'gems'
description "Install gems"
script "${projectDir}/bin/bundle"
scriptArgs 'install'
finalizedBy 'copyGems'
jvmArgs '--add-opens=java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens=java.base/java.io=ALL-UNNAMED'
}

tasks.register('updateGems', JRubyExec) {
group 'gems'
description "Update gems"
script "${projectDir}/bin/bundle"
scriptArgs 'update'
finalizedBy 'cleanGems', 'copyGems'
jvmArgs '--add-opens=java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens=java.base/java.io=ALL-UNNAMED'
}

tasks.register('cleanGems', JRubyExec) {
group 'gems'
description "Clean gems"
script "${projectDir}/bin/bundle"
scriptArgs 'clean', '--force'
jvmArgs '--add-opens=java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens=java.base/java.io=ALL-UNNAMED'
}

tasks.register('copyGems', Sync) {
group 'gems'
description 'Copies gems from vendor/bundle to src/main/resources/gems'
mustRunAfter 'cleanGems'
from "build/.gems/gems"
include "*/lib/**/*"
includeEmptyDirs = false
into("src/main/resources/gems")
eachFile { fcd -> fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(2)) }
}

jruby { jrubyVersion JRUBY_VERSION }
2 changes: 1 addition & 1 deletion src/main/resources/ruby/request_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.default_context(locale, params, rendering_context, request)
session: request.getSession(),
}
if defined?(SecurityContextHolder)
context.merge({
context.merge!({
current_user: SecurityContextHolder.context&.authentication&.principal,
user: request.session.getAttribute("user") || SecurityContextHolder.context&.authentication&.principal,
})
Expand Down

0 comments on commit b10c06f

Please sign in to comment.