Subversion Repositories DevTools

Rev

Rev 864 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 864 Rev 866
Line 91... Line 91...
91
  /**Set true when ant error reported on any target.
91
  /**Set true when ant error reported on any target.
92
   * @attribute
92
   * @attribute
93
   */
93
   */
94
  private boolean mErrorReported;
94
  private boolean mErrorReported;
95
 
95
 
96
  /**Set true when ant error reported on AbtSetUp target.
96
  /**Logger
97
   * @attribute
97
   * @attribute
98
   */
98
   */
99
  private boolean mSetUpErrorReported;
99
  private static final Logger mLogger = Logger.getLogger(BuildThread.class);
100
 
100
 
101
  /**Logger
101
  /**Package name for reporting purposes.
102
   * @attribute
102
   * @attribute
103
   */
103
   */
-
 
104
  protected String mReportingPackageName;
-
 
105
 
-
 
106
  /**Package version for reporting purposes.
-
 
107
   * @attribute
-
 
108
   */
-
 
109
  protected String mReportingPackageVersion;
-
 
110
 
-
 
111
  /**Package extension for reporting purposes.
-
 
112
   * @attribute
-
 
113
   */
-
 
114
  protected String mReportingPackageExtension;
-
 
115
 
-
 
116
  /**Package location for reporting purposes.
-
 
117
   * @attribute
-
 
118
   */
-
 
119
  protected String mReportingPackageLocation;
-
 
120
 
-
 
121
  /**Package dependencies for reporting purposes.
-
 
122
   * @attribute
-
 
123
   */
-
 
124
  protected String mReportingPackageDepends;
-
 
125
 
-
 
126
  /**Is ripple flag for reporting purposes.
-
 
127
   * @attribute
-
 
128
   */
-
 
129
  protected String mReportingIsRipple;
-
 
130
 
-
 
131
  /**Package version identifier for reporting purposes.
-
 
132
   * @attribute
-
 
133
   */
-
 
134
  protected String mReportingPackageVersionId;
-
 
135
 
-
 
136
  /**Fully published flag for reporting purposes.
-
 
137
   * @attribute
-
 
138
   */
-
 
139
  protected String mReportingFullyPublished;
-
 
140
  
-
 
141
  /**New label for reporting purposes.
-
 
142
   * @attribute
-
 
143
   */
-
 
144
  protected String mReportingNewLabel;
-
 
145
 
-
 
146
  /**Source control interaction for reporting purposes.
-
 
147
   * @attribute
-
 
148
   */
104
  private static final Logger mLogger = Logger.getLogger(BuildThread.class);
149
  protected String mReportingDoesNotRequireSourceControlInteraction;
-
 
150
 
-
 
151
  /**Log file location for reporting purposes.
-
 
152
   * @attribute
-
 
153
   */
-
 
154
  protected String mReportingBuildFailureLogFile;
105
 
155
 
106
  /**constructor
156
  /**constructor
107
   */
157
   */
108
  BuildThread()
158
  BuildThread()
109
  {
159
  {
110
    super(mThreadGroup, "");
160
    super(mThreadGroup, "");
111
    mLogger.debug("BuildThread");
161
    mLogger.debug("BuildThread");
112
    mSleep = false;
162
    mSleep = false;
113
    mErrorReported = false;
163
    mErrorReported = false;
114
    mSetUpErrorReported = false;
-
 
115
    mReleaseManager = new ReleaseManager();
164
    mReleaseManager = new ReleaseManager();
116
    
165
    
117
    // no need to be synchronized - BuildThreads are instantiated in a single thread
166
    // no need to be synchronized - BuildThreads are instantiated in a single thread
118
    if ( mResumeTimerTask == null )
167
    if ( mResumeTimerTask == null )
119
    {
168
    {
Line 481... Line 530...
481
   */
530
   */
482
  protected void deliverChange(String buildFileContent, String target, boolean master)
531
  protected void deliverChange(String buildFileContent, String target, boolean master)
483
  {
532
  {
484
    mLogger.debug("deliverChange");
533
    mLogger.debug("deliverChange");
485
    
534
    
-
 
535
    // always perform a AbtSetUp, AbtPublish (master only), and AbtTearDown
486
    if ( ( target == null || target.compareTo( "AbtPublish" ) == 0 ) && ( mErrorReported ) )
536
    if ( target == null && mErrorReported )
487
    {
537
    {
-
 
538
      // AbtSetUp failed
488
      // previous error occurred processing the build file content
539
      // the default target will inevitably fail and will generate further email if allowed to proceed
-
 
540
      // do not mask the root cause
489
      return;
541
      return;
490
    }
542
    }
491
    
543
    
492
    File buildFile = new File(mRtagId + "build.xml");
544
    File buildFile = new File(mRtagId + "build.xml");
493
    boolean logError = true;
545
    boolean logError = true;
-
 
546
    Project p = new Project();
494
    
547
    
495
    try
548
    try
496
    {
549
    {
497
      // clear the file contents
550
      // clear the file contents
498
      if ( buildFileContent != null && target != null && target.compareTo("AbtSetUp") == 0 )
551
      if ( buildFileContent != null && target != null && target.compareTo("AbtSetUp") == 0 )
Line 543... Line 596...
543
        FileWriter buildFileWriter = new FileWriter(buildFile);
596
        FileWriter buildFileWriter = new FileWriter(buildFile);
544
        buildFileWriter.write(sanitisedBFC);
597
        buildFileWriter.write(sanitisedBFC);
545
        buildFileWriter.close();
598
        buildFileWriter.close();
546
      }
599
      }
547
      
600
      
-
 
601
      mReportingPackageName = null;
-
 
602
      mReportingPackageVersion = null;
-
 
603
      mReportingPackageExtension = null;
-
 
604
      mReportingPackageLocation = null;
-
 
605
      mReportingPackageDepends = null;
548
      Project p = new Project();
606
      mReportingIsRipple = null;
-
 
607
      mReportingPackageVersionId = null;
-
 
608
      mReportingDoesNotRequireSourceControlInteraction = null;
-
 
609
      mReportingFullyPublished = null;
-
 
610
      mReportingNewLabel = null;
-
 
611
 
-
 
612
      if ( buildFile.exists() )
-
 
613
      {
549
      p.setProperty("ant.file", buildFile.getAbsolutePath());
614
        p.setProperty("ant.file", buildFile.getAbsolutePath());
550
      DefaultLogger dl = new DefaultLogger();
615
        DefaultLogger dl = new DefaultLogger();
551
      PrintStream ps = new PrintStream(mRtagId + ".log");
616
        PrintStream ps = new PrintStream(mRtagId + ".log");
552
      dl.setOutputPrintStream(ps);
617
        dl.setOutputPrintStream(ps);
553
      dl.setMessageOutputLevel(Project.MSG_INFO);
618
        dl.setMessageOutputLevel(Project.MSG_INFO);
554
      p.addBuildListener(dl);
619
        p.addBuildListener(dl);
555
      p.init();
620
        p.init();
556
      ProjectHelper pH = ProjectHelper.getProjectHelper();
621
        ProjectHelper pH = ProjectHelper.getProjectHelper();
557
      p.addReference("ant.projectHelper", pH);
622
        p.addReference("ant.projectHelper", pH);
558
      
623
        
559
      // parse can throw BuildException, this is serious
624
        // parse can throw BuildException, this is serious
560
      pH.parse(p, buildFile);
625
        pH.parse(p, buildFile);
561
      mLogger.warn("deliverChange ant launched on " + buildFile.getAbsolutePath());
626
        mLogger.warn("deliverChange ant launched on " + buildFile.getAbsolutePath());
562
      
627
        
563
      if ( target == null )
628
        if ( target == null )
564
      {
629
        {
565
        target = p.getDefaultTarget();
630
          target = p.getDefaultTarget();
-
 
631
        }
-
 
632
        mLogger.warn("deliverChange ant launched against target " + target);
-
 
633
        
-
 
634
        // executeTarget can throw BuildException, this is not serious
-
 
635
        logError = false;
-
 
636
        // set up project properties for reporting purposes
-
 
637
        // this first group are hard coded in the build file
-
 
638
        mReportingPackageName = p.getProperty("abt_package_name");
-
 
639
        mReportingPackageVersion = p.getProperty("abt_package_version");
-
 
640
        mReportingPackageExtension = p.getProperty("abt_package_extension");
-
 
641
        mReportingPackageLocation = p.getProperty("basedir") + p.getProperty("abt_package_location");
-
 
642
        mReportingPackageDepends = p.getProperty("abt_package_depends");
-
 
643
        mReportingIsRipple = p.getProperty("abt_is_ripple");
-
 
644
        mReportingPackageVersionId = p.getProperty("abt_package_version_id");
-
 
645
        mReportingDoesNotRequireSourceControlInteraction = p.getProperty("abt_does_not_require_source_control_interaction");
-
 
646
        
-
 
647
        p.executeTarget(target);
-
 
648
        mLogger.warn("deliverChange ant returned");
-
 
649
        
566
      }
650
      }
567
      mLogger.warn("deliverChange ant launched against target " + target);
-
 
568
      
-
 
569
      // executeTarget can throw BuildException, this is not serious
-
 
570
      logError = false;
-
 
571
      p.executeTarget(target);
-
 
572
      mLogger.warn("deliverChange ant returned");
-
 
573
    }
651
    }
574
    catch( BuildException e )
652
    catch( BuildException e )
575
    {
653
    {
576
      if ( logError )
654
      if ( logError )
577
      {
655
      {
578
        mLogger.error("deliverChange caught BuildException, the build failed " + e.getMessage());
656
        mLogger.error("deliverChange caught BuildException, the build failed " + e.getMessage());
579
      }
657
      }
580
      else
658
      else
581
      {
659
      {
-
 
660
        if ( mReportingBuildFailureLogFile == null )
-
 
661
        {
-
 
662
          mReportingBuildFailureLogFile = e.getMessage();
-
 
663
        }
582
        mLogger.debug("deliverChange caught BuildException, big deal, the build failed " + e.getMessage());
664
        mLogger.debug("deliverChange caught BuildException, big deal, the build failed " + mReportingBuildFailureLogFile);
583
      }
665
      }
584
      
666
      
585
      if ( target.compareTo( "AbtSetUp ") == 0 )
-
 
586
      {
-
 
587
        mSetUpErrorReported = true;
-
 
588
      }
-
 
589
 
-
 
590
      mErrorReported = true;
667
      mErrorReported = true;
591
    }
668
    }
592
    catch( FileNotFoundException e )
669
    catch( FileNotFoundException e )
593
    {
670
    {
594
      mLogger.error("deliverChange caught FileNotFoundException");
671
      mLogger.error("deliverChange caught FileNotFoundException");
Line 596... Line 673...
596
    catch( IOException e )
673
    catch( IOException e )
597
    {
674
    {
598
      mLogger.error("deliverChange caught IOException");
675
      mLogger.error("deliverChange caught IOException");
599
    }
676
    }
600
    
677
    
-
 
678
    // this group are set at run time (by the AbtPublish target only)
-
 
679
    // they will be null for every other target,
-
 
680
    // and null if an error occurs in the AbtPublish target
-
 
681
    mReportingFullyPublished = p.getProperty("abt_fully_published");
-
 
682
    mReportingNewLabel = p.getProperty("abt_new_label");
-
 
683
    
601
  }
684
  }
602
  
685
  
603
  /**sets up a ClearCase static view
686
  /**sets up a ClearCase static view
604
   */
687
   */
605
  protected void setViewUp(String content, boolean master)
688
  protected void setViewUp(String content, boolean master)
606
  {
689
  {
607
    mLogger.debug("setViewUp");
690
    mLogger.debug("setViewUp");
-
 
691
    mReportingBuildFailureLogFile = null;
608
    mErrorReported = false;
692
    mErrorReported = false;
609
    mSetUpErrorReported = false;
-
 
610
    // run ant on the AbtSetUp target
693
    // run ant on the AbtSetUp target
611
    deliverChange(content, "AbtSetUp", master);
694
    deliverChange(content, "AbtSetUp", master);
612
  }
695
  }
613
  
696
  
614
  /**tears down a ClearCase static view
-
 
615
  */
-
 
616
  protected void tearViewDown()
-
 
617
  {
-
 
618
    mLogger.debug("tearViewDown");
-
 
619
    
-
 
620
    if ( !mSetUpErrorReported )
-
 
621
    {
-
 
622
      // no error setting the view up, so...
-
 
623
      // run ant on the AbtTearDown target
-
 
624
      deliverChange(null, "AbtTearDown", false);
-
 
625
    }
-
 
626
  }
-
 
627
  
-
 
628
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
697
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
629
   */
698
   */
630
  protected boolean published(String archive, String packageName, 
699
  protected boolean published(String archive, String packageName, 
631
                            String packageVersion, String machtype,
700
                            String packageVersion, String machtype,
632
                            String generic)
701
                            String generic)