File tree Expand file tree Collapse file tree
lib/java_buildpack/container
container_groovy_shebang_containing_class Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ The Spring Boot CLI Container runs one or more Groovy (i.e. `*.groovy`) files us
77 <li>The application has one or more <tt>.groovy</tt> files in the root directory, and</li>
88 <li>All the application's <tt>.groovy</tt> files in the root directory are POGOs (a POGO contains one or more classes), and</li>
99 <li>None of the application's <tt>.groovy</tt> files in the root directory contain a <tt>main</tt> method, and</li>
10+ <li>None of the application's <tt>.groovy</tt> files in the root directory contain a shebang (`#!`) declaration, and</li>
1011 <li>The application does not have a <tt>WEB-INF</tt> subdirectory of its root directory.</li>
1112 </ul></td>
1213 </tr>
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ def release
5252
5353 def supports?
5454 gf = JavaBuildpack ::Util ::GroovyUtils . groovy_files ( @application )
55- gf . length > 0 && all_pogo ( gf ) && no_main_method ( gf ) && !has_web_inf
55+ gf . length > 0 && all_pogo ( gf ) && no_main_method ( gf ) && no_shebang ( gf ) && !has_web_inf
5656 end
5757
5858 private
@@ -65,6 +65,10 @@ def no_main_method(groovy_files)
6565 none? ( groovy_files ) { |file | JavaBuildpack ::Util ::GroovyUtils . main_method? file } # note that this will scan comments
6666 end
6767
68+ def no_shebang ( groovy_files )
69+ none? ( groovy_files ) { |file | JavaBuildpack ::Util ::GroovyUtils . shebang? file }
70+ end
71+
6872 def has_web_inf
6973 @application . child ( 'WEB-INF' ) . exist?
7074 end
Original file line number Diff line number Diff line change 1- #! /usr/bin/env groovy -w
1+ #! /usr/bin/env groovy
22/*
33 * Copyright 2013 the original author or authors.
44 *
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env groovy
2+ /*
3+ * Copyright 2013 the original author or authors.
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
17+
18+ class X {
19+ public static void exec () {
20+ println ' Hello World'
21+ }
22+ }
23+
24+ X. exec()
Original file line number Diff line number Diff line change 5757 expect ( component . detect ) . to eq ( "groovy=#{ version } " )
5858 end
5959
60+ it 'should detect a Groovy file which has a shebang but which also contains a class' ,
61+ app_fixture : 'container_groovy_shebang_containing_class' do
62+
63+ expect ( component . detect ) . to eq ( "groovy=#{ version } " )
64+ end
65+
6066 context do
6167 let ( :version ) { '2.1.5_10' }
6268
Original file line number Diff line number Diff line change 4545 expect ( component . detect ) . to be_nil
4646 end
4747
48+ it 'should not detect if one of the Groovy files has a shebang' ,
49+ app_fixture : 'container_groovy_shebang' do
50+
51+ expect ( component . detect ) . to be_nil
52+ end
53+
54+ it 'should not detect a Groovy file which has a shebang but which also contains a class' ,
55+ app_fixture : 'container_groovy_shebang_containing_class' do
56+
57+ expect ( component . detect ) . to be_nil
58+ end
59+
4860 it 'should not detect if one of the Groovy files has a main() method' ,
4961 app_fixture : 'container_spring_boot_cli_main_method' do
5062
You can’t perform that action at this time.
0 commit comments