Skip to content

Commit 8ba9dd3

Browse files
dmitri-gbnebhale
authored andcommitted
Add Flag to Disable JRebel
This change adds a flag to the JRebel configuration that allows users to explicitly disable the JRebel framework. [resolves #457]
1 parent 2a890c8 commit 8ba9dd3

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

config/jrebel_agent.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
---
1818
version: 7.+
1919
repository_root: https://dl.zeroturnaround.com/jrebel
20+
enabled: true

docs/framework-jrebel_agent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The framework can be configured by modifying the [`config/jrebel_agent.yml`][] f
2525
| ---- | -----------
2626
| `repository_root` | The URL of the JRebel repository index ([details][repositories]).
2727
| `version` | The version of JRebel to use. Candidate versions can be found in [this listing][].
28+
| `enabled` | Whether to activate JRebel (upon the presence of `rebel-remote.xml`) or not.
2829

2930
[Configuration and Extension]: ../README.md#configuration-and-extension
3031
[`config/jrebel_agent.yml`]: ../config/jrebel_agent.yml

lib/java_buildpack/framework/jrebel_agent.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ def release
4646

4747
# (see JavaBuildpack::Component::VersionedDependencyComponent#supports?)
4848
def supports?
49-
jrebel_configured?(@application.root) || jrebel_configured?(@application.root + 'WEB-INF/classes') ||
50-
jars_with_jrebel_configured?(@application.root)
49+
enabled? && (
50+
jrebel_configured?(@application.root) ||
51+
jrebel_configured?(@application.root + 'WEB-INF/classes') ||
52+
jars_with_jrebel_configured?(@application.root))
5153
end
5254

5355
private
@@ -68,6 +70,10 @@ def architecture
6870
`uname -m`.strip
6971
end
7072

73+
def enabled?
74+
@configuration['enabled'].nil? || @configuration['enabled']
75+
end
76+
7177
end
7278

7379
end

spec/java_buildpack/framework/jrebel_agent_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
expect(component.detect).to eq("jrebel-agent=#{version}")
4040
end
4141

42+
context do
43+
let(:configuration) { { 'enabled' => false } }
44+
45+
it 'does not detect when not enabled',
46+
app_fixture: 'framework_jrebel_app_simple' do
47+
expect(component.detect).to be_nil
48+
end
49+
end
50+
4251
it 'downloads the JRebel JAR and the native agent',
4352
app_fixture: 'framework_jrebel_app_simple',
4453
cache_fixture: 'stub-jrebel-archive.zip' do

0 commit comments

Comments
 (0)