Changeset 5846

Show
Ignore:
Timestamp:
10/06/06 20:00:36
Author:
jan
Message:

new depends_on syntax

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Rakefile.jerbil

    r5825 r5846  
    2020 
    2121desc "compile all java files" 
    22 Rake::JavacTask.new(:compile) do |jct| 
    23   jct.java_files = JAVA_FILES 
     22Rake::JavacTask.new(:compile) do |t| 
     23  t.java_files = JAVA_FILES 
    2424end 
    2525 
    2626desc "compile all tests" 
    27 Rake::JavacTask.new(:test_compile) do |jct| 
    28   jct.java_files = JAVA_TEST_FILES 
     27Rake::JavacTask.new(:test_compile) do |t| 
     28  t.java_files = JAVA_TEST_FILES 
     29  t.depends_on :compile 
    2930end 
    30 task :test_compile => [ :compile ] 
    3131 
    3232desc "run tests" 
    3333Rake::TestNG::TestNGTask.new(:test) do |t| 
    3434  t.tests = JAVA_TEST_FILES 
     35  t.depends_on :test_compile 
    3536end 
    36 task :test => [ :test_compile ] 
    3737 
    3838Rake::JavaDocTask.new do |t| 
    3939  t.sourcepath = SOURCE_DIR 
    4040  t.dstdir = JAVADOC_DIR 
     41  t.depends_on :compile 
    4142end 
    42 task :javadoc => [ :compile ] 
    4343 
    4444task :clean do |t| 
  • trunk/lib/hibernate_task.rb

    r5753 r5846  
    1111      include JavaHelper 
    1212       
    13       attr_accessor :name 
    14       attr_accessor :dependencies 
     13      attr_accessor :name     
    1514      attr_accessor :description 
    1615       
     
    2322      def initialize(name) 
    2423        @name = name 
    25         @description = nil 
    26         @dependencies = [] 
     24        @description = nil         
    2725        @srcfiles = [] 
    2826        @classpath = FileList.new 
  • trunk/lib/hibernate_task2.rb

    r5784 r5846  
    1111       
    1212      attr_accessor :name 
    13       attr_accessor :dependencies 
    1413       
    1514      attr_accessor :schemafile 
  • trunk/lib/jar_task.rb

    r5832 r5846  
    1212      yield self if block_given? 
    1313      raise "must define filename" if filename.nil?  
    14       raise "must define dir or files" if dir.nil? and files.nil?  
     14      raise "must define dir or files" if dir.nil? and files.nil?      
    1515      define 
    1616    end 
     
    1818    def define 
    1919      jardir = File.dirname(filename) 
    20       task name => [ jardir ] do |t| 
     20      depends_on jardir 
     21      task name => dependencies do |t| 
    2122         jar = Rjb::import('sun.tools.jar.Main') 
    2223         args = [ "cf" ] 
  • trunk/lib/java_helper.rb

    r5845 r5846  
    122122end 
    123123 
    124 class FileList   
     124class Rake::FileList   
    125125  def to_cp   
    126126    self.join($JAVA_PATH_SEPERATOR) 
     127  end 
     128end 
     129 
     130class Rake::TaskLib   
     131  def depends_on(*args) 
     132    dependencies.concat(args) 
     133  end 
     134   
     135  def dependencies 
     136    @dependencies ||= [] 
    127137  end 
    128138end 
  • trunk/lib/javac_task.rb

    r5845 r5846  
    1313    create_alias_for :g, :debug 
    1414     
    15     def initialize(name) 
     15    def initialize(name)    
    1616      @name = name 
    1717      @verbose = false 
     18     
    1819      yield self if block_given? 
     20      depends_on java_files.dstdir 
    1921      define      
    2022    end 
     
    2224    def define 
    2325            desc "compile files in #{java_files.srcdir.to_a.join(', ')}" if Rake.application.last_comment.nil?      
    24       task name => java_files.dstdir do |t| 
     26      task name => dependencies do |t| 
    2527           
    2628        parms  = [ "-d", java_files.dstdir ] 
  • trunk/lib/javadoc_task.rb

    r5845 r5846  
    1313      yield self if block_given? 
    1414      raise "need dstdir parameter" if dstdir.nil? 
     15      depends_on dstdir 
    1516      define 
    1617     end 
     
    1819     def define 
    1920      desc "generate javadocs" if Rake.application.last_comment.nil? 
    20       task name => dstdir do |t| 
     21      task name => dependencies do |t| 
    2122        javadoc = Rjb::import('com.sun.tools.javadoc.Main')     
    2223        args = [ "-d", dstdir ]                                                     
  • trunk/lib/testng_task.rb

    r5826 r5846  
    66module Rake 
    77  module TestNG 
    8     class TestNGTask < TaskLib 
     8    class TestNGTask < Rake::TaskLib 
    99      include JavaHelper 
    1010       
    1111      attr_accessor :name 
    12       attr_accessor :dependencies 
    1312      attr_accessor :tests 
    1413      attr_accessor :outputdir 
     
    2019      def initialize(name) 
    2120        @name = name 
    22         @dependencies = [] 
    2321        @tests = [] 
    2422        @outputdir = "test-output" 
     
    2826        @excludedgroups = nil 
    2927        yield self if block_given? 
    30         dependencies << workingdir unless workingdir.nil? 
    31         dependencies << outputdir 
     28        depends_on workingdir unless workingdir.nil? 
     29        depends_on outputdir 
    3230        define 
    3331      end 
  • trunk/sample/Rakefile

    r5845 r5846  
    1010 
    1111desc "compile all java files" 
    12 Rake::JavacTask.new(:compile) do |jct| 
    13   jct.java_files = JAVA_FILES 
    14   jct.options :nowarn, :debug 
    15   jct.source = "1.5" 
    16   jct.target = "1.5"  
     12Rake::JavacTask.new(:compile) do |t| 
     13  t.java_files = JAVA_FILES 
     14  t.options :nowarn, :debug 
     15  t.source = "1.5" 
     16  t.target = "1.5"  
    1717end 
    1818 
    1919desc "compile all tests" 
    20 Rake::JavacTask.new(:test_compile) do |jct| 
    21   jct.java_files = JAVA_TEST_FILES 
     20Rake::JavacTask.new(:test_compile) do |t| 
     21  t.java_files = JAVA_TEST_FILES 
     22  t.depends_on :compile 
    2223end 
    23 task :test_compile => [ :compile ] 
    2424 
    2525desc "run tests" 
     
    2727  t.outputdir = TESTOUTPUTDIR 
    2828  t.tests     = JAVA_TEST_FILES 
     29  t.depends_on :test_compile 
    2930end 
    30 task :test => [ :test_compile ] 
    3131 
    3232Rake::JavaDocTask.new do |t| 
     
    3535  t.dstdir = JAVADOC_DIR 
    3636  t.options :quiet   
     37  t.depends_on :compile 
    3738end 
    38 task :javadoc => [ :compile ] 
    3939 
    4040Rake::JarTask.new do |t| 
    4141  t.dir = JAVA_BUILD_DIR 
    4242  t.filename = DISTJAR 
     43  t.depends_on :clean, :compile 
    4344end 
    44 task :jar => [ :clean, :compile ] 
    4545 
    4646Rake::JavaTask.new(:run, "jerbil.sample.Main") do |t| 
    4747  t.classpath = CLASSPATH 
    4848  t.parameters = [ "50", "50" ] 
     49  t.depends_on :compile 
    4950end 
    50 task :run => [ :compile ] 
    5151 
    5252desc "find annotations and write output to #{ANNOTATED_CLASSES}" 
     
    5454  t.java_files= JAVA_FILES 
    5555  t.nocompile = true 
     56  t.depends_on :compile 
    5657  t.find_annotation 'jerbil.sample.MyAnnotation' do |classes| 
    5758    File.open(ANNOTATED_CLASSES, 'w') { |f| f << classes.to_yaml } 
    5859  end 
    5960end 
    60 task :find_annotations => [ :compile ] 
     61 
    6162file ANNOTATED_CLASSES => [ :find_annotations ] 
    6263 
     
    6566    rm_rf BUILD_DIR 
    6667    rm_rf DIST_DIR 
     68    rm_rf TESTOUTPUTDIR 
    6769  end 
    6870end 
  • trunk/test/test_build.rb

    r5844 r5846  
    5252   
    5353  def test_run 
    54     run_rake(:clean, :run) do 
    55      
     54    run_rake(:clean, :run) do     
     55    end 
     56  end 
     57   
     58  def test_clean 
     59    run_rake(:clean, :compile, :jar, :test) 
     60    run_rake(:clean) do 
     61      assert !File.directory?(TESTOUTPUTDIR)   
     62      assert !File.directory?(BUILD_DIR) 
     63      assert !File.directory?(DIST_DIR) 
    5664    end 
    5765  end