lib/dryrun/android_project.rb in dryrun-1.2.0 vs lib/dryrun/android_project.rb in dryrun-1.2.1

- old
+ new

@@ -12,18 +12,27 @@ @custom_app_path = custom_app_path @custom_module = custom_module @base_path = @custom_app_path ? File.join(path, @custom_app_path) : path @flavour = flavour @device = device + @gradle_file_extension = gradle_file_extension @settings_gradle_path = settings_gradle_file @main_gradle_file = main_gradle_file check_custom_app_path @modules = find_modules end + def gradle_file_extension + gradle_file = File.join(@base_path, 'settings.gradle.kts') + if (File.exist?(gradle_file)) + return ".gradle.kts" + end + ".gradle" + end + def check_custom_app_path return unless @custom_app_path full_custom_path = @base_path settings_path = settings_gradle_file(full_custom_path) @@ -47,11 +56,11 @@ def remove_application_id # Open temporary file tmp = Tempfile.new('extract') - file = "#{@path_to_sample}/build.gradle" + file = "#{@path_to_sample}/build#{@gradle_file_extension}" # Write good lines to temporary file File.open(file, 'r') do |f| f.each do |l| tmp << l unless l.include? 'applicationId' @@ -62,15 +71,15 @@ # Move temp file to origin FileUtils.mv(tmp.path, file) end def settings_gradle_file(path = @base_path) - File.join(path, 'settings.gradle') + File.join(path, "settings#{@gradle_file_extension}") end def main_gradle_file(path = @base_path) - File.join(path, 'build.gradle') + File.join(path, "build#{@gradle_file_extension}") end def valid?(main_gradle_file = @main_gradle_file) File.exist?(main_gradle_file) && File.exist?(@settings_gradle_path) @@ -79,11 +88,11 @@ def find_modules return [] unless valid? content = File.open(@settings_gradle_path, 'rb').read - content = content.split(/\n/).delete_if { |x| x.start_with?("rootProject")}.join("\n") - modules = content.scan(/'([^']*)'/) + content = content.split(/\n/).delete_if { |x| !x.start_with?("include")}.join("\n") + modules = content.scan(/'([^']*)'/) + content.scan(/\"([^"]*)\"/) modules.each {|replacement| replacement.first.tr!(':', '')} end def execute_command(command)