Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.ripple;
2
 
3
import java.io.File;
4
 
5
import java.sql.SQLException;
6
 
7
import java.util.Iterator;
866 mhunt 8
import java.util.ListIterator;
814 mhunt 9
import java.util.Vector;
10
 
11
import org.apache.log4j.Logger;
12
 
830 mhunt 13
import java.util.regex.PatternSyntaxException;
14
 
814 mhunt 15
/**Plans release impact by generating a set of Strings containing build file content.
16
 */
17
public class RippleEngine
18
{
19
  /**collection of gbemachtypes in String form associated with the baseline
20
   * limited to the following items "win32", "sparc", "solaris10_sparc32", "solaris10_x86", "linux_i386"
21
   * accessed by Package::isLinuxBuilt, isSolarisBuilt, isWin32Built
22
   * @attribute
23
   */
864 mhunt 24
  Vector<String> mGbeMachtypeCollection = new Vector<String>();
866 mhunt 25
 
814 mhunt 26
  /**configured mail server
27
   * @attribute
28
   */
868 mhunt 29
  public String mMailServer = new String();
814 mhunt 30
 
31
  /**configured mail sender user
32
   * @attribute
33
   */
868 mhunt 34
  public String mMailSender = new String();
814 mhunt 35
 
868 mhunt 36
  /**configured global email target
37
   * @attribute
38
   */
39
  public String mGlobalTarget = new String();
40
 
814 mhunt 41
  /**name associated with the baseline
42
   * @attribute
43
   */
868 mhunt 44
  public String mBaselineName = new String();
814 mhunt 45
 
46
  /**collection of released pv_ids associated with the release
47
   * @attribute
48
   */
864 mhunt 49
  Vector<Integer> mReleasedPvIDCollection = new Vector<Integer>();
814 mhunt 50
 
51
  /**timestamp associated with build file generation
52
   * @attribute
53
   */
54
  long mTimestamp = 0;
55
 
56
  /**set to "non generic", "generic" or "dummy" to indicate the nature of the package in the build file in daemon mode
57
   * @attribute
58
   */
59
  String mAddendum = new String("dummy");
60
 
866 mhunt 61
  /**collection of build exceptions associated with the baseline
62
  /* used to determine (and report) what change in build exceptions happens as part of planRelease
63
   * deamon centric
64
   * @aggregation shared
65
   * @attribute
66
   */
67
  Vector<BuildExclusion> mBuildExclusionCollection = new Vector<BuildExclusion>();
68
 
814 mhunt 69
  /**Logger
70
   * @attribute
71
   */
72
  private static final Logger mLogger = Logger.getLogger(RippleEngine.class);
73
 
830 mhunt 74
  /**collection of escrow clearcase support file content in String form, set_up
814 mhunt 75
   * @attribute
76
   */
864 mhunt 77
  private Vector<String> mEscrowClearcaseSupportCollection = new Vector<String>();
814 mhunt 78
 
79
  /**package versions representing the baseline
866 mhunt 80
   * escrow centric
814 mhunt 81
   * @aggregation shared
82
   * @attribute
83
   */
864 mhunt 84
  private Vector<Package> mPackageCollection = new Vector<Package>();
814 mhunt 85
 
86
  /**index to current String item
87
   * @attribute
88
   */
89
  private int mBuildIndex;
90
 
91
  /**Database abstraction
92
   * @attribute
93
   */
94
  private ReleaseManager mReleaseManager;
95
 
96
  /**Baseline identifier (rtag_id for a release manager baseline, bom_id for deployment manager baseline)
97
   * @attribute
98
   */
99
  private int mBaseline;
100
 
101
  /**When true, mBuildCollection contains one item based on a release manager rtag_id and contains a daemon property
102
   * When false, mBuildCollection contains at least one item based on a deployment manager bom_id
103
   * Will be accessed by the Package class to calculate its mAlias
104
   * @attribute
105
   */
106
  boolean mDaemon;
107
 
108
  /**collection of build file content in String form
109
   * @attribute
110
   */
864 mhunt 111
  private Vector<String> mBuildCollection = new Vector<String>();
814 mhunt 112
 
906 mhunt 113
  /**Warning message
114
   * @attribute
115
   */
116
  private static final String mAnyBuildPlatforms = new String("Warning. The following package versions are not reproducible on any build platform: ");
117
 
118
  /**Flag to control output to standard out
119
   * @attribute
120
   */
121
  private boolean mAnyBuildPlatformsFlag = true;
122
 
123
  /**Warning message
124
   * @attribute
125
   */
126
  private static final String mAssocBuildPlatforms = new String("Warning. The following package versions are not reproducible on the build platforms associated with this baseline: ");
127
 
128
  /**Flag to control output to standard out
129
   * @attribute
130
   */
131
  private boolean mAssocBuildPlatformsFlag = true;
132
 
133
  /**Warning message
134
   * @attribute
135
   */
136
  private static final String mNotInBaseline = new String("Warning. The following package versions are not reproducible as they are directly dependent upon package versions not in the baseline: ");
137
 
138
  /**Flag to control output to standard out
139
   * @attribute
140
   */
141
  private boolean mNotInBaselineFlag = true;
142
 
143
  /**Warning message
144
   * @attribute
145
   */
146
  private static final String mDependent = new String("Warning. The following package versions are not reproducible as they are directly/indirectly dependent upon not reproducible package versions: ");
147
 
148
  /**Flag to control output to standard out
149
   * @attribute
150
   */
151
  private boolean mDependentFlag = true;
152
 
814 mhunt 153
  /**constructor
154
   */
155
  public RippleEngine(ReleaseManager releaseManager, int rtag_id, 
156
                      boolean isDaemon)
157
  {
158
    mLogger.debug("RippleEngine rtag_id " + rtag_id + " isDaemon " + isDaemon);
159
    mReleaseManager = releaseManager;
160
    mBaseline = rtag_id;
161
    mDaemon = isDaemon;
162
  }
163
 
164
  /**discards all build file content
165
   * plans new build file content
166
   */
167
  public void planRelease() throws SQLException, Exception
168
  {
169
    mLogger.warn("planRelease mDaemon " + mDaemon);
170
    mAddendum = "dummy";
171
    mBuildCollection.removeAllElements();
172
    mPackageCollection.removeAllElements();
173
    mReleasedPvIDCollection.removeAllElements();
174
 
175
    if ( !mDaemon )
176
    {
177
      mEscrowClearcaseSupportCollection.removeAllElements();  
178
    }
179
 
898 mhunt 180
    // use finally block in planRelease to ensure releaseMutex is called
181
    try
182
    {
183
      mReleaseManager.connect();
814 mhunt 184
 
898 mhunt 185
      if ( mDaemon )
866 mhunt 186
      {
898 mhunt 187
        // claim the mutex
188
        mReleaseManager.claimMutex();
189
        mBuildExclusionCollection.removeAllElements();
190
        Vector<BuildExclusion> tempBuildExclusionCollection = new Vector<BuildExclusion>();
866 mhunt 191
 
898 mhunt 192
        mReleaseManager.queryBuildExclusions(tempBuildExclusionCollection, mBaseline);
193
 
194
        // only populate mBuildExclusionCollection with tempBuildExclusionCollection entries which have a relevant root_pv_id
195
        // ie the root_pv_id is ONLY relevant if it is null (-1) or it points to a pv_id in the collection
196
        // the package with a pv_id which is a root_pv_id may be removed ie when fixing a build issue
197
        for (Iterator<BuildExclusion> it = tempBuildExclusionCollection.iterator(); it.hasNext(); )
866 mhunt 198
        {
898 mhunt 199
          BuildExclusion buildExclusion = it.next();
200
 
201
          if ( buildExclusion.isRelevant(tempBuildExclusionCollection) )
202
          {
203
            mBuildExclusionCollection.add(buildExclusion);
204
          }
205
          else
206
          {
207
            // this is just a cosmetic step
208
            // it includes package versions which have been indirectly excluded
209
            // the build daemon ignores this information, but it serves to clarify this point to users
210
            buildExclusion.includeToBuild(mReleaseManager, mBaseline);
211
          }
866 mhunt 212
        }
213
      }
898 mhunt 214
 
215
      mReleaseManager.queryPackageVersions(this, mPackageCollection, mDaemon, mBaseline);
216
 
908 mhunt 217
      // must deal with test builds here as they may impact upon package attributes
218
      // eg dependency collection and build standard differences
219
      // this gives test builds preferential treatment
220
      if ( mDaemon )
221
      {
222
        // process test builds
223
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
224
        {
225
          Package p = it.next();
226
 
227
          if (p.mBuildFile == 0)
228
          {
229
            // package has yet to be processed
230
            if (  p.mTestBuildInstruction > 0 )
231
            {
232
              mLogger.info("planRelease package test build " + p.mName);
233
 
234
              // force patch for test build numbering
235
              p.mDirectlyPlanned = true;
236
              p.mChangeType.setPatch();
237
              p.mRequiresSourceControlInteraction = false;
238
              rippleIndirectlyPlanned(p);
239
 
240
              // put the mTestBuildAttributes to work
241
              p.mLabel = p.mTestBuildLabel;
242
              p.mLocation = p.mTestBuildLocation;
243
              p.setEmail();
244
              p.setDependencyCollection();
245
              p.setBuildStandardCollection();
246
            }
247
          }
248
        }
249
      }
250
 
898 mhunt 251
      // set up mPackageDependencyCollection
252
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 253
      {
898 mhunt 254
        Package p = it.next();
255
 
256
        for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
814 mhunt 257
        {
898 mhunt 258
          String alias = it2.next();
259
          Package dependency = findPackage(alias);
260
 
902 mhunt 261
          p.mPackageDependencyCollection.add(dependency);
262
        }
263
      }
264
 
265
      // DEVI 55483 now use the fully built mPackageDependencyCollection (in rippleBuildExclude)
266
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
267
      {
268
        Package p = it.next();
269
 
270
        for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
271
        {
272
          String alias = it2.next();
273
          Package dependency = findPackage(alias);
274
 
898 mhunt 275
          if (dependency == ReleaseManager.NULL_PACKAGE)
276
          {
277
            mLogger.info("planRelease dependency is not in the baseline " + alias);
278
            // exclude all dependent packages
279
            // max 50 chars
900 mhunt 280
            rippleBuildExclude(p, p.mId, "Package build dependency not in the release", null, null);
898 mhunt 281
 
282
            // take the package out of the build
283
            p.mBuildFile = -4;
284
            mLogger.info("planRelease set mBuildFile to -4 for package " + p.mAlias );
906 mhunt 285
            standardOut(mNotInBaseline, p.mAlias, mNotInBaselineFlag);
898 mhunt 286
            break;
287
          }
814 mhunt 288
        }
289
      }
902 mhunt 290
 
898 mhunt 291
      // process packages which are not reproducible, and all packages dependent upon them      
292
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 293
      {
898 mhunt 294
        Package p = it.next();
295
 
296
        if (p.mBuildFile == 0)
814 mhunt 297
        {
898 mhunt 298
          // package has yet to be processed
299
          if (!p.isReproducible())
300
          {
301
            // for escrow build purposes, exclude all dependent package versions
302
            mLogger.info("planRelease package not reproducible " + p.mName);
303
            // max 50 chars
900 mhunt 304
            rippleBuildExclude(p, p.mId, "Package has no build environment", null, null);
898 mhunt 305
 
306
            // package is not reproducible, discard
307
            p.mBuildFile = -1;
308
            mLogger.info("planRelease set mBuildFile to -1 for package " + p.mAlias );
906 mhunt 309
            standardOut(mAnyBuildPlatforms, p.mAlias, mAnyBuildPlatformsFlag);
898 mhunt 310
          }
814 mhunt 311
        }
312
      }
898 mhunt 313
 
314
      // process packages which are not reproducible on the build platforms configured for this baseline
315
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 316
      {
898 mhunt 317
        Package p = it.next();
858 mhunt 318
 
898 mhunt 319
        if (p.mBuildFile == 0)
814 mhunt 320
        {
898 mhunt 321
          // package has yet to be processed
322
          // assume it does not need to be reproduced for this baseline
323
          boolean reproduce = false;
324
 
325
          for (Iterator<String> it2 = mGbeMachtypeCollection.iterator(); it2.hasNext(); )
814 mhunt 326
          {
898 mhunt 327
            String machtype = it2.next();
328
 
329
            if ( machtype.compareTo("linux_i386") == 0 )
814 mhunt 330
            {
898 mhunt 331
              if ( p.isLinuxBuilt() )
332
              {
333
                reproduce = true;
334
                mLogger.info("planRelease package built on linux " + p.mAlias );
335
                break;
336
              }
814 mhunt 337
            }
898 mhunt 338
            else if ( machtype.compareTo("win32") == 0 )
814 mhunt 339
            {
898 mhunt 340
              if ( p.isWin32Built() )
341
              {
342
                reproduce = true;
343
                mLogger.info("planRelease package built on win32 " + p.mAlias );
344
                break;
345
              }
814 mhunt 346
            }
898 mhunt 347
            else if ( machtype.compareTo("sparc") == 0
348
                   || machtype.compareTo("solaris10_x86") == 0
349
                   || machtype.compareTo("solaris10_sparc32") == 0 )
814 mhunt 350
            {
898 mhunt 351
              if ( p.isSolarisBuilt() )
352
              {
353
                reproduce = true;
354
                mLogger.info("planRelease package built on solaris " + p.mAlias );
355
                break;
356
              }
814 mhunt 357
            }
358
          }
898 mhunt 359
 
360
          if ( !reproduce )
361
          {
362
            mLogger.info("planRelease package not reproducible on the build platforms configured for this baseline " + p.mName);
363
 
906 mhunt 364
            if (mDaemon)
365
            {
366
              // DEVI 54816
367
              // for escrow build purposes, do not exclude all dependent package versions
368
              // max 50 chars
369
              rippleBuildExclude(p, p.mId, "Package not built for configured platforms", null, null);
370
            }
371
 
898 mhunt 372
            // package is not reproducible on the build platforms configured for this baseline, discard
373
            p.mBuildFile = -2;
374
            mLogger.info("planRelease set mBuildFile to -2 for package " + p.mAlias );
906 mhunt 375
            standardOut(mAssocBuildPlatforms, p.mAlias, mAssocBuildPlatformsFlag);
898 mhunt 376
          }
858 mhunt 377
        }
898 mhunt 378
      }      
379
 
380
      if (mDaemon)
814 mhunt 381
      {
898 mhunt 382
        // process packages which are not ripple buildable, and all packages dependent upon them
383
        for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
814 mhunt 384
        {
898 mhunt 385
          BuildExclusion be = it.next();
866 mhunt 386
 
898 mhunt 387
          for (Iterator<Package> it1 = mPackageCollection.iterator(); it1.hasNext(); )
814 mhunt 388
          {
898 mhunt 389
            Package p = it1.next();
390
 
908 mhunt 391
            // ensure only root cause, non test build, build exclusions are excluded
900 mhunt 392
            // mBuildExclusionCollection is at this point based on
393
            // relevant (direct and indirect) excluded pv's in the database
908 mhunt 394
            if ( be.compare(p.mId) && be.isARootCause() && p.mTestBuildInstruction == 0 )
866 mhunt 395
            {
900 mhunt 396
              // package is not reproducible, discard
397
              rippleBuildExclude( p, p.mId, null, it, be );
398
              p.mBuildFile = -3;
399
              mLogger.info("planRelease set mBuildFile to -3 for package " + p.mAlias );
898 mhunt 400
              break;
866 mhunt 401
            }
814 mhunt 402
          }
403
        }
898 mhunt 404
 
405
        // process packages which need to be ripple built
406
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 407
        {
898 mhunt 408
          Package p = it.next();
409
 
410
          if (p.mBuildFile == 0)
814 mhunt 411
          {
898 mhunt 412
            // package has yet to be processed
413
            if (p.mDirectlyPlanned)
814 mhunt 414
            {
898 mhunt 415
              // a WIP exists on the package
416
              // exclude all dependent package versions
417
              mLogger.info("planRelease package has WIP " + p.mName);
418
              rippleIndirectlyPlanned(p);
419
            }
420
            else
421
            {
422
              Iterator<Integer> it2 = p.mDependencyIDCollection.iterator();
423
              Iterator<Package> it3 = p.mPackageDependencyCollection.iterator();
424
              for ( ; it2.hasNext() && it3.hasNext(); )
814 mhunt 425
              {
898 mhunt 426
                Integer dpv_id = it2.next();
427
                Package dependency = it3.next();
428
 
429
                if ( !dependency.mAdvisoryRipple )
814 mhunt 430
                {
898 mhunt 431
                  // not advisory, ie has ripple build impact
432
                  boolean found = false;
433
 
434
                  for ( Iterator<Integer> it4 = mReleasedPvIDCollection.iterator(); it4.hasNext(); )
814 mhunt 435
                  {
898 mhunt 436
                    Integer pv_id = it4.next();
437
 
438
                    if ( pv_id.compareTo(dpv_id) == 0 )
439
                    {
440
                      found = true;
441
                      break;
442
                    }
443
                  }
444
 
445
                  if ( !found )
446
                  {
447
                    // the package is out of date
448
                    // exclude all dependent package versions
449
                    mLogger.info("planRelease package out of date " + p.mName);
450
                    rippleIndirectlyPlanned(p);                 
814 mhunt 451
                    break;
452
                  }
453
                }
454
              }
455
            }
456
          }
457
        }
898 mhunt 458
 
459
        // process packages which do not exist in the archive
460
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 461
        {
898 mhunt 462
          Package p = it.next();
463
 
464
          if (p.mBuildFile == 0)
814 mhunt 465
          {
898 mhunt 466
            // package has yet to be processed
467
            // for unit test purposes, assume all packages exist in the archive if released
468
            if ( ReleaseManager.mUseDatabase )
814 mhunt 469
            {
898 mhunt 470
              // only check existence outside the unit test
471
              if (!p.mDirectlyPlanned && !p.mIndirectlyPlanned)
814 mhunt 472
              {
898 mhunt 473
                // check package version archive existence
474
                if (!p.exists())
475
                {
476
                  mLogger.info("planRelease package not found in archive " + p.mName);
477
                  // DEVI 47395 the cause of this build is not WIP or ripple induced,
478
                  // it simply does not exist in the archive (has been removed)
479
                  // prevent source control interaction
480
                  p.mRequiresSourceControlInteraction = false;
481
                  rippleIndirectlyPlanned(p);
482
                }
814 mhunt 483
              }
484
            }
485
          }
486
        }
908 mhunt 487
 
488
        // process forced ripples
489
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
490
        {
491
          Package p = it.next();
492
 
493
          if (p.mBuildFile == 0)
494
          {
495
            // package has yet to be processed
496
            if ( p.mForcedRippleInstruction > 0 )
497
            {
498
              mLogger.info("planRelease package forced ripple " + p.mName);
499
              rippleIndirectlyPlanned(p);
500
            }
501
          }
502
        }
814 mhunt 503
      }
906 mhunt 504
      else
505
      {
506
        // escrow reporting only     
507
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
508
        {
509
          Package p = it.next();
510
 
511
          if (p.mBuildFile == -3)
512
          {
513
            standardOut(mDependent, p.mAlias, mDependentFlag);
514
          }
515
        }
516
      }
826 mhunt 517
 
898 mhunt 518
      // process remaining packages which need to be reproduced for this baseline
519
      // determine the build file for each package
520
      // for daemon builds, determine the first package that can be built now, this means the first package not dependent upon packages also to be built
521
      // set its mBuildNumber to 1, all remaining reproducible packages to 2
522
      // for escrow builds, determine the package versions that can be built in the build iteration
523
      // set their mBuildNumber to the build iteration
524
      // increment the build iteration and repeat until all package versions that need to be reproduced have been assigned a build iteration
525
      boolean allProcessed = false;
526
      int buildFile = 1;
527
 
528
      // delete the file <rtagId>official
529
      Integer rtag = new Integer(mBaseline);
530
      File rtagIdOfficial = new File(rtag + "official");
531
 
532
      if (rtagIdOfficial.exists())
826 mhunt 533
      {
898 mhunt 534
        boolean del = rtagIdOfficial.delete();
535
 
826 mhunt 536
        if ( !del )
537
        {
898 mhunt 538
          // the delete failed
539
          // some literature suggests a forced garbage collection may free up resources associated with file handles
540
          // nothing to lose since the file "must" be deleted
541
          System.gc();
542
          del = rtagIdOfficial.delete();
543
 
544
          if ( !del )
545
          {
546
            mLogger.fatal("rtagIdOfficial.delete() returned " + del);
547
          }
826 mhunt 548
        }
549
      }
814 mhunt 550
 
898 mhunt 551
      String raw_data = new String("");
552
      String lf = new String( System.getProperty("line.separator") );
553
 
814 mhunt 554
      do
555
      {
898 mhunt 556
        boolean allDependenciesProcessed = true;
814 mhunt 557
 
898 mhunt 558
        do
814 mhunt 559
        {
898 mhunt 560
          // assume all dependencies have been processed
561
          allDependenciesProcessed = true;
814 mhunt 562
 
898 mhunt 563
          for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 564
          {
898 mhunt 565
            Package p = it.next();
566
 
906 mhunt 567
            if ( ( mDaemon && ( ( !p.mDirectlyPlanned && !p.mIndirectlyPlanned ) || p.mBuildFile < 0 ) ) ||
568
                 ( !mDaemon && p.mBuildFile == -2 ) )
814 mhunt 569
            {
898 mhunt 570
              // flag packages with no build requirement as processed in daemon mode
906 mhunt 571
              // DEVI 54816 flag packages with a foreign build environment as processed in escrow mode
898 mhunt 572
              p.mProcessed = true;
573
              mLogger.info("planRelease package has no build requirement " + p.mName);            
574
            }
906 mhunt 575
            else if ( ( p.mBuildFile == 0 ) && ( (mDaemon && ( p.mDirectlyPlanned || p.mIndirectlyPlanned ) ) || ( !mDaemon ) ) )
898 mhunt 576
            {
906 mhunt 577
              // package yet to be processed and
578
              // in daemon mode has a build requirement or
579
              // in escrow mode
580
              boolean canBeBuiltNow = true;
581
              boolean allDependenciesForThisPackageProcessed = true;
582
 
583
              for ( Iterator<Package> it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
814 mhunt 584
              {
906 mhunt 585
                Package dependency = it2.next();
814 mhunt 586
 
906 mhunt 587
                if ( !dependency.mProcessed )
814 mhunt 588
                {
906 mhunt 589
                  // cannot determine canBeBuiltNow until this dependency has been processed
590
                  allDependenciesForThisPackageProcessed = false;
591
                  allDependenciesProcessed = false;
592
                }
593
                else if ( ( mDaemon && ( dependency.mDirectlyPlanned ) || ( dependency.mIndirectlyPlanned ) ) || 
594
                          ( !mDaemon &&
595
                            ( ( dependency.mBuildFile == 0 ) ||
596
                              ( dependency.mBuildFile == buildFile &&
597
                                ( ( p.isLinuxBuilt() && !dependency.isLinuxBuilt() ) ||
598
                                  ( p.isWin32Built() && !dependency.isWin32Built() ) ||
599
                                  ( p.isSolarisBuilt() && !dependency.isSolarisBuilt() ) ||
600
                                  ( !p.isLinuxBuilt() && dependency.isLinuxBuilt() ) ||
601
                                  ( !p.isWin32Built() && dependency.isWin32Built() ) ||
602
                                  ( !p.isSolarisBuilt() && dependency.isSolarisBuilt() ) ) ) ) ) )
603
                {
604
                  // in daemon mode this processed dependency has a build requirement or
605
                  // in escrow mode...
606
                  // this processed dependency has not been assigned to a build iteration or
607
                  // this processed dependency has been assigned to this build iteration and does not build on this platform
608
                  canBeBuiltNow = false;
609
                  mLogger.info("planRelease package cannot be built in this iteration " + p.mName);
610
                  break;
611
                }
612
              }
613
 
614
              if (allDependenciesForThisPackageProcessed)
615
              {
616
                p.mProcessed = true;
617
 
618
                if ( mDaemon )
619
                {
620
                  if ( canBeBuiltNow )
814 mhunt 621
                  {
906 mhunt 622
                    // flag package with build requirement, may get downgraded to future build requirement
623
                    p.mBuildFile = 1;
624
                    mLogger.info("planRelease set mBuildFile to 1 for package " + p.mAlias );
814 mhunt 625
                  }
906 mhunt 626
                  else
814 mhunt 627
                  {
906 mhunt 628
                    // flag package with future build requirement
629
                    p.mBuildFile = 2;
630
                    mLogger.info("planRelease set mBuildFile to 2 for package " + p.mAlias );
814 mhunt 631
                  }
632
                }
906 mhunt 633
                else
814 mhunt 634
                {
906 mhunt 635
                  if ( canBeBuiltNow )
814 mhunt 636
                  {
906 mhunt 637
                    String isWin32Built = new String("");
638
 
639
                    if ( p.isWin32Built() )
848 dpurdie 640
                    {
906 mhunt 641
                      isWin32Built = "W";
898 mhunt 642
                    }
906 mhunt 643
 
644
                    String isLinuxBuilt = new String("");
645
 
646
                    if ( p.isLinuxBuilt() )
898 mhunt 647
                    {
906 mhunt 648
                      isLinuxBuilt = "L";
898 mhunt 649
                    }
906 mhunt 650
 
651
                    String isSolarisBuilt = new String("");
652
 
653
                    if ( p.isSolarisBuilt() )
898 mhunt 654
                    {
906 mhunt 655
                      isSolarisBuilt = "S";
848 dpurdie 656
                    }
906 mhunt 657
 
658
                    String isGeneric = new String("");
659
 
660
                    if ( p.isGeneric() )
661
                    {
662
                      isGeneric = "G";
663
                    }
664
 
665
                    raw_data += p.mAlias + "," +
666
                                isWin32Built + "," +
667
                                isLinuxBuilt + "," +
668
                                isSolarisBuilt + "," +
669
                                isGeneric + "," +
670
                                buildFile +
671
                                lf;
672
 
673
                    // not daemon
674
                    p.mBuildFile = buildFile;
675
                    mLogger.info("planRelease set mBuildFile to " + buildFile + " for package " + p.mAlias );
814 mhunt 676
                  }
677
                }
678
              }
679
            }
680
          }
898 mhunt 681
        } while( !allDependenciesProcessed );
682
 
683
        if ( mDaemon )
814 mhunt 684
        {
898 mhunt 685
          for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 686
          {
898 mhunt 687
            Package p = it.next();
688
 
689
            if ( p.mProcessed && p.mBuildFile == 1 )
814 mhunt 690
            {
898 mhunt 691
              p.mBuildFile = buildFile;
692
              mLogger.info("planRelease 2 set mBuildFile to " + buildFile + " for package " + p.mAlias );
693
 
694
              if ( buildFile == 1 )
874 mhunt 695
              {
898 mhunt 696
                int pvApplied = p.applyPV(mReleaseManager, mBaseline);
697
 
698
                if ( pvApplied == 1 )
699
                {
700
                  // max 50 chars
900 mhunt 701
                  rippleBuildExclude(p, p.mId, "Package has non standard versioning", null, null);
898 mhunt 702
                }
703
                else
704
                if ( pvApplied == 2 )
705
                {
706
                  // max 50 chars
900 mhunt 707
                  rippleBuildExclude(p, p.mId, "Package has reached ripple field limitations", null, null);
898 mhunt 708
                }
709
                else
710
                {
711
                  buildFile = 2;
908 mhunt 712
 
713
                  if ( p.mForcedRippleInstruction > 0 )
714
                  {
715
                    mReleaseManager.markDaemonInstCompleted( p.mForcedRippleInstruction );
716
                  }
717
 
718
                  if ( p.mTestBuildInstruction > 0 )
719
                  {
720
                    mReleaseManager.markDaemonInstInProgress( p.mTestBuildInstruction );
721
                  }
898 mhunt 722
                }
874 mhunt 723
              }
724
              else
725
              {
898 mhunt 726
                mLogger.info("planRelease package has future (downgraded) build requirement " + p.mName + " " + buildFile);              
874 mhunt 727
              }
814 mhunt 728
            }
898 mhunt 729
          }
730
        }
731
 
732
        // are more build files required
733
        allProcessed = true;
734
 
735
        if (mDaemon)
736
        {
737
          for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
738
          {
739
            Package p = it.next();
740
 
741
            if ( p.mBuildFile < 0 || ( !p.mDirectlyPlanned && !p.mIndirectlyPlanned ) )
814 mhunt 742
            {
898 mhunt 743
              // at this point...
744
              // only 1 package with a build requirement has a mBuildFile of 1,
745
              // all other packages with a build requirement have an mBuildFile of 2
746
              // give packages with no build requirement, reproducible or not, an mBuildFile of 3
747
              p.mBuildFile = 3;
748
              mLogger.info("planRelease 1 set mBuildFile to 3 for package " + p.mAlias );
814 mhunt 749
            }
750
          }
751
        }
898 mhunt 752
        else
753
        {
754
          // this is escrow mode centric
755
          for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
756
          {
757
            Package p = it.next();
758
 
759
            if ( p.mBuildFile == 0 )
760
            {
761
              // more build files are required
762
              allProcessed = false;
763
              mLogger.info("planRelease more build files are required for " + p.mName);
764
              break;
765
            }
766
          }
767
 
768
          buildFile++;
769
        }
770
      } while( !allProcessed );
814 mhunt 771
 
898 mhunt 772
      // persist the build files
773
      allProcessed = false;
774
      buildFile = 1;
814 mhunt 775
 
898 mhunt 776
      if ( mDaemon )
814 mhunt 777
      {
898 mhunt 778
        // all interesting packages in daemon mode match the following filter
779
        buildFile = 3;
780
      }
781
 
782
      mTimestamp = System.currentTimeMillis();
783
 
784
      if ( !ReleaseManager.mUseDatabase )
785
      {
786
        mTimestamp = 123456789;
787
      }
788
 
789
      do
790
      {
791
        String buildFileContent = new String( generateBuildFileHeader() );
792
 
864 mhunt 793
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 794
        {
864 mhunt 795
          Package p = it.next();
906 mhunt 796
 
797
          // DEVI 54816
798
          // now set a packages mBuildFile to -2 in escrow mode, but do not ripple this through
799
          // its consumers need dependency package property info
800
          if ( ( ( p.mBuildFile > 0 ) && ( p.mBuildFile <= buildFile ) ) || ( !mDaemon && p.mBuildFile == -2 ) )
814 mhunt 801
          {
898 mhunt 802
            buildFileContent += generatePackageProperty(p);
814 mhunt 803
          }
804
        }
898 mhunt 805
 
806
        buildFileContent += generateTaskdef();
807
 
808
        String set_up = new String("");
809
        boolean daemonHasTarget = false;
810
 
864 mhunt 811
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 812
        {
864 mhunt 813
          Package p = it.next();
898 mhunt 814
 
815
          if ( p.mBuildFile > 0 && p.mBuildFile <= buildFile )
814 mhunt 816
          {
898 mhunt 817
            buildFileContent += generateTarget(p, buildFile);
818
 
819
            if ( p.mBuildFile == 1 )
820
            {
821
              daemonHasTarget = true;
822
            }
814 mhunt 823
          }
866 mhunt 824
 
898 mhunt 825
          if ( !mDaemon && buildFile == 1 )
866 mhunt 826
          {
898 mhunt 827
            // for the purposes of the set up, use /
828
            String loc = new String("");
829
            try
830
            {
831
              // The regular expression "\\\\" matches an escape character "\\" and a single backslash "\\"
832
              loc = p.mLocation.replaceAll("\\\\", "/");
833
            }
834
            catch( PatternSyntaxException e )
835
            {
836
            }
837
 
838
            set_up += "jats release -extractfiles"
839
                      + " \"-label=" + p.mLabel + "\""
840
                      + " \"-path=" + loc + "\""
841
                      + " \"-view=" + p.mAlias + "\""
842
                      + " -root=. -noprefix"
843
                      + lf;
866 mhunt 844
          }
814 mhunt 845
        }
898 mhunt 846
 
847
        if ( mDaemon && !daemonHasTarget )
848
        {
849
          // must have AbtSetUp, AbtTearDown, and AbtPublish targets
850
          buildFileContent += "<target name=\"AbtSetUp\"/>" + lf +
851
                              "<target name=\"AbtTearDown\"/>" + lf +
852
                              "<target name=\"AbtPublish\"/>" + lf;
853
        }
814 mhunt 854
 
855
        if ( !mDaemon && buildFile == 1 )
856
        {
898 mhunt 857
          mEscrowClearcaseSupportCollection.add(set_up);
858
          mEscrowClearcaseSupportCollection.add(raw_data);
859
        }
860
 
861
        buildFileContent += generateDefaultTarget( buildFile);
862
        buildFileContent += generateBuildFileFooter();
863
 
864
        mBuildCollection.add(buildFileContent);
865
 
866
        // are more build files required
867
        allProcessed = true;
868
 
869
        if (!mDaemon)
870
        {
871
          // this is escrow mode centric
872
          for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
848 dpurdie 873
          {
898 mhunt 874
            Package p = it.next();
875
 
876
            if ( p.mBuildFile > buildFile )
877
            {
878
              // more build files are required
879
              allProcessed = false;
880
              mLogger.info("planRelease reiterating package has no build requirement " + p.mName + " " + p.mBuildFile + " " + buildFile);
881
              break;
882
            }
883
          } 
884
 
885
          buildFile++;
814 mhunt 886
        }
898 mhunt 887
      } while( !allProcessed );
888
    }
889
    finally
866 mhunt 890
    {
898 mhunt 891
      // this block is executed regardless of what happens in the try block
892
      // even if an exception is thrown
893
      // ensure the SELECT FOR UPDATE is released
894
      if ( mDaemon )
866 mhunt 895
      {
898 mhunt 896
        // attempt to release the SELECT FOR UPDATE through a commit
897
        // a commit must be done in the normal case
898
        // a commit may as well be done in the Exception case
899
        // in the case of a SQLException indicating database connectivity has been lost
900
        // having a go at the commit is superfluous
901
        // as the SELECT FOR UPDATE will have been released upon disconnection
902
        mReleaseManager.releaseMutex();
866 mhunt 903
      }
898 mhunt 904
 
905
      // ensure disconnect
906
      mReleaseManager.disconnect();
866 mhunt 907
    }
908
 
814 mhunt 909
    mLogger.warn("planRelease mDaemon " + mDaemon + " returned");
910
  }
911
 
908 mhunt 912
  /**reports what change in build exceptions happens as part of planRelease
913
   */
914
  public void reportChange() throws SQLException, Exception
915
  {
916
    for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
917
    {
918
      BuildExclusion buildExclusion = it.next();
919
 
920
      if ( !buildExclusion.isProcessed() )
921
      {
922
        // notify
923
        buildExclusion.excludeFromBuild(mReleaseManager, mBaseline);
924
        buildExclusion.email(mPackageCollection, mMailServer, mMailSender, mBaselineName, mReleaseManager);
925
      }
926
    }
927
  }
928
 
814 mhunt 929
  /**returns first build file content
930
   * returns false if no build file content exists
931
   */
932
  public boolean getFirstBuildFileContent(MutableString content)
933
  {
934
    mLogger.debug("getFirstBuildFileContent");
935
    boolean retVal = true;
936
 
937
    try
938
    {
939
      mBuildIndex = 0;
940
      content.value = (String)mBuildCollection.get( mBuildIndex );
941
    }
942
    catch( ArrayIndexOutOfBoundsException e )
943
    {
944
      retVal = false;
945
    }
946
 
947
    mLogger.info("getFirstBuildFileContent returned " + retVal);
948
    return retVal;
949
  }
950
 
951
  /**returns next build file content
952
   * returns false if no next build file content exists
953
   */
954
  public boolean getNextBuildFileContent(MutableString content)
955
  {
956
    mLogger.debug("getNextBuildFileContent");
957
    boolean retVal = true;
958
 
959
    try
960
    {
961
      mBuildIndex++;
962
      content.value = (String)mBuildCollection.get( mBuildIndex );
963
    }
964
    catch( ArrayIndexOutOfBoundsException e )
965
    {
966
      retVal = false;
967
    }
968
 
969
    mLogger.debug("getNextBuildFileContent returned " + retVal);
970
    return retVal;
971
  }
972
 
973
  /**collects meta data associated with the baseline
868 mhunt 974
   * this is sufficient to send an indefinite pause email notification
814 mhunt 975
   */
868 mhunt 976
  public void collectMetaData() throws SQLException, Exception
814 mhunt 977
  {
978
    mLogger.debug("collectMetaData mDaemon " + mDaemon);
979
    mGbeMachtypeCollection.removeAllElements();
898 mhunt 980
 
981
    try
814 mhunt 982
    {
898 mhunt 983
      mReleaseManager.connect();
984
      mReleaseManager.queryMachtypes(mGbeMachtypeCollection, mDaemon, mBaseline);
985
 
986
      if (mDaemon)
987
      {
988
        mMailServer = mReleaseManager.queryMailServer();
989
        mMailSender = mReleaseManager.queryMailSender();
990
        mGlobalTarget = mReleaseManager.queryGlobalAddresses();
991
      }
992
      mBaselineName = mReleaseManager.queryBaselineName(mDaemon, mBaseline);
814 mhunt 993
    }
898 mhunt 994
    finally
995
    {
996
      // this block is executed regardless of what happens in the try block
997
      // even if an exception is thrown
998
      // ensure disconnect
999
      mReleaseManager.disconnect();
1000
    }
814 mhunt 1001
  }
1002
 
1003
  /**returns the Package with the matching mAlias or NULL_PACKAGE if no package has the mID
1004
   */
908 mhunt 1005
  public Package findPackage(String alias)
814 mhunt 1006
  {
1007
    mLogger.debug("findPackage");
1008
    Package retVal = ReleaseManager.NULL_PACKAGE;
1009
 
864 mhunt 1010
    for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1011
    {
864 mhunt 1012
      Package p = it.next();
814 mhunt 1013
 
1014
      if ( p.mAlias.compareTo( alias ) == 0 )
1015
      {
1016
        retVal = p;
1017
        break;
1018
      }
1019
    }
1020
 
1021
    mLogger.info("findPackage returned " + retVal.mName);
1022
    return retVal;
1023
  }
1024
 
1025
  /**sets the mBuildFile to -5 for the package and all dependent packages
1026
   */
900 mhunt 1027
  private void rippleBuildExclude(Package p, int root_pv_id, String root_cause, ListIterator<BuildExclusion> list, BuildExclusion be )
814 mhunt 1028
  {
1029
    mLogger.debug("rippleBuildExclude");
874 mhunt 1030
    if ( p.mBuildFile == 0 || p.mBuildFile == 1 )
814 mhunt 1031
    {
1032
      p.mBuildFile = -5;
894 mhunt 1033
      mLogger.info("rippleBuildExclude set mBuildFile to -5 for package " + p.mAlias );
866 mhunt 1034
 
900 mhunt 1035
      if ( be != null )
866 mhunt 1036
      {
900 mhunt 1037
        be.process();
866 mhunt 1038
      }
900 mhunt 1039
      else
866 mhunt 1040
      {
900 mhunt 1041
        // if found, process it, else add it (unprocessed)
1042
        boolean found = false;
866 mhunt 1043
        for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
1044
        {
1045
          BuildExclusion buildExclusion = it.next();
836 mhunt 1046
 
900 mhunt 1047
          if ( buildExclusion.compare(p.mId, root_pv_id, root_cause))
866 mhunt 1048
          {
900 mhunt 1049
            found = true;
866 mhunt 1050
            buildExclusion.process();
900 mhunt 1051
            break;
866 mhunt 1052
          }
1053
        }
1054
 
900 mhunt 1055
        if (!found)
866 mhunt 1056
        {
900 mhunt 1057
          // process all occurrences for this package
1058
          // these will be superceded by a new build exclusion entry
1059
          for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
814 mhunt 1060
          {
900 mhunt 1061
            BuildExclusion buildExclusion = it.next();
814 mhunt 1062
 
900 mhunt 1063
            if ( buildExclusion.compare(p.mId))
814 mhunt 1064
            {
900 mhunt 1065
              buildExclusion.process();
814 mhunt 1066
            }
1067
          }
900 mhunt 1068
 
908 mhunt 1069
          BuildExclusion buildExclusion = new BuildExclusion(p.mId, root_pv_id, root_cause, p.mTestBuildInstruction);
900 mhunt 1070
 
1071
          if ( list == null )
1072
          {
1073
            mBuildExclusionCollection.add(buildExclusion);
1074
          }
1075
          else
1076
          {
1077
            // must use the ListIterator interface to add to the collection whilst iterating through it
1078
            list.add(buildExclusion);
1079
          }
814 mhunt 1080
        }
1081
      }
1082
 
908 mhunt 1083
      // only ripple a test build failure through for non test builds
1084
      if ( p.mTestBuildInstruction == 0 )
866 mhunt 1085
      {
908 mhunt 1086
        // non test build
1087
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
866 mhunt 1088
        {
908 mhunt 1089
          Package pkg = it.next();
1090
 
1091
          if ( pkg != p )
866 mhunt 1092
          {
908 mhunt 1093
            for (Iterator<Package> it2 = pkg.mPackageDependencyCollection.iterator(); it2.hasNext(); )
866 mhunt 1094
            {
908 mhunt 1095
              Package dependency = it2.next();
1096
 
1097
              if ( dependency == p )
1098
              {
1099
                rippleBuildExclude( pkg, root_pv_id, null, list, null );
1100
                break;
1101
              }
866 mhunt 1102
            }
1103
          }
1104
        }
1105
      }
1106
    }
1107
    mLogger.info("rippleBuildExclude set " + p.mName + " " + p.mBuildFile);
1108
  }
1109
 
814 mhunt 1110
  /**returns a build file header for the mBaseline
1111
   */
1112
  private String generateBuildFileHeader()
1113
  {
1114
    mLogger.debug("generateBuildFileHeader");
1115
    String lf = new String( System.getProperty("line.separator") );
1116
    String retVal = new String("");
1117
    retVal +=
862 mhunt 1118
    "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>" + lf +
814 mhunt 1119
    "<project name=\"mass\" default=\"full\" basedir=\".\">" + lf;
1120
 
1121
    if ( mDaemon )
1122
    {
1123
      retVal +=
1124
      "<property name=\"abt_mail_server\" value=\"" + mMailServer + "\"/>" + lf +
1125
      "<property name=\"abt_mail_sender\" value=\"" + mMailSender + "\"/>" + lf +
1126
      "<property name=\"abt_rtag_id\" value=\"" + mBaseline + "\"/>" + lf +
1127
      "<property name=\"abt_daemon\" value=\"" + mTimestamp + "\"/>" + lf;
866 mhunt 1128
 
1129
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1130
      {
1131
        Package p = it.next();
1132
 
1133
        if ( p.mBuildFile == 1 )
1134
        {
1135
          retVal +=
1136
          "<property name=\"abt_package_name\" value=\"" + p.mName + "\"/>" + lf +
1137
          "<property name=\"abt_package_version\" value=\"" + p.mVersion + p.mExtension + "\"/>" + lf +
1138
          "<property name=\"abt_package_extension\" value=\"" + p.mExtension + "\"/>" + lf +
1139
          loc(p, "abt_package_location", lf) +
1140
          "<property name=\"abt_package_depends\" value=\"";
1141
 
1142
          // depends in the form 'cs','25.1.0000.cr';'Dinkumware_STL','1.0.0.cots'
1143
          String depends = new String();
1144
 
1145
          for (Iterator<Package> it3 = p.mPackageDependencyCollection.iterator(); it3.hasNext(); )
1146
          {
1147
            Package depend = it3.next();
1148
 
1149
            if ( depends.compareTo( "" ) != 0 )
1150
            {
1151
              depends += ";";
1152
            }
1153
            depends += "\'" + depend.mName + "\'";
1154
            depends += ",";
1155
            String dependsExtension = depend.mExtension;
1156
            String dependsVersion = depend.mVersion;
1157
 
1158
            if ( dependsExtension.length() > 0 )
1159
            {
1160
              dependsVersion += dependsExtension;
1161
            }
1162
            else
1163
            {
1164
              dependsExtension = ".";
1165
            }
1166
            depends += "\'" + dependsVersion + "\'";
1167
          }
1168
 
1169
          retVal += depends + "\"/>" + lf +
1170
          "<property name=\"abt_is_ripple\" value=\"";
1171
 
1172
          if ( p.mDirectlyPlanned )
1173
          {
1174
            retVal += "0";
1175
          }
1176
          else
1177
          {
1178
            retVal += "1";
1179
          }
1180
 
1181
          retVal += "\"/>" + lf +
1182
          "<property name=\"abt_package_version_id\" value=\"" + p.mId + "\"/>" + lf +
1183
          "<property name=\"abt_does_not_require_source_control_interaction\" value=\"";
1184
 
1185
          if ( ! p.mRequiresSourceControlInteraction )
1186
          {
1187
            retVal += "true";
1188
          }
1189
          else
1190
          {
1191
            retVal += "false";
1192
          }
1193
 
908 mhunt 1194
          retVal += "\"/>" + lf +
1195
          "<property name=\"abt_test_build_instruction\" value=\"" + p.mTestBuildInstruction + "\"/>" + lf;
866 mhunt 1196
        }
1197
      }
814 mhunt 1198
    }
1199
    else
1200
    {
1201
      retVal +=
1202
      "<property name=\"abt_rtag_id\" value=\"-1\"/>" + lf;
1203
    }
1204
 
822 mhunt 1205
    String majorVersionNumber = this.getClass().getPackage().getSpecificationVersion();
1206
 
864 mhunt 1207
    if ( !ReleaseManager.mUseDatabase )
822 mhunt 1208
    {
1209
        // hard code 11 for unit test purposes
1210
         majorVersionNumber = "11";
1211
    }
1212
 
814 mhunt 1213
    retVal +=
1214
    "<property name=\"abt_release\" value=\"" + mBaselineName + "\"/>" + lf +
822 mhunt 1215
    "<property name=\"abt_buildtool_version\" value=\""+ majorVersionNumber + "\"/>" + lf +
814 mhunt 1216
    "<condition property=\"abt_family\" value=\"windows\">" + lf +
1217
    "  <os family=\"windows\"/>" + lf +
1218
    "</condition>" + lf +
1219
    "<property name=\"abt_family\" value=\"unix\"/>" + lf;
1220
    mLogger.info("generateBuildFileHeader returned " + retVal);
1221
    return retVal;
1222
  }
1223
 
1224
  /**returns an ant property for the passed Package
1225
   */
1226
  private String generatePackageProperty(Package p)
1227
  {
1228
    mLogger.debug("generatePackageProperty");
1229
    String lf = new String( System.getProperty("line.separator") );
1230
    String retVal = new String("");
1231
    retVal +=
1232
    "<property name=\"" + p.mAlias + "\" value=\"" + p.mName + " " + p.mVersion + p.mExtension + "\"/>" + lf;
1233
    mLogger.info("generatePackageProperty returned " + retVal);
1234
    return retVal;
1235
  }
1236
 
1237
  /**returns an ant taskdef for the abt ant task
1238
   */
1239
  private String generateTaskdef()
1240
  {
1241
    mLogger.debug("generateTaskdef");
1242
    String lf = new String( System.getProperty("line.separator") );
1243
    String retVal = new String("");
1244
    retVal +=
866 mhunt 1245
    "<taskdef name=\"abt\" classname=\"com.erggroup.buildtool.abt.ABT\"/>" + lf;
814 mhunt 1246
    return retVal;
1247
  }
1248
 
1249
  /**returns an ant target for the passed Package
1250
   * in daemon mode:
1251
   *  packages are categorised with one of three mBuildFile values:
1252
   *   1 the package to be built by this buildfile
1253
   *   2 the packages with a future build requirement
1254
   *   3 the packages with no build requirement
1255
   *  the returned target depends on this categorisation and will have
1256
   *   1 full abt info
1257
   *   2 full dependency info to determine future build ordering but no abt info (will not build this package)
1258
   *   3 only a name attribute (will not build this package)
1259
   * in escrow mode:
1260
   *  if the passed Package's mBuildFile is different (less than) the passed build file,
1261
   *  the returned target have only a name attribute (will not build this package) 
1262
   */
1263
  private String generateTarget(Package p, int buildFile)
1264
  {
1265
    mLogger.debug("generateTarget");
1266
 
832 mhunt 1267
    if ( ( mDaemon && p.mBuildFile == 1 ) || ( !mDaemon && !p.isGeneric() ) )
814 mhunt 1268
    {
1269
      // populate 'missing' BuildStandards
1270
      boolean solaris = false;
1271
      boolean linux = false;
1272
      boolean win32 = false;
1273
      boolean jats = false;
1274
      boolean determinedBuildStandard = false;
1275
 
864 mhunt 1276
      for (Iterator<BuildStandard> it = p.mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 1277
      {
864 mhunt 1278
        BuildStandard bs = it.next();
814 mhunt 1279
 
1280
        if ( bs.getSolaris() )
1281
        {
1282
          solaris = true;
1283
        }
1284
        else
1285
        if ( bs.getLinux() )
1286
        {
1287
          linux = true;
1288
        }
1289
        else
1290
        if ( bs.getWin32() )
1291
        {
1292
          win32 = true;
1293
        }
1294
 
908 mhunt 1295
        if ( !determinedBuildStandard && bs.getBuildStandard(!ReleaseManager.mUseDatabase, true).contains("<jats") )
814 mhunt 1296
        {
1297
          jats = true;
1298
          determinedBuildStandard = true;
1299
        }
1300
      }
1301
 
1302
      if ( !solaris )
1303
      {
1304
        BuildStandard bs = new BuildStandard(this);
1305
        bs.setSolaris();
1306
 
1307
        if ( jats )
1308
        {
1309
          bs.setJatsNone();
1310
        }
1311
        else
1312
        {
1313
          bs.setAntNone();
1314
        }
1315
 
1316
        p.mBuildStandardCollection.add(bs);
1317
      }
1318
 
1319
      if ( !linux )
1320
      {
1321
        BuildStandard bs = new BuildStandard(this);
1322
        bs.setLinux();
1323
 
1324
        if ( jats )
1325
        {
1326
          bs.setJatsNone();
1327
        }
1328
        else
1329
        {
1330
          bs.setAntNone();
1331
        }
1332
 
1333
        p.mBuildStandardCollection.add(bs);
1334
      }
1335
 
1336
      if ( !win32 )
1337
      {
1338
        BuildStandard bs = new BuildStandard(this);
1339
        bs.setWin32();
1340
 
1341
        if ( jats )
1342
        {
1343
          bs.setJatsNone();
1344
        }
1345
        else
1346
        {
1347
          bs.setAntNone();
1348
        }
1349
 
1350
        p.mBuildStandardCollection.add(bs);
1351
      }
1352
    }
1353
 
1354
    String lf = new String( System.getProperty("line.separator") );
1355
    String retVal = new String("");
1356
 
1357
    if ( ( mDaemon && p.mBuildFile == 3 ) ||
1358
         ( !mDaemon && ( p.mBuildFile < buildFile ) ) )
1359
    {
1360
      retVal +=
1361
      "<target name=\"" + p.mAlias + "\"/>" + lf;
1362
    }
1363
    else
1364
    {
848 dpurdie 1365
      retVal +=
814 mhunt 1366
      "<target name=\"" + p.mAlias + ".wrap\"";
1367
 
1368
      if ( p.mPackageDependencyCollection.size() > 0 )
1369
      {
1370
        retVal +=" depends=\"";
1371
        boolean comma = false;
1372
 
864 mhunt 1373
        for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
814 mhunt 1374
        {
906 mhunt 1375
          Package dependency = it.next();
1376
          // DEVI 54816
1377
          if ( !mDaemon && dependency.mBuildFile == -2 )
1378
          {
1379
            // ignore targets which build in foreign environments in escrow mode
1380
            continue;
1381
          }
814 mhunt 1382
          if (comma)
1383
          {
1384
            retVal += ",";
1385
          }
1386
          comma = true;
1387
 
1388
          retVal += dependency.mAlias;
1389
        }
1390
 
1391
        retVal += "\"";
1392
      }
1393
      retVal += ">" + lf;
1394
 
1395
      if ( !mDaemon )
1396
      {
1397
        boolean hasDependenciesBuiltInThisIteration = false;
1398
        if ( ( p.mPackageDependencyCollection.size() > 0 ) )
1399
        {
864 mhunt 1400
          for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
814 mhunt 1401
          {
864 mhunt 1402
            Package dependency = it.next();
814 mhunt 1403
 
1404
            if ( dependency.mBuildFile == buildFile )
1405
            {
1406
              hasDependenciesBuiltInThisIteration = true;
1407
              break;
1408
            }
1409
          }
1410
        }
1411
 
1412
        if ( hasDependenciesBuiltInThisIteration )
1413
        {
1414
          retVal +=
1415
          "  <condition property=\"" + p.mAlias + ".build\">" + lf +
1416
          "    <and>" + lf;
1417
 
864 mhunt 1418
          for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
814 mhunt 1419
          {
864 mhunt 1420
            Package dependency = it.next();
814 mhunt 1421
 
1422
            if ( dependency.mBuildFile == buildFile )
1423
            {
1424
              retVal +=
1425
              "      <or>" + lf +
1426
              "        <equals arg1=\"${" + dependency.mAlias + ".res}\" arg2=\"0\"/>" + lf +
1427
              "        <equals arg1=\"${" + dependency.mAlias + ".res}\" arg2=\"257\"/>" + lf +
1428
              "      </or>" + lf;
1429
            }
1430
          }
1431
 
1432
          retVal +=
1433
          "    </and>" + lf +
1434
          "  </condition>" + lf;
1435
        }
1436
        else
1437
        {
1438
          retVal += "  <property name=\"" + p.mAlias + ".build\" value=\"\"/>" + lf;
1439
        }
1440
      }
1441
 
1442
      retVal +=
1443
      "</target>" + lf +
1444
      "<target name=\"" + p.mAlias + "\" depends=\"" + p.mAlias + ".wrap\"";
1445
 
1446
      if ( !mDaemon )
1447
      {
1448
        retVal += " if=\"" + p.mAlias + ".build\"";
1449
      }
1450
 
1451
      retVal += ">" + lf;
1452
 
1453
      if ( mDaemon && p.mBuildFile == 1 )
1454
      {
1455
        retVal +=
1456
        "<property name=\"" + p.mAlias + "pkg_id\" value=\"" + p.mPid + "\"/>" + lf +
1457
        "<property name=\"" + p.mAlias + "pv_id\" value=\"" + p.mId + "\"/>" + lf;
1458
      }
1459
 
1460
      if ( ( mDaemon && p.mBuildFile == 1 ) || !mDaemon )
1461
      {
1462
        retVal +=
1463
        "<property name=\"" + p.mAlias + "packagename\" value=\"" + p.mName + "\"/>" + lf +
1464
        "<property name=\"" + p.mAlias + "packageversion\" value=\"" + p.mVersion + "\"/>" + lf +
1465
        "<property name=\"" + p.mAlias + "packageextension\" value=\"";
1466
 
1467
        if ( p.mExtension.length() > 0 )
1468
        {
1469
          // drop the .
1470
          retVal += p.mExtension.substring(1);
1471
        }
1472
        else
1473
        {
1474
          retVal += p.mExtension;
1475
        }
1476
 
1477
        retVal += "\"/>" + lf +
1478
        "<property name=\"" + p.mAlias + "packagelabel\" value=\"" + p.mLabel + "\"/>" + lf;
1479
 
1480
        if ( p.mDirectlyPlanned )
1481
        {
1482
          retVal += "<property name=\"" + p.mAlias + "directchange\" value=\"\"/>" + lf;
1483
        }
1484
 
852 mhunt 1485
        if ( ! p.mRequiresSourceControlInteraction )
1486
        {
1487
          retVal += "<property name=\"" + p.mAlias + "doesnotrequiresourcecontrolinteraction\" value=\"\"/>" + lf;
1488
        }
1489
 
814 mhunt 1490
        mAddendum = "non generic";
1491
 
1492
        if ( p.isGeneric() )
1493
        {
1494
          mAddendum = "generic";
1495
          retVal += "<property name=\"" + p.mAlias + "generic\" value=\"\"/>" + lf;
1496
        }
1497
 
1498
        retVal += loc(p, p.mAlias + "loc", lf);
1499
 
830 mhunt 1500
        if ( p.mHasAutomatedUnitTests && mDaemon )
814 mhunt 1501
        {
1502
          retVal += 
1503
          "<property name=\"" + p.mAlias + "unittests\" value=\"\"/>" + lf;
1504
        }
1505
      }
1506
 
1507
      retVal += "<abt>" + lf;
1508
 
1509
      if ( ( mDaemon && p.mBuildFile == 1 ) || !mDaemon )
1510
      {
864 mhunt 1511
        for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
814 mhunt 1512
        {
864 mhunt 1513
          Package dependency = it.next();
814 mhunt 1514
          retVal +=
1515
          "  <depend package_alias=\"${" + dependency.mAlias + "}\"/>" + lf;
1516
        }
1517
 
836 mhunt 1518
        retVal += buildInfo(p, lf, false);
814 mhunt 1519
      }
1520
 
1521
      if ( mDaemon && p.mBuildFile == 1 )
1522
      {
854 mhunt 1523
        retVal += p.emailInfo( lf );
814 mhunt 1524
      }
1525
 
1526
      retVal += "</abt>" + lf +
1527
      "</target>" + lf;
1528
 
1529
      if ( mDaemon && p.mBuildFile == 1 )
1530
      {
1531
        retVal +=
1532
        "<target name=\"AbtSetUp\">" + lf +
854 mhunt 1533
        "<property name=\"AbtSetUppackagelabel\" value=\"" + p.mLabel + "\"/>" + lf +
872 dpurdie 1534
        "<property name=\"AbtSetUppackagename\" value=\"" + p.mName + "\"/>" + lf +
1535
        "<property name=\"AbtSetUppackageSrcPath\" value=\"" + p.mLocation.replace('\\', '/') + "\"/>" + lf;
814 mhunt 1536
 
1537
        retVal +=
1538
        "<abt>" + lf +
854 mhunt 1539
        p.emailInfo( lf ) +
814 mhunt 1540
        "</abt>" + lf +
872 dpurdie 1541
        "</target>" + lf;
1542
 
1543
        retVal +=
814 mhunt 1544
        "<target name=\"AbtTearDown\">" + lf +
1545
        "<property name=\"AbtTearDownpackagelabel\" value=\"" + p.mLabel + "\"/>" + lf +
1546
        "<property name=\"AbtTearDownpackagename\" value=\"" + p.mName + "\"/>" + lf +
1547
        "<property name=\"AbtTearDownpackageversion\" value=\"" + p.mVersion + "\"/>" + lf +
1548
        "<property name=\"AbtTearDownpackageextension\" value=\"";
1549
 
1550
        if ( p.mExtension.length() > 0 )
1551
        {
1552
          // drop the .
1553
          retVal += p.mExtension.substring(1);
1554
        }
1555
        else
1556
        {
1557
          retVal += p.mExtension;
1558
        }
1559
 
1560
        retVal += "\"/>" + lf;
1561
 
1562
        if ( p.isGeneric() )
1563
        {
1564
          retVal += "<property name=\"" + p.mAlias + "generic\" value=\"\"/>" + lf;
1565
        }
1566
 
1567
        retVal +=        
1568
        "<abt>" + lf +
836 mhunt 1569
        buildInfo(p, lf, false) +
854 mhunt 1570
        p.emailInfo( lf ) +
814 mhunt 1571
        "</abt>" + lf +
1572
        "</target>" + lf +
1573
        "<target name=\"AbtPublish\">" + lf +
1574
        "<property name=\"AbtPublishpackagelabel\" value=\"" + p.mLabel + "\"/>" + lf +
1575
        "<property name=\"AbtPublishpackagename\" value=\"" + p.mName + "\"/>" + lf +
1576
        "<property name=\"AbtPublishpackageversion\" value=\"" + p.mVersion + "\"/>" + lf +
1577
        "<property name=\"AbtPublishpackageextension\" value=\"";
1578
 
1579
        if ( p.mExtension.length() > 0 )
1580
        {
1581
          // drop the .
1582
          retVal += p.mExtension.substring(1);
1583
        }
1584
        else
1585
        {
1586
          retVal += p.mExtension;
1587
        }
1588
 
1589
        retVal += "\"/>" + lf;
1590
 
1591
        if ( p.mDirectlyPlanned )
1592
        {
1593
          retVal += "<property name=\"AbtPublishdirectchange\" value=\"\"/>" + lf;
1594
        }
1595
 
852 mhunt 1596
        if ( ! p.mRequiresSourceControlInteraction )
1597
        {
1598
          retVal += "<property name=\"AbtPublishdoesnotrequiresourcecontrolinteraction\" value=\"\"/>" + lf;
1599
        }
1600
 
814 mhunt 1601
        if ( p.isGeneric() )
1602
        {
1603
          retVal += "<property name=\"AbtPublishgeneric\" value=\"\"/>" + lf;
1604
        }
1605
 
1606
        retVal += loc(p, "AbtPublishloc", lf);
1607
        retVal +=
816 mhunt 1608
        "<abt>" + lf +
854 mhunt 1609
        buildInfo(p, lf, true) +
1610
        p.emailInfo( lf ) +
814 mhunt 1611
        "</abt>" + lf +
1612
        "</target>" + lf;
1613
      }
1614
    }
1615
    mLogger.info("generateTarget returned " + retVal);
1616
    return retVal;
1617
  }
1618
 
1619
  /**returns an ant default target for the current build iteration
1620
   */
1621
  private String generateDefaultTarget(int buildFile)
1622
  {
1623
    mLogger.debug("generateDefaultTarget");
1624
    String lf = new String( System.getProperty("line.separator") );
1625
    String retVal = new String("");
1626
    retVal +=
1627
    "<target name=\"fullstart\">" + lf;
1628
 
1629
    if (buildFile == 1)
1630
    {
1631
      retVal +=
906 mhunt 1632
      "<echo message=\"${line.separator}" + mAnyBuildPlatforms + "${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
814 mhunt 1633
 
864 mhunt 1634
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1635
      {
864 mhunt 1636
        Package p = it.next();
814 mhunt 1637
 
1638
        if ( p.mBuildFile == -1 )
1639
        {
1640
          retVal +=
1641
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1642
        }
1643
      }
1644
 
1645
      retVal +=
906 mhunt 1646
      "<echo message=\"${line.separator}" + mAssocBuildPlatforms + "${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
814 mhunt 1647
 
864 mhunt 1648
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1649
      {
864 mhunt 1650
        Package p = it.next();
814 mhunt 1651
 
1652
        if ( p.mBuildFile == -2 )
1653
        {
1654
          retVal +=
1655
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1656
        }
1657
      }
1658
 
1659
      retVal +=
906 mhunt 1660
      "<echo message=\"${line.separator}" + mNotInBaseline + "${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
814 mhunt 1661
 
864 mhunt 1662
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1663
      {
864 mhunt 1664
        Package p = it.next();
814 mhunt 1665
 
1666
        if ( p.mBuildFile == -4 )
1667
        {
1668
          retVal +=
1669
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1670
        }
1671
      }
1672
 
1673
      retVal +=
906 mhunt 1674
      "<echo message=\"${line.separator}" + mDependent + "${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
814 mhunt 1675
 
864 mhunt 1676
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1677
      {
864 mhunt 1678
        Package p = it.next();
814 mhunt 1679
 
1680
        if ( p.mBuildFile == -5 )
1681
        {
1682
          retVal +=
1683
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1684
        }
1685
      }
1686
    }
1687
    if ( !mDaemon )
1688
    {
1689
      retVal +=
1690
      "<echo message=\"${line.separator}Build Started:${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1691
    }
1692
 
1693
    retVal +=
1694
    "</target>" + lf +
1695
    "<target name=\"full\" depends=\"fullstart";
1696
 
864 mhunt 1697
    for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1698
    {
864 mhunt 1699
      Package p = it.next();
814 mhunt 1700
 
1701
      if ( ( p.mBuildFile > 0 ) && ( p.mBuildFile <= buildFile ) )
1702
      {
1703
        retVal += "," + p.mAlias;
1704
      }
1705
    }
1706
 
1707
    retVal +=
1708
    "\">" + lf;
1709
 
1710
    if ( !mDaemon )
1711
    {
1712
      retVal +=
1713
      "<echo message=\"${line.separator}Build Finished${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1714
    }
1715
 
1716
    retVal +=
1717
    "</target>" + lf;
1718
    return retVal;
1719
  }
1720
 
1721
  /**returns a build file footer
1722
   */
1723
  private String generateBuildFileFooter()
1724
  {
1725
    mLogger.debug("generateBuildFileFooter");
1726
    String retVal = new String("</project>");
1727
    return retVal;
1728
  }
1729
 
1730
  /**sets the mIndirectlyPlanned true for the package and all dependent packages
1731
   */
1732
  private void rippleIndirectlyPlanned(Package p)
1733
  {
1734
    mLogger.debug("rippleIndirectlyPlanned");
1735
    if ( !p.mIndirectlyPlanned && p.mBuildFile == 0 )
1736
    {
1737
      p.mIndirectlyPlanned = true;
1738
 
864 mhunt 1739
      for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
814 mhunt 1740
      {
864 mhunt 1741
        Package pkg = it.next();
814 mhunt 1742
 
1743
        if ( pkg != p )
1744
        {
864 mhunt 1745
          for (Iterator<Package> it2 = pkg.mPackageDependencyCollection.iterator(); it2.hasNext(); )
814 mhunt 1746
          {
864 mhunt 1747
            Package dependency = it2.next();
814 mhunt 1748
 
1749
            if ( dependency == p )
1750
            {
1751
              rippleIndirectlyPlanned( pkg );
1752
              break;
1753
            }
1754
          }
1755
        }
1756
      }
1757
    }
1758
    mLogger.info("rippleIndirectlyPlanned set " + p.mName + " " + p.mIndirectlyPlanned);    
1759
  }
1760
 
1761
  /**accessor method
1762
   */
830 mhunt 1763
  public String getESCROWSetUp()
814 mhunt 1764
  {
830 mhunt 1765
    mLogger.debug("getESCROWSetUp");
814 mhunt 1766
    String retVal = new String("");
1767
 
1768
    try
1769
    {
830 mhunt 1770
      if ( mEscrowClearcaseSupportCollection.size() >= 1 )
814 mhunt 1771
      {
1772
        retVal = (String)mEscrowClearcaseSupportCollection.get(0);
1773
      }
1774
    }
1775
    catch( ArrayIndexOutOfBoundsException e )
1776
    {
1777
    }
1778
 
830 mhunt 1779
    mLogger.info("getESCROWSetUp returned " + retVal);
814 mhunt 1780
    return retVal;
1781
  }
1782
 
1783
  /**accessor method
1784
   */
830 mhunt 1785
  public String getRawData()
814 mhunt 1786
  {
830 mhunt 1787
    mLogger.debug("getRawData");
814 mhunt 1788
    String retVal = new String("");
1789
 
1790
    try
1791
    {
830 mhunt 1792
      if ( mEscrowClearcaseSupportCollection.size() >= 2 )
814 mhunt 1793
      {
1794
        retVal = (String)mEscrowClearcaseSupportCollection.get(1);
1795
      }
1796
    }
1797
    catch( ArrayIndexOutOfBoundsException e )
1798
    {
1799
    }
1800
 
830 mhunt 1801
    mLogger.info("getRawData returned " + retVal);
814 mhunt 1802
    return retVal;
1803
  }
1804
 
1805
  /**returns first build file content and addendum
1806
   * the addendum value is one of "non generic", "generic" or "dummy"
1807
   */
1808
  public void getFirstBuildFileContent(MutableString content, 
1809
                                MutableString addendum)
1810
  {
1811
    mLogger.debug("getFirstBuildFileContent");
1812
    try
1813
    {
1814
      mBuildIndex = 0;
1815
      content.value = (String)mBuildCollection.get( mBuildIndex );
1816
      addendum.value = mAddendum;
1817
    }
1818
    catch( ArrayIndexOutOfBoundsException e )
1819
    {
1820
    }
1821
    mLogger.info("getFirstBuildFileContent passed " + content.value + addendum.value);
1822
  }
1823
 
872 dpurdie 1824
  /**returns the build loc
814 mhunt 1825
   */
1826
  private String loc(Package p, String target, String lf)
1827
  {
1828
    mLogger.debug("loc");
1829
    String retVal = new String();
872 dpurdie 1830
    String loc = new String("/");
1831
 
1832
    if (mDaemon)
814 mhunt 1833
    {
872 dpurdie 1834
      // Daemon: Start in root of view/workspace
878 mhunt 1835
      loc += mBaseline + "/" + p.mLabel;
814 mhunt 1836
    }
872 dpurdie 1837
    else
814 mhunt 1838
    {
872 dpurdie 1839
      // mAlias used with jats -extractfiles -view
1840
      loc += p.mAlias;
1841
    }
814 mhunt 1842
 
872 dpurdie 1843
    //
1844
    //  Always use '/' as a path seperator - even if user has specified '\'
1845
    //  Ant can handle it.
1846
    //
814 mhunt 1847
    loc = loc.replace('\\', '/');
1848
    retVal += 
1849
    "<property name=\"" + target + "\" value=\"" + loc + "\"/>" + lf;
1850
 
1851
    mLogger.info("loc returned " + retVal);
1852
    return retVal;
1853
  }
816 mhunt 1854
 
1855
  /**returns the buildInfo
1856
   */
836 mhunt 1857
  private String buildInfo(Package p, String lf, boolean filter)
816 mhunt 1858
  {
1859
    mLogger.debug("buildInfo");
1860
 
1861
    String platforms = new String();
1862
    String standards = new String();
1863
 
864 mhunt 1864
    for (Iterator<BuildStandard> it = p.mBuildStandardCollection.iterator(); it.hasNext(); )
816 mhunt 1865
    {
864 mhunt 1866
      BuildStandard bs = it.next();
816 mhunt 1867
 
836 mhunt 1868
      if ( !filter )
816 mhunt 1869
      {
908 mhunt 1870
        String platform = bs.getPlatform(!ReleaseManager.mUseDatabase, true);
816 mhunt 1871
 
1872
        if ( platform.length() > 0 )
1873
        {
1874
          platforms += platform + lf;
1875
        }
1876
 
908 mhunt 1877
        String standard = bs.getBuildStandard(!ReleaseManager.mUseDatabase, true);
816 mhunt 1878
 
1879
        if ( standard.length() > 0 )
1880
        {
1881
          standards += standard + lf;
1882
        }
1883
      }
1884
      else
1885
      {
908 mhunt 1886
        if ( !bs.getBuildStandard(!ReleaseManager.mUseDatabase, true).contains("\"none\"") )
816 mhunt 1887
        {
908 mhunt 1888
          String platform = bs.getPlatform(!ReleaseManager.mUseDatabase, true);
816 mhunt 1889
 
1890
          if ( platform.length() > 0 )
1891
          {
1892
            platforms += platform + lf;
1893
          }
836 mhunt 1894
 
908 mhunt 1895
          String standard = bs.getBuildStandard(!ReleaseManager.mUseDatabase, true);
836 mhunt 1896
 
1897
          if ( standard.length() > 0 )
1898
          {
1899
            standards += standard + lf;
1900
          }
816 mhunt 1901
        }
1902
      }
1903
    }
1904
 
1905
    mLogger.info("buildInfo returned " + platforms + standards);
1906
    return platforms + standards;
1907
  }
866 mhunt 1908
 
906 mhunt 1909
  /**prints to standard out in escrow mode only
1910
   */
1911
  private void standardOut(final String message, final String alias, boolean printMessage)
1912
  {
1913
    mLogger.debug("standardOut");
1914
    if (!mDaemon)
1915
    {
1916
      if ( printMessage )
1917
      {
1918
        System.out.println(message);
1919
        // switch the message off
1920
        printMessage = false;
1921
      }
1922
 
1923
      System.out.println(alias);
1924
    }
1925
  }
814 mhunt 1926
}