lib/maven/tools/jarfile.rb in maven-tools-1.0.4 vs lib/maven/tools/jarfile.rb in maven-tools-1.0.5

- old
+ new

@@ -19,10 +19,12 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # require ::File.join(::File.dirname(__FILE__), 'coordinate.rb') require ::File.join(::File.dirname(__FILE__), 'artifact.rb') require 'fileutils' +require 'delegate' +require 'maven/tools/dsl/jarfile' module Maven module Tools class Jarfile include Coordinate @@ -77,10 +79,11 @@ jarfile = self.new jarfile.eval_file( file ) end def eval_file( file ) + warn "#{self.class} is deprecated" if ::File.exists?( file ) eval( ::File.read( file ), nil, file ) self end end @@ -150,13 +153,31 @@ @scope = nil end end + class LockedParent < SimpleDelegator + def initialize(obj) + super + end + + def dependencies + @d ||= [] + end + end + + def setup_unlocked( parent ) + Maven::Tools::DSL::Jarfile.new( @file, parent ) + end + + def setup_locked( parent ) + Maven::Tools::DSL::Jarfile.new( @file, LockedParent.new( parent ) ) + end + def populate_unlocked( container = nil, &block ) if ::File.exists?(@file) - dsl = DSL.new - dsl.eval_file( @file ) + dsl = Maven::Tools::DSL::Jarfile.new( @file ) + #dsl.eval_file( @file ) if block block.call( dsl ) end # TODO all that container stuff needs to go into jbundler !!!