buildr-iidea 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +38 -33
- data/LICENSE +203 -203
- data/NOTICE +16 -16
- data/README.rdoc +328 -328
- data/Rakefile +42 -33
- data/buildr-iidea.gemspec +25 -25
- data/lib/buildr/intellij_idea/idea_file.rb +85 -85
- data/lib/buildr/intellij_idea/idea_module.rb +255 -263
- data/lib/buildr/intellij_idea/idea_project.rb +105 -105
- data/lib/buildr/intellij_idea/project_extension.rb +108 -108
- data/lib/buildr/intellij_idea/version.rb +10 -10
- data/lib/buildr_iidea.rb +6 -6
- data/spec/buildr/intellij_idea/clean_spec.rb +37 -37
- data/spec/buildr/intellij_idea/dependency_spec.rb +115 -115
- data/spec/buildr/intellij_idea/extra_modules_spec.rb +24 -24
- data/spec/buildr/intellij_idea/facet_generation_spec.rb +36 -36
- data/spec/buildr/intellij_idea/group_spec.rb +33 -33
- data/spec/buildr/intellij_idea/idea_file_generation_spec.rb +243 -243
- data/spec/buildr/intellij_idea/inform_spec.rb +28 -28
- data/spec/buildr/intellij_idea/initial_components_spec.rb +38 -38
- data/spec/buildr/intellij_idea/module_content_generation_spec.rb +96 -96
- data/spec/buildr/intellij_idea/module_defaults.rb +15 -15
- data/spec/buildr/intellij_idea/module_property_inheritance_spec.rb +27 -27
- data/spec/buildr/intellij_idea/project_extension_spec.rb +96 -96
- data/spec/buildr/intellij_idea/template_spec.rb +233 -233
- data/spec/spec_helper.rb +79 -72
- data/spec/xpath_matchers.rb +108 -108
- metadata +15 -16
- data/spec/spec.opts +0 -1
@@ -1,105 +1,105 @@
|
|
1
|
-
module Buildr
|
2
|
-
module IntellijIdea
|
3
|
-
class IdeaProject < IdeaFile
|
4
|
-
attr_accessor :vcs
|
5
|
-
attr_accessor :extra_modules
|
6
|
-
attr_writer :jdk_version
|
7
|
-
|
8
|
-
def initialize(buildr_project)
|
9
|
-
@buildr_project = buildr_project
|
10
|
-
@vcs = detect_vcs
|
11
|
-
@extra_modules = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def jdk_version
|
15
|
-
@jdk_version ||= buildr_project.compile.options.source || "1.6"
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
def extension
|
21
|
-
"ipr"
|
22
|
-
end
|
23
|
-
|
24
|
-
def detect_vcs
|
25
|
-
if File.directory?(buildr_project._('.svn'))
|
26
|
-
"svn"
|
27
|
-
elsif File.directory?(buildr_project._('.git'))
|
28
|
-
"Git"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def base_document
|
33
|
-
target = StringIO.new
|
34
|
-
Builder::XmlMarkup.new(:target => target).project(:version => "4", :relativePaths => "false")
|
35
|
-
REXML::Document.new(target.string)
|
36
|
-
end
|
37
|
-
|
38
|
-
def default_components
|
39
|
-
[
|
40
|
-
lambda { modules_component },
|
41
|
-
vcs_component
|
42
|
-
]
|
43
|
-
end
|
44
|
-
|
45
|
-
def initial_components
|
46
|
-
[
|
47
|
-
lambda { project_root_manager_component },
|
48
|
-
lambda { project_details_component }
|
49
|
-
]
|
50
|
-
end
|
51
|
-
|
52
|
-
def project_root_manager_component
|
53
|
-
attribs = {"version" => "2",
|
54
|
-
"assert-keyword" => "true",
|
55
|
-
"jdk-15" => "true",
|
56
|
-
"project-jdk-name" => self.jdk_version,
|
57
|
-
"project-jdk-type" => "JavaSDK",
|
58
|
-
"languageLevel" => "JDK_#{self.jdk_version.gsub('.','_')}" }
|
59
|
-
create_component("ProjectRootManager",attribs) do |xml|
|
60
|
-
xml.output("url" => "file://$PROJECT_DIR$/out")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def project_details_component
|
65
|
-
create_component("ProjectDetails") do |xml|
|
66
|
-
xml.option("name" => "projectName", "value" => self.name )
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def modules_component
|
71
|
-
create_component("ProjectModuleManager") do |xml|
|
72
|
-
xml.modules do
|
73
|
-
buildr_project.projects.select { |subp| subp.iml? }.each do |subproject|
|
74
|
-
module_path = subproject.base_dir.gsub(/^#{buildr_project.base_dir}\//, '')
|
75
|
-
path = "#{module_path}/#{subproject.iml.name}.iml"
|
76
|
-
attribs = { :fileurl => "file://$PROJECT_DIR$/#{path}", :filepath => "$PROJECT_DIR$/#{path}" }
|
77
|
-
if subproject.iml.group == true
|
78
|
-
attribs[:group] = subproject.parent.name.gsub(':', '/')
|
79
|
-
elsif !subproject.iml.group.nil?
|
80
|
-
attribs[:group] = subproject.group.to_s
|
81
|
-
end
|
82
|
-
xml.module attribs
|
83
|
-
end
|
84
|
-
self.extra_modules.each do |iml_file|
|
85
|
-
xml.module :fileurl => "file://$PROJECT_DIR$/#{iml_file}",
|
86
|
-
:filepath => "$PROJECT_DIR$/#{iml_file}"
|
87
|
-
end
|
88
|
-
if buildr_project.iml?
|
89
|
-
xml.module :fileurl => "file://$PROJECT_DIR$/#{buildr_project.iml.name}.iml",
|
90
|
-
:filepath => "$PROJECT_DIR$/#{buildr_project.iml.name}.iml"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def vcs_component
|
97
|
-
if vcs
|
98
|
-
create_component("VcsDirectoryMappings") do |xml|
|
99
|
-
xml.mapping :directory => "", :vcs => vcs
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module IntellijIdea
|
3
|
+
class IdeaProject < IdeaFile
|
4
|
+
attr_accessor :vcs
|
5
|
+
attr_accessor :extra_modules
|
6
|
+
attr_writer :jdk_version
|
7
|
+
|
8
|
+
def initialize(buildr_project)
|
9
|
+
@buildr_project = buildr_project
|
10
|
+
@vcs = detect_vcs
|
11
|
+
@extra_modules = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def jdk_version
|
15
|
+
@jdk_version ||= buildr_project.compile.options.source || "1.6"
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def extension
|
21
|
+
"ipr"
|
22
|
+
end
|
23
|
+
|
24
|
+
def detect_vcs
|
25
|
+
if File.directory?(buildr_project._('.svn'))
|
26
|
+
"svn"
|
27
|
+
elsif File.directory?(buildr_project._('.git'))
|
28
|
+
"Git"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def base_document
|
33
|
+
target = StringIO.new
|
34
|
+
Builder::XmlMarkup.new(:target => target).project(:version => "4", :relativePaths => "false")
|
35
|
+
REXML::Document.new(target.string)
|
36
|
+
end
|
37
|
+
|
38
|
+
def default_components
|
39
|
+
[
|
40
|
+
lambda { modules_component },
|
41
|
+
vcs_component
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def initial_components
|
46
|
+
[
|
47
|
+
lambda { project_root_manager_component },
|
48
|
+
lambda { project_details_component }
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
def project_root_manager_component
|
53
|
+
attribs = {"version" => "2",
|
54
|
+
"assert-keyword" => "true",
|
55
|
+
"jdk-15" => "true",
|
56
|
+
"project-jdk-name" => self.jdk_version,
|
57
|
+
"project-jdk-type" => "JavaSDK",
|
58
|
+
"languageLevel" => "JDK_#{self.jdk_version.gsub('.','_')}" }
|
59
|
+
create_component("ProjectRootManager",attribs) do |xml|
|
60
|
+
xml.output("url" => "file://$PROJECT_DIR$/out")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def project_details_component
|
65
|
+
create_component("ProjectDetails") do |xml|
|
66
|
+
xml.option("name" => "projectName", "value" => self.name )
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def modules_component
|
71
|
+
create_component("ProjectModuleManager") do |xml|
|
72
|
+
xml.modules do
|
73
|
+
buildr_project.projects.select { |subp| subp.iml? }.each do |subproject|
|
74
|
+
module_path = subproject.base_dir.gsub(/^#{buildr_project.base_dir}\//, '')
|
75
|
+
path = "#{module_path}/#{subproject.iml.name}.iml"
|
76
|
+
attribs = { :fileurl => "file://$PROJECT_DIR$/#{path}", :filepath => "$PROJECT_DIR$/#{path}" }
|
77
|
+
if subproject.iml.group == true
|
78
|
+
attribs[:group] = subproject.parent.name.gsub(':', '/')
|
79
|
+
elsif !subproject.iml.group.nil?
|
80
|
+
attribs[:group] = subproject.group.to_s
|
81
|
+
end
|
82
|
+
xml.module attribs
|
83
|
+
end
|
84
|
+
self.extra_modules.each do |iml_file|
|
85
|
+
xml.module :fileurl => "file://$PROJECT_DIR$/#{iml_file}",
|
86
|
+
:filepath => "$PROJECT_DIR$/#{iml_file}"
|
87
|
+
end
|
88
|
+
if buildr_project.iml?
|
89
|
+
xml.module :fileurl => "file://$PROJECT_DIR$/#{buildr_project.iml.name}.iml",
|
90
|
+
:filepath => "$PROJECT_DIR$/#{buildr_project.iml.name}.iml"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def vcs_component
|
97
|
+
if vcs
|
98
|
+
create_component("VcsDirectoryMappings") do |xml|
|
99
|
+
xml.mapping :directory => "", :vcs => vcs
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -1,108 +1,108 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
module Buildr
|
4
|
-
module IntellijIdea
|
5
|
-
module ProjectExtension
|
6
|
-
|
7
|
-
include Extension
|
8
|
-
|
9
|
-
first_time do
|
10
|
-
desc "Generate Intellij IDEA artifacts for all projects"
|
11
|
-
Project.local_task "iidea:generate" => "artifacts"
|
12
|
-
|
13
|
-
desc "Delete the generated Intellij IDEA artifacts"
|
14
|
-
Project.local_task "iidea:clean"
|
15
|
-
|
16
|
-
# Remove the old idea tasks if they exist. Either could depending on the names
|
17
|
-
# selected for the IDEA project files by iidea extension and thus have been removed.
|
18
|
-
task_list = Rake.application.instance_variable_get('@tasks')
|
19
|
-
task_list.delete("idea")
|
20
|
-
task_list.delete("idea7x")
|
21
|
-
task_list.delete("idea7x:clean")
|
22
|
-
end
|
23
|
-
|
24
|
-
before_define do |project|
|
25
|
-
project.recursive_task("iidea:generate")
|
26
|
-
project.recursive_task("iidea:clean")
|
27
|
-
end
|
28
|
-
|
29
|
-
after_define do |project|
|
30
|
-
iidea = project.task("iidea:generate")
|
31
|
-
|
32
|
-
files = [
|
33
|
-
(project.iml if project.iml?),
|
34
|
-
(project.ipr if project.ipr?)
|
35
|
-
].compact
|
36
|
-
|
37
|
-
files.each do |ideafile|
|
38
|
-
module_dir = File.dirname(ideafile.filename)
|
39
|
-
# Need to clear the actions else the extension included as part of buildr will run
|
40
|
-
file(ideafile.filename).clear_actions
|
41
|
-
directory(module_dir)
|
42
|
-
iidea.enhance [ file(ideafile.filename) ]
|
43
|
-
file(ideafile.filename => [Buildr.application.buildfile, module_dir]) do |task|
|
44
|
-
info "Writing #{task.name}"
|
45
|
-
t = Tempfile.open("buildr-iidea")
|
46
|
-
temp_filename = t.path
|
47
|
-
t.close!
|
48
|
-
File.open(temp_filename, "w") do |f|
|
49
|
-
ideafile.write f
|
50
|
-
end
|
51
|
-
mv temp_filename, ideafile.filename
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
project.task("iidea:clean") do
|
56
|
-
files.each do |f|
|
57
|
-
info "Removing #{f.filename}" if File.exist?(f.filename)
|
58
|
-
rm_rf f.filename
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def ipr
|
64
|
-
if ipr?
|
65
|
-
@ipr ||= IdeaProject.new(self)
|
66
|
-
else
|
67
|
-
raise "Only the root project has an IPR"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def ipr?
|
72
|
-
!@no_ipr && self.parent.nil?
|
73
|
-
end
|
74
|
-
|
75
|
-
def iml
|
76
|
-
if iml?
|
77
|
-
unless @iml
|
78
|
-
inheritable_iml_source = self.parent
|
79
|
-
while inheritable_iml_source && !inheritable_iml_source.iml?
|
80
|
-
inheritable_iml_source = inheritable_iml_source.parent;
|
81
|
-
end
|
82
|
-
@iml = inheritable_iml_source ? inheritable_iml_source.iml.clone : IdeaModule.new
|
83
|
-
@iml.buildr_project = self
|
84
|
-
end
|
85
|
-
return @iml
|
86
|
-
else
|
87
|
-
raise "IML generation is disabled for #{self.name}"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def no_ipr
|
92
|
-
@no_ipr = true
|
93
|
-
end
|
94
|
-
|
95
|
-
def no_iml
|
96
|
-
@has_iml = false
|
97
|
-
end
|
98
|
-
|
99
|
-
def iml?
|
100
|
-
@has_iml = @has_iml.nil? ? true : @has_iml
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class Buildr::Project
|
107
|
-
include Buildr::IntellijIdea::ProjectExtension
|
108
|
-
end
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
module Buildr
|
4
|
+
module IntellijIdea
|
5
|
+
module ProjectExtension
|
6
|
+
|
7
|
+
include Extension
|
8
|
+
|
9
|
+
first_time do
|
10
|
+
desc "Generate Intellij IDEA artifacts for all projects"
|
11
|
+
Project.local_task "iidea:generate" => "artifacts"
|
12
|
+
|
13
|
+
desc "Delete the generated Intellij IDEA artifacts"
|
14
|
+
Project.local_task "iidea:clean"
|
15
|
+
|
16
|
+
# Remove the old idea tasks if they exist. Either could depending on the names
|
17
|
+
# selected for the IDEA project files by iidea extension and thus have been removed.
|
18
|
+
task_list = Rake.application.instance_variable_get('@tasks')
|
19
|
+
task_list.delete("idea")
|
20
|
+
task_list.delete("idea7x")
|
21
|
+
task_list.delete("idea7x:clean")
|
22
|
+
end
|
23
|
+
|
24
|
+
before_define do |project|
|
25
|
+
project.recursive_task("iidea:generate")
|
26
|
+
project.recursive_task("iidea:clean")
|
27
|
+
end
|
28
|
+
|
29
|
+
after_define do |project|
|
30
|
+
iidea = project.task("iidea:generate")
|
31
|
+
|
32
|
+
files = [
|
33
|
+
(project.iml if project.iml?),
|
34
|
+
(project.ipr if project.ipr?)
|
35
|
+
].compact
|
36
|
+
|
37
|
+
files.each do |ideafile|
|
38
|
+
module_dir = File.dirname(ideafile.filename)
|
39
|
+
# Need to clear the actions else the extension included as part of buildr will run
|
40
|
+
file(ideafile.filename).clear_actions
|
41
|
+
directory(module_dir)
|
42
|
+
iidea.enhance [ file(ideafile.filename) ]
|
43
|
+
file(ideafile.filename => [Buildr.application.buildfile, module_dir]) do |task|
|
44
|
+
info "Writing #{task.name}"
|
45
|
+
t = Tempfile.open("buildr-iidea")
|
46
|
+
temp_filename = t.path
|
47
|
+
t.close!
|
48
|
+
File.open(temp_filename, "w") do |f|
|
49
|
+
ideafile.write f
|
50
|
+
end
|
51
|
+
mv temp_filename, ideafile.filename
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
project.task("iidea:clean") do
|
56
|
+
files.each do |f|
|
57
|
+
info "Removing #{f.filename}" if File.exist?(f.filename)
|
58
|
+
rm_rf f.filename
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def ipr
|
64
|
+
if ipr?
|
65
|
+
@ipr ||= IdeaProject.new(self)
|
66
|
+
else
|
67
|
+
raise "Only the root project has an IPR"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def ipr?
|
72
|
+
!@no_ipr && self.parent.nil?
|
73
|
+
end
|
74
|
+
|
75
|
+
def iml
|
76
|
+
if iml?
|
77
|
+
unless @iml
|
78
|
+
inheritable_iml_source = self.parent
|
79
|
+
while inheritable_iml_source && !inheritable_iml_source.iml?
|
80
|
+
inheritable_iml_source = inheritable_iml_source.parent;
|
81
|
+
end
|
82
|
+
@iml = inheritable_iml_source ? inheritable_iml_source.iml.clone : IdeaModule.new
|
83
|
+
@iml.buildr_project = self
|
84
|
+
end
|
85
|
+
return @iml
|
86
|
+
else
|
87
|
+
raise "IML generation is disabled for #{self.name}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def no_ipr
|
92
|
+
@no_ipr = true
|
93
|
+
end
|
94
|
+
|
95
|
+
def no_iml
|
96
|
+
@has_iml = false
|
97
|
+
end
|
98
|
+
|
99
|
+
def iml?
|
100
|
+
@has_iml = @has_iml.nil? ? true : @has_iml
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Buildr::Project
|
107
|
+
include Buildr::IntellijIdea::ProjectExtension
|
108
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Buildr
|
2
|
-
module IntellijIdea
|
3
|
-
class Version
|
4
|
-
MAJOR = "0"
|
5
|
-
MINOR = "0"
|
6
|
-
MICRO = "
|
7
|
-
|
8
|
-
STRING = "#{MAJOR}.#{MINOR}.#{MICRO}"
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module IntellijIdea
|
3
|
+
class Version
|
4
|
+
MAJOR = "0"
|
5
|
+
MINOR = "0"
|
6
|
+
MICRO = "10"
|
7
|
+
|
8
|
+
STRING = "#{MAJOR}.#{MINOR}.#{MICRO}"
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
data/lib/buildr_iidea.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'buildr'
|
2
|
-
require 'buildr/intellij_idea/version'
|
3
|
-
require 'buildr/intellij_idea/idea_file'
|
4
|
-
require 'buildr/intellij_idea/idea_module'
|
5
|
-
require 'buildr/intellij_idea/idea_project'
|
6
|
-
require 'buildr/intellij_idea/project_extension'
|
1
|
+
require 'buildr'
|
2
|
+
require 'buildr/intellij_idea/version'
|
3
|
+
require 'buildr/intellij_idea/idea_file'
|
4
|
+
require 'buildr/intellij_idea/idea_module'
|
5
|
+
require 'buildr/intellij_idea/idea_project'
|
6
|
+
require 'buildr/intellij_idea/project_extension'
|