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