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.



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

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

Instance Attribute Details

#nameObject



35
36
37
38
39
# File 'lib/buildr/ide/eclipse.rb', line 35

def name
  return @name if @name
  return @project.id.split('-').last if @options.short_names
  @project.id
end

#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.



148
149
150
151
152
153
154
155
# File 'lib/buildr/ide/eclipse.rb', line 148

def builders(*values)
  if values.size > 0
    @builders ||= []
    @builders += values.flatten
  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.



137
138
139
# File 'lib/buildr/ide/eclipse.rb', line 137

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.



104
105
106
107
108
109
110
111
# File 'lib/buildr/ide/eclipse.rb', line 104

def classpath_containers(*values)
  if values.size > 0
    @classpath_containers ||= []
    @classpath_containers += values.flatten
  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.



92
93
94
# File 'lib/buildr/ide/eclipse.rb', line 92

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.



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

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



57
58
59
60
61
62
# File 'lib/buildr/ide/eclipse.rb', line 57

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



116
117
118
119
120
121
122
123
# File 'lib/buildr/ide/eclipse.rb', line 116

def exclude_libs(*values)
  if values.size > 0
    @exclude_libs ||= []
    @exclude_libs += values.flatten
  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



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

def exclude_libs=(libs)
  @exclude_libs = arrayfy(libs)
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.



79
80
81
82
83
84
85
86
# File 'lib/buildr/ide/eclipse.rb', line 79

def natures(*values)
  if values.size > 0
    @natures ||= []
    @natures += values.flatten
  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.



68
69
70
# File 'lib/buildr/ide/eclipse.rb', line 68

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