Class: Buildr::Eclipse::Eclipse

Inherits:
Object
  • Object
show all
Defined in:
lib/buildr/ide/eclipse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Eclipse

Returns a new instance of Eclipse.



29
30
31
32
# File 'lib/buildr/ide/eclipse.rb', line 29

def initialize(project)
  @project = project
  @options = Options.new(project)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



27
28
29
# File 'lib/buildr/ide/eclipse.rb', line 27

def options
  @options
end

Instance Method Details

#builders(*values) ⇒ Object

:call-seq:

builders() => [b1, b2]

Returns the Eclipse project builders on the project. They may be derived from the parent project if no specific builders have been set on the project.

A builder is an Eclipse background job that parses the source code to produce built artifacts.



141
142
143
144
145
146
147
148
# File 'lib/buildr/ide/eclipse.rb', line 141

def builders(*values)
  if values.size > 0
    @builders ||= []
    @builders += values
  else
    @builders || (@project.parent ? @project.parent.eclipse.builders : [])
  end
end

#builders=(var) ⇒ Object

:call-seq:

builders=(builders)

Sets the Eclipse project builders on the project.



130
131
132
# File 'lib/buildr/ide/eclipse.rb', line 130

def builders=(var)
  @builders = arrayfy(var)
end

#classpath_containers(*values) ⇒ Object

:call-seq:

classpath_containers() => [con1, con2]

Returns the Eclipse project classpath containers on the project. They may be derived from the parent project if no specific classpath containers have been set on the project.

A classpath container is an Eclipse pre-determined ensemble of dependencies made available to the project classpath.



97
98
99
100
101
102
103
104
# File 'lib/buildr/ide/eclipse.rb', line 97

def classpath_containers(*values)
  if values.size > 0
    @classpath_containers ||= []
    @classpath_containers += values
  else
    @classpath_containers || (@project.parent ? @project.parent.eclipse.classpath_containers : [])
  end
end

#classpath_containers=(var) ⇒ Object

:call-seq:

classpath_containers=(cc)

Sets the Eclipse project classpath containers on the project.



85
86
87
# File 'lib/buildr/ide/eclipse.rb', line 85

def classpath_containers=(var)
  @classpath_containers = arrayfy(var)
end

#classpath_variables(*values) ⇒ Object

:call-seq:

classpath_variables { :VAR => '/path/to/location' }

Sets classpath variables to be used for library path substitution on the project.



39
40
41
42
43
44
45
46
47
48
# File 'lib/buildr/ide/eclipse.rb', line 39

def classpath_variables(*values)
  fail "eclipse.classpath_variables expects a single hash argument" if values.size > 1
  if values.size == 1
    fail "eclipse.classpath_variables expects a Hash argument" unless values[0].is_a? Hash
    # convert keys to strings
    values = values[0].inject({}) { |h, (k,v)| h[k.to_s] = @project.path_to(v); h }
    @variables = values.merge(@variables || {})
  end
  @variables || (@project.parent ? @project.parent.eclipse.classpath_variables : default_classpath_variables)
end

#default_classpath_variablesObject



50
51
52
53
54
55
# File 'lib/buildr/ide/eclipse.rb', line 50

def default_classpath_variables
  vars = {}
  vars[:SCALA_HOME] = ENV['SCALA_HOME'] if ENV['SCALA_HOME']
  vars[:JAVA_HOME]  = ENV['JAVA_HOME']  if ENV['JAVA_HOME']
  vars
end

#exclude_libs(*values) ⇒ Object

:call-seq:

exclude_libs() => [lib1, lib2]

Returns the an array of libraries to be excluded from the generated Eclipse classpath



109
110
111
112
113
114
115
116
# File 'lib/buildr/ide/eclipse.rb', line 109

def exclude_libs(*values)
  if values.size > 0
    @exclude_libs ||= []
    @exclude_libs += values
  else
    @exclude_libs || (@project.parent ? @project.parent.eclipse.exclude_libs : [])
  end
end

#exclude_libs=(libs) ⇒ Object

:call-seq:

exclude_libs=(lib1, lib2)

Sets libraries to be excluded from the generated Eclipse classpath



122
123
124
# File 'lib/buildr/ide/eclipse.rb', line 122

def exclude_libs=(libs)
  @exclude_libs = arrayfy(libs)
end

#external_sources(*values) ⇒ Object



154
155
156
157
158
159
160
161
# File 'lib/buildr/ide/eclipse.rb', line 154

def external_sources(*values)
  if values.size > 0
    @external_sources ||= []
    @external_sources += values
  else
    @external_sources || (@project.parent ? @project.parent.eclipse.external_sources : [])
  end
end

#external_sources=(var) ⇒ Object



150
151
152
# File 'lib/buildr/ide/eclipse.rb', line 150

def external_sources=(var)
  @external_sources = arrayfy(var)
end

#natures(*values) ⇒ Object

:call-seq:

natures() => [n1, n2]

Returns the Eclipse project natures on the project. They may be derived from the parent project if no specific natures have been set on the project.

An Eclipse project nature is used internally by Eclipse to determine the aspects of a project.



72
73
74
75
76
77
78
79
# File 'lib/buildr/ide/eclipse.rb', line 72

def natures(*values)
  if values.size > 0
    @natures ||= []
    @natures += values
  else
    @natures || (@project.parent ? @project.parent.eclipse.natures : [])
  end
end

#natures=(var) ⇒ Object

:call-seq:

natures=(natures)

Sets the Eclipse project natures on the project.



61
62
63
# File 'lib/buildr/ide/eclipse.rb', line 61

def natures=(var)
  @natures = arrayfy(var)
end