Class: Maven::Tools::RailsProject
- Inherits:
-
GemProject
- Object
- Model::Tag
- Model::Coordinate
- Model::Project
- MavenProject
- GemProject
- Maven::Tools::RailsProject
- Defined in:
- lib/maven/tools/rails_project.rb
Instance Method Summary collapse
- #add_defaults(args = {}) ⇒ Object
- #has_gem?(gem) ⇒ Boolean
-
#initialize(name = dir_name, &block) ⇒ RailsProject
constructor
A new instance of RailsProject.
Methods inherited from GemProject
#gem, #gemspec, #git, #group, #load_gemfile, #load_gemspec, #path, #platforms, #source
Methods inherited from MavenProject
#load_jarfile, #load_mavenfile
Methods inherited from Model::Project
#_name, #build, #dependency_management, #description, #description=, #developers, #dump_pom, #execute_in_phase, #executions_in_phase, #licenses, #name, #name=, #parent, #plugin, #plugin?, #plugin_repositories, #plugin_repository, #profile, #profiles, #properties, #properties=, #repositories, #repository, #source_control, #version
Methods included from Model::Dependencies
#dependencies, #detect_gem, #gem, #gem?, included, #jar, #jar?, #pom, #pom?, #test_jar, #test_jar?
Methods inherited from Model::Coordinate
Methods included from Coordinate
#gav, #group_artifact, #to_coordinate, #to_split_coordinate, #to_version
Methods inherited from Model::Tag
#_name, _tags, #comment, prepend_tags, tags, #to_xml
Constructor Details
#initialize(name = dir_name, &block) ⇒ RailsProject
Returns a new instance of RailsProject.
27 28 29 30 31 |
# File 'lib/maven/tools/rails_project.rb', line 27 def initialize(name = dir_name, &block) super(name, &block) group_id "rails" packaging "war" end |
Instance Method Details
#add_defaults(args = {}) ⇒ Object
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/maven/tools/rails_project.rb', line 38 def add_defaults(args = {}) self.name = "#{dir_name} - rails application" unless name # setup bundler plugin plugin(:bundler) s_args = args.dup s_args.delete(:jruby_plugins) super(s_args) versions = VERSIONS.merge(args) rails_gem = dependencies.detect { |d| d.type.to_sym == :gem && d.artifact_id.to_s =~ /^rail.*s$/ } # allow rails or railties if !jar?("org.jruby:jruby-complete") && !jar?("org.jruby:jruby-core") && versions[:jruby_version] minor = versions[:jruby_version].sub(/[0-9]*\./, '').sub(/\..*/, '') #TODO once jruby-core pom is working !!! if minor.to_i > 55 #TODO fix minor minimum version jar("org.jruby:jruby-core", versions[:jruby_version]) jar("org.jruby:jruby-stdlib", versions[:jruby_version]) # override deps which works jar("jline:jline", '0.9.94') if versions[:jruby_version] =~ /1.6.[1-2]/ jar("org.jruby.extras:jffi", '1.0.8', 'native') if versions[:jruby_version] =~ /1.6.[0-2]/ jar("org.jruby.extras:jaffl", '0.5.10') if versions[:jruby_version] =~ /1.6.[0-2]/ else jar("org.jruby:jruby-complete", "${jruby.version}") end end jar("org.jruby.rack:jruby-rack", versions[:jruby_rack]) unless jar?("org.jruby.rack:jruby-rack") self.properties = { "jruby.version" => versions[:jruby_version], "rails.env" => "development", "gem.includeRubygemsInTestResources" => false }.merge(self.properties) dependencies.find { |d| d.artifact_id == 'bundler' }.scope = nil plugin(:rails3) do |rails| rails.version = "${jruby.plugins.version}" unless rails.version rails.in_phase(:validate).execute_goal(:initialize) end plugin(:war, versions[:war_plugin]) unless plugin?(:war) plugin(:war) do |w| = { :webResources => Maven::Model::NamedArray.new(:resource) do |l| l << { :directory => "public" } l << { :directory => ".", :targetPath => "WEB-INF", :includes => ['app/**', 'config/**', 'lib/**', 'vendor/**', 'Gemfile'] } l << { :directory => '${gem.path}', :targetPath => 'WEB-INF/gems', :includes => ['gems/**', 'specifications/**'] } if plugin(:bundler).dependencies.detect { |d| d.type.to_sym == :gem } l << { :directory => '${gem.path}-bundler-maven-plugin', :targetPath => 'WEB-INF/gems', :includes => ['specifications/**'] } end end } [:webXml] = 'config/web.xml' if File.exists?('config/web.xml') || !File.exists?('src/main/webapp/WEB-INF/web.xml') w.with end profile(:assets).activation.by_default if profiles.key?(:assets) profile(:development).activation.by_default profile(:test).activation.by_default profile(:test).activation.property("rails.env", "test") profile(:production) do |prod| prod.activation.property("rails.env", "production") prod.properties = { "gem.home" => "${project.build.directory}/rubygems-production", "gem.path" => "${project.build.directory}/rubygems-production" }.merge(prod.properties) end end |
#has_gem?(gem) ⇒ Boolean
33 34 35 36 |
# File 'lib/maven/tools/rails_project.rb', line 33 def has_gem?(gem) assets = profile(:assets) self.gem?(gem) || (assets && assets.gem?(gem)) end |