@@ -7,38 +7,50 @@ def self.run(params)
77 require 'set'
88 require 'shellwords'
99
10- app_folder_name ||= params [ :app_folder_name ]
11- UI . message ( "The commit_android_version_bump plugin is looking inside your project folder (#{ app_folder_name } )!" )
12-
13- build_folder_paths = Dir [ File . expand_path ( File . join ( '**/' , app_folder_name ) ) ] . reject { |file | [ 'build/' , 'node_modules/' ] . any? { |part | file . include? part } }
14- # no build.gradle found: error
15- UI . user_error! ( 'Could not find a build folder in the current repository\'s working directory.' ) if build_folder_paths . count == 0
16-
17- UI . message ( "Found the following project path: #{ build_folder_paths } " )
18- # too many projects found: error
19- if build_folder_paths . count > 1
20- UI . user_error! ( "Found multiple build.gradle projects in the current repository's working directory." )
10+ build_file_folder ||= params [ :gradle_file_folder ]
11+ if build_file_folder != nil
12+ UI . message ( "The commit_android_version_bump plugin will use gradle file at (#{ build_file_folder } )!" )
13+
14+ absolute_path = File . expand_path ( build_file_folder )
15+ build_file_path = build_file_folder +"/build.gradle"
16+ # find the repo root path
17+ repo_path = Actions . sh ( "git -C #{ absolute_path } rev-parse --show-toplevel" ) . strip
18+ repo_pathname = Pathname . new ( repo_path )
19+ else
20+ app_folder_name ||= params [ :app_folder_name ]
21+ UI . message ( "The commit_android_version_bump plugin is looking inside your project folder (#{ app_folder_name } )!" )
22+
23+ build_folder_paths = Dir [ File . expand_path ( File . join ( '**/' , app_folder_name ) ) ] . reject { |file | [ 'build/' , 'node_modules/' ] . any? { |part | file . include? part } }
24+ # no build.gradle found: error
25+ UI . user_error! ( 'Could not find a build folder in the current repository\'s working directory.' ) if build_folder_paths . count == 0
26+
27+ UI . message ( "Found the following project path: #{ build_folder_paths } " )
28+ # too many projects found: error
29+ if build_folder_paths . count > 1
30+ UI . user_error! ( "Found multiple build.gradle projects in the current repository's working directory." )
31+ end
32+
33+ build_folder_path = build_folder_paths . first
34+
35+ # find the repo root path
36+ repo_path = Actions . sh ( "git -C #{ build_folder_path } rev-parse --show-toplevel" ) . strip
37+ repo_pathname = Pathname . new ( repo_path )
38+
39+
40+ build_file_paths = Dir [ File . expand_path ( File . join ( '**/' , app_folder_name , 'build.gradle' ) ) ] . reject { |file | file . include? 'node_modules/' }
41+
42+ # no build.gradle found: error
43+ UI . user_error! ( 'Could not find a build.gradle in the current repository\'s working directory.' ) if
44+ build_file_paths . count == 0
45+ # too many projects found: error
46+ if build_file_paths . count > 1
47+ UI . user_error! ( "Found multiple build.gradle projects in the current repository's working directory." )
48+ end
49+
50+ build_file_path = build_file_paths . first
51+ build_file_path . replace build_file_path . sub ( "#{ repo_pathname } /" , "" )
2152 end
2253
23- build_folder_path = build_folder_paths . first
24-
25- # find the repo root path
26- repo_path = Actions . sh ( "git -C #{ build_folder_path } rev-parse --show-toplevel" ) . strip
27- repo_pathname = Pathname . new ( repo_path )
28-
29-
30- build_file_paths = Dir [ File . expand_path ( File . join ( '**/' , app_folder_name , 'build.gradle' ) ) ] . reject { |file | file . include? 'node_modules/' }
31-
32- # no build.gradle found: error
33- UI . user_error! ( 'Could not find a build.gradle in the current repository\'s working directory.' ) if build_file_paths . count == 0
34- # too many projects found: error
35- if build_file_paths . count > 1
36- UI . user_error! ( "Found multiple build.gradle projects in the current repository's working directory." )
37- end
38-
39- build_file_path = build_file_paths . first
40- build_file_path . replace build_file_path . sub ( "#{ repo_pathname } /" , "" )
41-
4254 # create our list of files that we expect to have changed, they should all be relative to the project root, which should be equal to the git workdir root
4355 expected_changed_files = [ ]
4456 expected_changed_files << build_file_path
@@ -98,7 +110,7 @@ def self.description
98110 end
99111
100112 def self . authors
101- [ "jems " ]
113+ [ "Jems " ]
102114 end
103115
104116 def self . available_options
@@ -113,6 +125,12 @@ def self.available_options
113125 optional : true ,
114126 type : String ,
115127 default_value :"app" ) ,
128+ FastlaneCore ::ConfigItem . new ( key : :gradle_file_folder ,
129+ env_name : "CVB_GRADLE_FILE_FOLDER" ,
130+ description : "The relative path to the folder that contains the gradle file containing the modification to commit (example :project/app)" ,
131+ optional : true ,
132+ type : String ,
133+ default_value : nil ) ,
116134 FastlaneCore ::ConfigItem . new ( key : :force ,
117135 env_name : "CVB_FORCE_COMMIT" ,
118136 description : "Forces the commit, even if other files than the ones containing the version number have been modified" ,
0 commit comments