lib/maven/tools/dsl.rb in maven-tools-1.0.0.rc5 vs lib/maven/tools/dsl.rb in maven-tools-1.0.0.rc6

- old
+ new

@@ -243,20 +243,24 @@ source = options[ :source ] || options[ 'source' ] build do source_directory source end end - if jar && ( source || - ::File.exists?( ::File.join( basedir, 'src', 'main', 'java' ) ) ) && spec.platform.to_s.match( /java|jruby/ ) + if jar && ( source || + ::File.exists?( ::File.join( basedir, 'src', 'main', 'java' ) ) ) + unless spec.nil? || spec.platform.to_s.match( /java|jruby/ ) + warn "gem is not a java platform gem but has a jar and source" + end + plugin( :jar, VERSIONS[ :jar_plugin ], :outputDirectory => output, :finalName => jar ) do execute_goals :jar, :phase => 'prepare-package' end plugin( :clean, VERSIONS[ :clean_plugin ], :filesets => [ { :directory => output, - :includes => [ "#{jar}.jar" ] } ] ) + :includes => [ "#{jar}.jar", '*/**/*.jar' ] } ] ) true else false end end @@ -297,11 +301,11 @@ if options[ :skip_locked ] or not file.exists_lock? file.populate_unlocked do |dsl| setup_jruby( dsl.jruby ) dsl.artifacts.each do |a| - dependency a + _dependency a end end else file.locked.each do |dep| artifact( dep ) @@ -393,10 +397,11 @@ return if options[ :only_metadata ] config = { :gemspec => name.sub( /^#{basedir}\/?/, '' ) } if options[ :include_jars ] || options[ 'include_jars' ] config[ :includeDependencies ] = true + config[ :useRepositoryLayout ] = true end jruby_plugin!( :gem, config ) deps = nil if @inside_gemfile.is_a? Symbol @@ -407,11 +412,11 @@ deps = all_deps( spec ) end unless deps.java_runtime.empty? deps.java_runtime.each do |d| - dependency Maven::Tools::Artifact.new( *d ) + _dependency Maven::Tools::Artifact.new( *d ) end end end def all_deps( spec ) @@ -428,10 +433,25 @@ end deps end private :all_deps + def licenses + yield + end + alias :developers :licenses + alias :contributors :licenses + alias :mailing_lists :licenses + alias :notifiers :licenses + alias :dependencies :licenses + alias :repositories :licenses + alias :plugin_repositories :licenses + alias :extensions :licenses + alias :resources :licenses + alias :testResources :licenses + alias :plugins :licenses + def build( &block ) build = @current.build ||= Build.new nested_block( :build, build, block ) if block build end @@ -976,19 +996,19 @@ @current.executions << exec nested_block(:execution, exec, block) if block exec end - def dependency( type, *args, &block ) + def _dependency( type, *args, &block ) do_dependency( false, type, *args, &block ) end - def dependency!( type, *args, &block ) + def _dependency!( type, *args, &block ) do_dependency( true, type, *args, &block ) end - def dependency?( type, *args ) + def _dependency?( type, *args ) find_dependency( dependency_container, retrieve_dependency( type, *args ) ) != nil end def find_dependency( container, dep ) @@ -1120,18 +1140,33 @@ else profile( id, &block ) end end - def profile( id, &block ) + def profile( *args, &block ) profile = Profile.new - profile.id = id if id + args, options = args_and_options( *args ) + profile.id = args[ 0 ] + fill_options( profile, options ) @current.profiles << profile nested_block( :profile, profile, block ) if block profile end + def dependency( *args, &block ) + dep = Dependency.new + args, options = args_and_options( *args ) + dep.group_id = args[ 0 ] + dep.artifact_id = args[ 1 ] + dep.version = args[ 2 ] + dep.type = :jar + fill_options( dep, options ) + nested_block( :dependency, dep, block ) if block + dependency_container << dep + dep + end + def report_set( *reports, &block ) set = ReportSet.new case reports.last when Hash options = reports.last @@ -1158,11 +1193,11 @@ d.group_id == 'rubygems' && d.artifact_id == name && d.type == :gem end end def jar!( *args ) - dependency!( :jar, *args ) + _dependency!( :jar, *args ) end def gem( *args ) do_gem( false, *args ) end @@ -1215,11 +1250,11 @@ end end def local( path, options = {} ) path = ::File.expand_path( path ) - dependency( :jar, + _dependency( :jar, Maven::Tools::Artifact.new_local( path, :jar, options ) ) end def method_missing( method, *args, &block ) if @context @@ -1258,14 +1293,14 @@ # args[0].is_a?( String ) && # args[0] =~ /^[${}0-9a-zA-Z._-]+(:[${}0-9a-zA-Z._-]+)+$/ ) || # ( args.size == 1 && args[0].is_a?( Hash ) ) case method.to_s[ -1 ] when '?' - dependency?( method.to_s[0..-2].to_sym, *args, &block ) + _dependency?( method.to_s[0..-2].to_sym, *args, &block ) when '!' - dependency!( method.to_s[0..-2].to_sym, *args, &block ) + _dependency!( method.to_s[0..-2].to_sym, *args, &block ) else - dependency( method, *args, &block ) + _dependency( method, *args, &block ) end # elsif @current.respond_to? method # @current.send( method, *args ) # @current # else