This repository was archived by the owner on Apr 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildfile
More file actions
82 lines (70 loc) · 2.4 KB
/
Copy pathbuildfile
File metadata and controls
82 lines (70 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Generated by Buildr 1.4.4, change to your liking
# Standard maven2 repository
repositories.remote << 'http://www.ibiblio.org/maven2'
require 'time'
THIS_VERSION = '0.1'
layout = Layout.new
layout[:source, :main, :java] = 'src/main/java'
layout[:source, :test, :java] = 'src/test/java'
Project.local_task :ragel
Project.local_task :ragel_clean
desc 'codeblockparser'
define 'codeblockparser', :layout=>layout do
eclipse.natures 'org.eclipse.jdt.core.javanature'
eclipse.builders 'org.eclipse.jdt.core.javabuilder'
compile.with 'commons-io:commons-io:jar:2.0'
#test.with 'junit:junit:jar:4.8.2'
test.with 'org.mockito:mockito-core:jar:1.8.5'
compile.with(
'org.slf4j:slf4j-log4j12:jar:1.6.1',
'org.slf4j:slf4j-api:jar:1.6.1',
'log4j:log4j:jar:1.2.16'
)
project.group = 'de.entwicklerland'
project.version = THIS_VERSION
package :sources
package :javadoc
package(:jar).with :manifest=>
{
'Project' => project.id,
'Copyright' => 'Ruben Jenster (C) 2011',
'Version' => THIS_VERSION,
'Creation' => Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
}
def filetask(options = {})
files = Dir.glob(options[:files])
if (files.empty?)
puts "\n#{options[:message_not_found]}\n"
else
puts "\n#{options[:message_found]}"
files.each do |path|
if yield(path)
puts(" processed file: #{path}")
end
end
puts "\n"
end
end
# generate all java classes for the ragel files in the /src directory recursively
# which have a machine definition and a machine instantiation
task :ragel do
# check that the ragel file contains a machine instantiation
filetask(:files => 'src/**/*.rl',
:message_not_found => "No machine definitions found!",
:message_found => "Generating ragel parsers for machine definitions:") do |path|
if File.new(path).grep(/(^|[\s]+)machine[\s]+/).length > 0 &&
File.new(path).grep(/.*:=.*/).length > 0
system("ragel -J #{path}")
end
end
end
# remove all generated ragel parsers from the /src directory recursively
task :ragel_clean do
filetask(:files => "src/**/*.rl",
:message_not_found => "No generated ragel parsers found to delete!",
:message_found => "Removing generated ragel parsers:") do |path|
path = path.gsub(/\.rl$/,'.java')
File.delete(path) if File.exists?(path)
end
end
end