Last active
September 20, 2016 23:37
-
-
Save c650/ea26564325d08e79b1e6f8e8519c9303 to your computer and use it in GitHub Desktop.
converts directory of java files into an eclipse project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
# by charles bailey (@c650) | |
# under MIT License | |
# 9.20.16 | |
require 'fileutils' | |
if ARGV.length != 4 | |
puts "Usage: ./program [code dir] [new project dir] [example dir] [project name]" | |
exit(1) | |
end | |
puts "Starting to make Eclipse folder..." | |
code_dir = File.expand_path(ARGV[0]) | |
new_project_dir = File.expand_path(ARGV[1]) | |
example_dir = File.expand_path(ARGV[2]) | |
# Start initializing directories... | |
FileUtils.mkdir_p(new_project_dir) | |
src_dir = new_project_dir+"/src" | |
FileUtils.mkdir_p(src_dir) | |
bin_dir = new_project_dir+"/bin" | |
FileUtils.mkdir_p(bin_dir) | |
# copy stuff into new directory | |
puts "Copying All Java Files to #{new_project_dir}/src..." | |
Dir.chdir(code_dir) | |
FileUtils.cp_r(Dir.glob("*.java"), src_dir) | |
puts "Copying Hidden Configuration Files..." | |
Dir.chdir(example_dir) | |
FileUtils.cp_r(["./.classpath", "./.settings", "./.project"], new_project_dir) | |
Dir.chdir(new_project_dir) | |
project_file = new_project_dir+"/.project" | |
puts "Naming project to #{ARGV[3]}" | |
f = File.read(project_file).gsub("PROJECT_NAME", ARGV[3]) | |
File.open(project_file, "w") do |file| | |
file.puts f | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment