Skip to content

Commit

Permalink
support for exclude in dependencies and dropping LegacyDependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Oct 30, 2015
1 parent 74d932d commit 11eedb5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 36 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ From version 1.1.0 you can use the same gradle dependency string that Java users
app.gradle do
dependency 'net.sf.ehcache:ehcache:2.9.0'
dependency 'com.joanzapata.pdfview:android-pdfview:1.0.+@aar'
dependency 'com.danikula:videocache:2.3.1' do
exclude module: 'android', group: 'com.google.android'
end
end
end
```
Expand Down
2 changes: 1 addition & 1 deletion lib/motion-gradle.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'pathname'
require 'shellwords'
require 'motion_gradle/legacy_dependency'
require 'motion_gradle/dependency'
require 'motion_gradle/aidl'
require 'motion_gradle/template'
require 'motion_gradle/version'
Expand Down
8 changes: 2 additions & 6 deletions lib/motion/project/gradle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ def path=(path)
@gradle_path = path
end

def dependency(name, options = {})
if name.include?(':')
@dependencies << name
else
@dependencies << MotionGradle::LegacyDependency.new(name, options)
end
def dependency(name, &block)
@dependencies << MotionGradle::Dependency.new(name, &block)
end

def library(library_name, options = {})
Expand Down
16 changes: 16 additions & 0 deletions lib/motion_gradle/dependency.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module MotionGradle
class Dependency
attr_reader :name
attr_reader :excludes

def initialize(name, &block)
@name = name
@excludes = []
instance_eval(&block) if block_given?
end

def exclude(options = {})
@excludes << options
end
end
end
23 changes: 0 additions & 23 deletions lib/motion_gradle/legacy_dependency.rb

This file was deleted.

11 changes: 6 additions & 5 deletions lib/motion_gradle/templates/build.gradle.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ dependencies {
compile project(':<%= library[:name] %>')
<% end %>
<% dependencies.each do |dependency| %>
<% if dependency.is_a?(MotionGradle::LegacyDependency) %>
<%= dependency.parse %>
<% else %>
compile '<%= dependency %>'
<% end %>
compile '<%= dependency.name %>', {
<% dependency.excludes.each do |exclude| %>
exclude module: '<%= exclude[:module] %>',
group: '<%= exclude[:group] %>'
<% end %>
}
<% end %>
}
2 changes: 1 addition & 1 deletion lib/motion_gradle/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module MotionGradle
VERSION = '1.6.0'
VERSION = '2.0.0'
end

0 comments on commit 11eedb5

Please sign in to comment.