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