Subversion Repositories DevTools

Rev

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