Subversion Repositories DevTools

Rev

Rev 7046 | Rev 7088 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7046 Rev 7082
Line 45... Line 45...
45
    /**name associated with the baseline
45
    /**name associated with the baseline
46
     * @attribute
46
     * @attribute
47
     */
47
     */
48
    public String mBaselineName = "";
48
    public String mBaselineName = "";
49
 
49
 
50
    /**collection of released pv_ids associated with the release
-
 
51
     * @attribute
-
 
52
     */
-
 
53
    public List<Integer> mReleasedPvIDCollection = new ArrayList<Integer>();
-
 
54
 
-
 
55
    /**Collection of build exceptions associated with the baseline
50
    /**Collection of build exceptions associated with the baseline
56
     * Used to determine (and report) what change in build exceptions happens as part of planRelease
51
     * Used to determine (and report) what change in build exceptions happens as part of planRelease
57
     * Daemon centric
52
     * Daemon centric
58
     * @aggregation shared
53
     * @aggregation shared
59
     * @attribute
54
     * @attribute
Line 73... Line 68...
73
    /** Escrow information - Raw data (May not be used)
68
    /** Escrow information - Raw data (May not be used)
74
     * @attribute
69
     * @attribute
75
     */
70
     */
76
    private String mEscrowRawData;
71
    private String mEscrowRawData;
77
 
72
 
78
    /**package versions representing the baseline
-
 
79
     * escrow centric
-
 
80
     * @aggregation shared
73
    /** Collections of packages
81
     * @attribute
-
 
82
     */
74
     */
83
    private ArrayList<Package> mPackageCollection = new ArrayList<Package>();
75
    private ArrayList<Package> mPackageCollection = new ArrayList<Package>();
-
 
76
    private ArrayList<Package> mPackageCollectionWip = new ArrayList<Package>();
-
 
77
    private ArrayList<Package> mPackageCollectionTest = new ArrayList<Package>();
-
 
78
    private ArrayList<Package> mPackageCollectionRipple = new ArrayList<Package>();
-
 
79
    private ArrayList<Package> mPackageCollectionAll = new ArrayList<Package>();
-
 
80
    
84
 
81
 
85
    /**index to current String item
82
    /**index to current String item
86
     * @attribute
83
     * @attribute
87
     */
84
     */
88
    private int mBuildIndex;
85
    private int mBuildIndex;
Line 120... Line 117...
120
 
117
 
121
    /** List of packages that we plan to build
118
    /** List of packages that we plan to build
122
     * Used to provide feedback into RM
119
     * Used to provide feedback into RM
123
     * Only the first entry is about to be built as we re-plan every cycle
120
     * Only the first entry is about to be built as we re-plan every cycle
124
     */
121
     */
125
    private ArrayList<Package> mBuildOrder = new ArrayList  <Package>();
122
    private ArrayList<PlannedPackage> mBuildOrder = new ArrayList  <PlannedPackage>();
126
    /**Warning message
123
    /**Warning message
127
     * @attribute
124
     * @attribute
128
     */
125
     */
129
    private static final String mAnyBuildPlatforms = "Warning. The following package versions are not reproducible on any build platform: ";
126
    private static final String mAnyBuildPlatforms = "Warning. The following package versions are not reproducible on any build platform: ";
130
 
127
 
Line 221... Line 218...
221
    {
218
    {
222
        mLogger.warn("planRelease mDaemon {}", mDaemon);
219
        mLogger.warn("planRelease mDaemon {}", mDaemon);
223
 
220
 
224
        mBuildCollection.clear();
221
        mBuildCollection.clear();
225
        mPackageCollection.clear();
222
        mPackageCollection.clear();
-
 
223
        mPackageCollectionRipple.clear();
-
 
224
        mPackageCollectionTest.clear();
226
        mReleasedPvIDCollection.clear();
225
        mPackageCollectionWip.clear();
227
        mBuildOrder.clear();
226
        mBuildOrder.clear();
228
        mEscrowRawData = "";
227
        mEscrowRawData = "";
229
        mEscrowSetup = "";
228
        mEscrowSetup = "";
230
        Phase phase = new Phase("Plan");
229
        Phase phase = new Phase("Plan");
231
 
230
 
Line 290... Line 289...
290
            //	Query package versions
289
            //	Query package versions
291
            //
290
            //
292
            phase.setPhase("queryPackageVersions");
291
            phase.setPhase("queryPackageVersions");
293
            mLogger.debug("planRelease queryPackageVersions");
292
            mLogger.debug("planRelease queryPackageVersions");
294
            mReleaseManager.queryPackageVersions(this, mPackageCollection, mBaseline);
293
            mReleaseManager.queryPackageVersions(this, mPackageCollection, mBaseline);
-
 
294
            mReleaseManager.queryWips(this, mPackageCollectionWip, mBaseline);
-
 
295
            mReleaseManager.queryTest(this, mPackageCollectionTest, mBaseline);
-
 
296
            mReleaseManager.queryRipples(this, mPackageCollectionRipple, mBaseline);
-
 
297
            mPackageCollectionAll.addAll(mPackageCollection);
-
 
298
            mPackageCollectionAll.addAll(mPackageCollectionWip);
-
 
299
            mPackageCollectionAll.addAll(mPackageCollectionTest);
-
 
300
            mPackageCollectionAll.addAll(mPackageCollectionRipple);
-
 
301
            
-
 
302
            // Sort the collection by PVID
-
 
303
            //      Unit Test output order is known
-
 
304
            //      May assist in creating repeatable build orders
-
 
305
            //
-
 
306
            Collections.sort(mPackageCollectionAll, Package.SeqComparator);
295
 
307
 
296
            //------------------------------------------------------------------------
308
            //------------------------------------------------------------------------
297
            //    Process packages collected
309
            //    Process packages collected
298
            //    Determine and tag those we can't build
310
            //    Determine and tag those we can't build
299
            phase.setPhase("processPackages");
311
            phase.setPhase("processPackages");
Line 362... Line 374...
362
     * @throws Exception
374
     * @throws Exception
363
     */
375
     */
364
    private void processPackages() throws SQLException, Exception {
376
    private void processPackages() throws SQLException, Exception {
365
 
377
 
366
        // Deal with test builds here as they may impact upon package attributes
378
        // Deal with test builds here as they may impact upon package attributes
367
        //    eg dependency collection and build standard differences
379
        //    eg: dependency collection and build standard differences
368
        //    This gives test builds preferential treatment
-
 
369
        //    Note: Done before mPackageDependencyCollection is setup
380
        //    Note: Done before mPackageDependencyCollection is setup
370
        //
381
        //
371
        if ( mDaemon )
382
        if ( mDaemon )
372
        {
383
        {
373
            // process test builds
384
            // Process test builds - they are in their own collection
374
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
385
            for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
375
            {
386
            {
376
                Package p = it.next();
387
                Package p = it.next();
-
 
388
                mLogger.info("planRelease package test build {}", p.mAlias);
377
 
389
 
-
 
390
                //
-
 
391
                //    Cannot test build an SDK based package or a Pegged Package
-
 
392
                //        Remove the test build request from the database
-
 
393
                //        Send a warning email
-
 
394
                //
378
                if (p.mBuildFile == 0)
395
                if(p.mIsPegged || p.mIsSdk)
379
                {
396
                {
380
                    // package has yet to be processed
397
                    // package has yet to be processed
381
                    if (  p.mTestBuildInstruction > 0 )
398
                    if (  p.mTestBuildInstruction > 0 )
382
                    {
399
                    {
383
                        mLogger.info("planRelease package test build {}", p.mName);
400
                        mLogger.info("planRelease package test build {}", p.mName);
384
 
401
 
385
                        //
-
 
386
                        //    Cannot test build an SDK based package or a Pegged Package
402
                    mLogger.error("planRelease Daemon Instruction (testBuild) of {} package deleted: {}", reason, p.mAlias);
387
                        //        Remove the test build request from the database
403
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
388
                        //        Send a warning email
404
                    emailRejectedDaemonInstruction("Cannot 'Test Build' a " + reason + " package",p);
389
                        //
-
 
390
                        if(p.mIsPegged || p.mIsSdk)
-
 
391
                        {
405
                }
392
                            String reason;
-
 
393
                            reason = (p.mIsPegged) ? "Pegged" : "SDK Based";
-
 
394
 
406
 
395
                            mLogger.error("planRelease Daemon Instruction of {} package deleted: {}", reason, p.mName);
407
                            mLogger.error("planRelease Daemon Instruction of {} package deleted: {}", reason, p.mName);
396
                            mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
408
                            mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
397
                            emailRejectedDaemonInstruction("Cannot 'Test Build' a " + reason + " package",p);
409
                            emailRejectedDaemonInstruction("Cannot 'Test Build' a " + reason + " package",p);
398
                        }
410
                        }
Line 416... Line 428...
416
            }
428
            }
417
        }
429
        }
418
 
430
 
419
        // Set up mPackageDependencyCollection on each package
431
        // Set up mPackageDependencyCollection on each package
420
        //    Examine the dependencies by alias and convert this to a 'package' selected from the released package set
432
        //    Examine the dependencies by alias and convert this to a 'package' selected from the released package set
421
        mLogger.debug("planRelease setup mPackageDependencyCollection");
433
        mLogger.debug("planRelease setup setPackageDependencyCollection");
422
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
434
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
423
        {
435
        {
424
            Package p = it.next();
436
            Package p = it.next();
425
 
437
 
426
            for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
438
            for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
427
            {
439
            {
428
                String alias = it2.next();
440
                String alias = it2.next();
429
                Package dependency = findPackage(alias);
441
                Package dependency = findPackage(alias);
430
 
-
 
431
                p.mPackageDependencyCollection.add(dependency);
442
                p.mPackageDependencyCollection.add(dependency);
432
            }
443
            }
433
        }
444
        }    
434
 
445
 
435
        // DEVI 56479 detect and deal with circular dependencies
446
        // Detect and deal with circular dependencies
-
 
447
        // Examine all packages under consideration
-
 
448
        //
436
        mLogger.debug("planRelease deal with circular dependencies");
449
        mLogger.debug("planRelease deal with circular dependencies");
437
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
450
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
438
        {
451
        {
439
            Package p = it.next();
452
            Package p = it.next();
440
 
453
 
441
            if ( p.hasCircularDependency( this ) )
454
            if ( p.hasCircularDependency( mPackageCollectionAll ) )
442
            {
455
            {
443
                mLogger.info("planRelease circular dependency detected {}", p.mAlias);
456
                mLogger.info("planRelease circular dependency detected {}", p.mAlias);
444
                
457
                
445
                //  Force this package to be marked as having a circular dependency - even if its been excluded
458
                //  Force this package to be marked as having a circular dependency - even if its been excluded
446
                p.mBuildFile = 0;
459
                p.mBuildFile = 0;
447
                
460
                
448
                // exclude all dependent packages
461
                // Exclude the package
449
                // max 50 chars
462
                // max 50 chars
450
                rippleBuildExclude(p, p.mId, "Package has circular dependency", null, null, true);
463
                rippleBuildExclude(p, p.mId, "Package has circular dependency", -6);
451
 
464
 
452
                // take the package out of the build
465
                // take the package out of the build
453
                p.mBuildFile = -6;
466
                p.mBuildFile = -6;
454
                mLogger.info("planRelease set mBuildFile to -6 for package {}", p.mAlias );
467
                mLogger.info("planRelease set mBuildFile to -6 for package {}", p.mAlias );
455
                standardOut(mCircularDependency, p.mAlias, mCircularDependencyFlag);
468
                standardOut(mCircularDependency, p.mAlias, mCircularDependencyFlag);
Line 457... Line 470...
457
            }
470
            }
458
        }
471
        }
459
 
472
 
460
        // Scan for packages with missing dependencies
473
        // Scan for packages with missing dependencies
461
        //    ie: The dependent package is not in the package Collection
474
        //    ie: The dependent package is not in the package Collection
462
        //        DEVI 55483 now use the fully built mPackageDependencyCollection (in rippleBuildExclude)
-
 
463
        mLogger.debug("planRelease use the fully built mPackageDependencyCollection");
475
        mLogger.debug("planRelease use the fully built mPackageDependencyCollection");
464
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
476
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
465
        {
477
        {
466
            Package p = it.next();
478
            Package p = it.next();
467
 
479
 
468
            if ( mDaemon )
480
            if ( mDaemon )
469
            {
481
            {
Line 484... Line 496...
484
                if (dependency == ReleaseManager.NULL_PACKAGE)
496
                if (dependency == ReleaseManager.NULL_PACKAGE)
485
                {
497
                {
486
                    mLogger.info("planRelease dependency is not in the baseline {}", alias);
498
                    mLogger.info("planRelease dependency is not in the baseline {}", alias);
487
                    // exclude all dependent packages
499
                    // exclude all dependent packages
488
                    // max 50 chars
500
                    // max 50 chars
489
                    rippleBuildExclude(p, p.mId, "Package build dependency not in the release", null, null, true);
501
                    rippleBuildExclude(p, p.mId, "Package build dependency not in the release", -4);
490
 
502
 
491
                    // take the package out of the build
503
                    // take the package out of the build
492
                    p.mBuildFile = -4;
504
                    p.mBuildFile = -4;
493
                    mLogger.info("planRelease set mBuildFile to -4 for package {}", p.mAlias );
505
                    mLogger.info("planRelease set mBuildFile to -4 for package {}", p.mAlias );
494
                    standardOut(mNotInBaseline, p.mAlias, mNotInBaselineFlag);
506
                    standardOut(mNotInBaseline, p.mAlias, mNotInBaselineFlag);
Line 496... Line 508...
496
                    break;
508
                    break;
497
                }
509
                }
498
            }
510
            }
499
        }
511
        }
500
 
512
 
501
        // Process packages which are not reproducible, and all packages dependent upon them
513
        // Detect packages with no build standard and exclude them from the build
502
        //    ie: Have no build standard      
-
 
503
        mLogger.debug("planRelease process packages which are not reproducible");
514
        mLogger.debug("planRelease process packages which are not reproducible");
504
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
515
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
505
        {
516
        {
506
            Package p = it.next();
517
            Package p = it.next();
507
 
518
 
508
            if (p.mBuildFile == 0)
519
            if (p.mBuildFile == 0)
509
            {
520
            {
Line 516... Line 527...
516
                    {
527
                    {
517
                        continue;
528
                        continue;
518
                    }
529
                    }
519
                }
530
                }
520
 
531
 
-
 
532
                // Does the package have a build standard. If not then we can't reproduce it.
521
                // package has yet to be processed
533
                // Escrow - Assume the package is provided
-
 
534
                // Daemon - Exclude this package, but not its consumers. If the package is available then we can use it.
522
                if (!p.isReproducible())
535
                if (!p.isReproducible())
523
                {
536
                {
524
                    // for escrow build purposes, exclude all dependent package versions
537
                    // for escrow build purposes, exclude all dependent package versions
525
                    mLogger.info("planRelease package not reproducible {}" ,p.mName);
538
                    mLogger.info("planRelease package not reproducible {}" ,p.mName);
526
                    // max 50 chars
539
                    // max 50 chars
527
                    rippleBuildExclude(p, p.mId, "Package has no build environment", null, null, true);
540
                    rippleBuildExclude(p, p.mId, "Package has no build environment", -1);
528
 
541
 
529
                    // package is not reproducible, discard
542
                    // package is not reproducible, discard
530
                    p.mBuildFile = -1;
543
                    p.mBuildFile = -1;
531
                    mLogger.info("planRelease set mBuildFile to -1 for package {}", p.mAlias );
544
                    mLogger.info("planRelease set mBuildFile to -1 for package {}", p.mAlias );
532
                    standardOut(mAnyBuildPlatforms, p.mAlias, mAnyBuildPlatformsFlag);
545
                    standardOut(mAnyBuildPlatforms, p.mAlias, mAnyBuildPlatformsFlag);
533
                    mAnyBuildPlatformsFlag = false;
546
                    mAnyBuildPlatformsFlag = false;
534
                }
547
                }
535
            }
548
            }
536
        }
549
        }
537
 
550
 
538
        //    Process packages which are not reproducible on the configured set of  build machines.
551
        //    Process packages which are not reproducible on the configured set of build machines.
539
        //
552
        //
540
        //    Test each package and determine if the package contains a buildStandard that
553
        //    Test each package and determine if the package contains a buildStandard that
541
        //    can be processed by one of the machines in the build set
554
        //    can be processed by one of the machines in the build set
542
        //
555
        //
543
        //    ie: Package: Win32:Production and we have a BM with a class of 'Win32'
556
        //    ie: Package: Win32:Production and we have a BM with a class of 'Win32'
544
        //
557
        //
545
        //    July-2014 
-
 
546
        //    Only exclude the failing package and not its dependents
558
        //    Only exclude the failing package and not its dependents
547
        //    May be legitimate in the release
559
        //    May be legitimate in the release
548
        //
560
        //
549
        mLogger.debug("planRelease process packages which are not reproducible2");
561
        mLogger.debug("planRelease process packages which are not reproducible2");
550
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
562
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
551
        {
563
        {
552
            Package p = it.next();
564
            Package p = it.next();
553
 
565
 
554
            if (p.mBuildFile == 0)
566
            if (p.mBuildFile == 0)
555
            {
567
            {
Line 584... Line 596...
584
 
596
 
585
                if ( !reproduce )
597
                if ( !reproduce )
586
                {
598
                {
587
                    mLogger.info("planRelease package not reproducible on the build platforms configured for this baseline {}", p.mName);
599
                    mLogger.info("planRelease package not reproducible on the build platforms configured for this baseline {}", p.mName);
588
 
600
 
589
                    if (mDaemon)
-
 
590
                    {
-
 
591
                        // DEVI 54816
601
                    // Exclude the package
592
                        // for escrow build purposes, do not exclude all dependent package versions
-
 
593
                        // max 50 chars
602
                    // max 50 chars
594
                        rippleBuildExclude(p, p.mId, "Package not built for configured platforms", null, null, false);
603
                    rippleBuildExclude(p, p.mId, "Package not built for configured platforms", -2);
595
                    }
-
 
596
 
604
 
597
                    // package is not reproducible on the build platforms configured for this baseline, discard
605
                    // package is not reproducible on the build platforms configured for this baseline, discard
598
                    p.mBuildFile = -2;
606
                    p.mBuildFile = -2;
599
                    mLogger.info("planRelease set mBuildFile to -2 for package {}", p.mAlias );
607
                    mLogger.info("planRelease set mBuildFile to -2 for package {}", p.mAlias );
600
                    standardOut(mAssocBuildPlatforms, p.mAlias, mAssocBuildPlatformsFlag);
608
                    standardOut(mAssocBuildPlatforms, p.mAlias, mAssocBuildPlatformsFlag);
601
                    mAssocBuildPlatformsFlag = false;
609
                    mAssocBuildPlatformsFlag = false;
602
                }
610
                }
603
            }
611
            }
604
        }      
612
        }      
605
 
613
 
606
        if (mDaemon)
614
        if (mDaemon )
607
        {
615
        {
608
            // Daemon Mode Only
-
 
609
            // Process packages which are not ripple buildable, and all packages dependent upon them
-
 
610
            mLogger.debug("planRelease process packages which are not ripple buildable");
-
 
611
            for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
-
 
612
            {
-
 
613
                BuildExclusion be = it.next();
-
 
614
 
616
 
615
                for (Iterator<Package> it1 = mPackageCollection.iterator(); it1.hasNext(); )
617
                for (Iterator<Package> it1 = mPackageCollection.iterator(); it1.hasNext(); )
616
                {
618
                {
617
                    Package p = it1.next();
619
                    Package p = it1.next();
618
 
620
 
Line 644... Line 646...
644
                    if (p.mIsPegged || p.mIsSdk)
646
                    if (p.mIsPegged || p.mIsSdk)
645
                    {
647
                    {
646
                        continue;
648
                        continue;
647
                    }
649
                    }
648
 
650
 
649
                    // package has yet to be processed
651
                    //    Examine this packages dependencies
-
 
652
                    //    If one of them does not exist in the 'official release' set then
-
 
653
                    //    the package needs to be built against the official release set
-
 
654
                    //    and we can't build any of its dependent packages
-
 
655
                    Iterator<Integer> it2 = p.mDependencyIDCollection.iterator();
-
 
656
                    Iterator<Package> it3 = p.mPackageDependencyCollection.iterator();
650
                    if (p.mDirectlyPlanned)
657
                    while ( it2.hasNext() && it3.hasNext() )
651
                    {
658
                    {
652
                        // a WIP exists on the package, or it is a Test Build
659
                        // a WIP exists on the package, or it is a Test Build
653
                        // exclude all dependent package versions
660
                        // exclude all dependent package versions
654
                        mLogger.info("planRelease package has WIP {}", p.mName);
661
                        mLogger.info("planRelease package has WIP {}", p.mName);
655
                        if ( p.mBuildReason == null)
662
                        if ( p.mBuildReason == null)
Line 664... Line 671...
664
                        //    and we can't build any of its dependent packages
671
                        //    and we can't build any of its dependent packages
665
                        Iterator<Integer> it2 = p.mDependencyIDCollection.iterator();
672
                        Iterator<Integer> it2 = p.mDependencyIDCollection.iterator();
666
                        Iterator<Package> it3 = p.mPackageDependencyCollection.iterator();
673
                        Iterator<Package> it3 = p.mPackageDependencyCollection.iterator();
667
                        while ( it2.hasNext() && it3.hasNext() )
674
                        while ( it2.hasNext() && it3.hasNext() )
668
                        {
675
                        {
669
                            Integer dpvId = it2.next();
676
                            // not advisory, ie: has ripple build impact
670
                            Package dependency = it3.next();
-
 
671
 
-
 
672
                            if ( !dependency.mAdvisoryRipple )
677
                            if ( !isInRelease(dpvId) )
673
                            {
678
                            {
674
                                // not advisory, ie: has ripple build impact
679
                                // the package is out of date
-
 
680
                                // exclude all dependent package versions
-
 
681
                                mLogger.info("planRelease package out of date {}", p.mName);
-
 
682
                                p.mBuildReason = BuildReason.Ripple;
675
                                if ( !isInRelease(dpvId) )
683
                                rippleIndirectlyPlanned(p);
-
 
684
                                
-
 
685
                                //  This package needs to be rippled
-
 
686
                                //  If this package has a rippleStop marker of 's', then we cannot
-
 
687
                                //  build this package at the moment.
-
 
688
                                //  Packages that depend on this package have been excluded
-
 
689
                                //  We need to exclude this one too
-
 
690
                                //
-
 
691
                                if (p.mRippleStop == 's' || p.mRippleStop == 'w') 
676
                                {
692
                                {
677
                                    // the package is out of date
693
                                    // the package is out of date
678
                                    // exclude all dependent package versions
694
                                    // exclude all dependent package versions
679
                                    mLogger.info("planRelease package out of date {}", p.mName);
695
                                    mLogger.info("planRelease package out of date {}", p.mName);
680
                                    p.mBuildReason = BuildReason.Ripple;
696
                                    p.mBuildReason = BuildReason.Ripple;
Line 699... Line 715...
699
                                            // Need to flag to users that the package build is waiting user action
715
                                            // Need to flag to users that the package build is waiting user action
700
                                            mLogger.info("planRelease Ripple Required. Stopped by flag {}", p.mName);
716
                                            mLogger.info("planRelease Ripple Required. Stopped by flag {}", p.mName);
701
                                            mReleaseManager.setRippleStopWait(mRtagId,p);
717
                                            mReleaseManager.setRippleStopWait(mRtagId,p);
702
                                        }
718
                                        }
703
                                    }
719
                                    }
704
                                    
-
 
705
                                    
-
 
706
                                    break;
-
 
707
                                }
720
                                }
-
 
721
                                
-
 
722
                                break;
708
                            }
723
                            }
709
                        }
724
                        }
710
                    }
725
                    }
711
                }
726
                }
712
            }
727
            }
Line 733... Line 748...
733
                                {
748
                                {
734
                                    //  Package does not exist in dpkg_archive and it has been flagged as unbuildable
749
                                    //  Package does not exist in dpkg_archive and it has been flagged as unbuildable
735
                                    //  This may be because is Unbuildable or Manually built
750
                                    //  This may be because is Unbuildable or Manually built
736
                                    mLogger.info("planRelease Unbuildable package not found in archive {}", p.mName);
751
                                    mLogger.info("planRelease Unbuildable package not found in archive {}", p.mName);
737
                                    // max 50 chars
752
                                    // max 50 chars
738
                                    rippleBuildExclude(p, p.mId, "Unbuildable" + " package not found in archive", null, null, true);
753
                                    rippleBuildExclude(p, p.mId, "Unbuildable" + " package not found in archive", -10);
739
 
-
 
740
                                    // package is unBuildable, mark reason and discard
-
 
741
                                    p.mBuildFile = -10;
-
 
742
                                    
754
                                    
743
                                }
755
                                }
744
                                //  Not interested in a pegged package or a package provided from an SDK.
756
                                //  Not interested in a pegged package or a package provided from an SDK.
745
                                //  Such packages are not rippled
757
                                //  Such packages are not rippled
746
                                else if (p.mIsPegged || p.mIsSdk)
758
                                else if (p.mIsPegged || p.mIsSdk)
Line 751... Line 763...
751
                                    //  Pegged packages or packages provided from an SDK MUST exist in dpkg_archive
763
                                    //  Pegged packages or packages provided from an SDK MUST exist in dpkg_archive
752
                                    //  They will not be built within the context of this release. It is the responsibility
764
                                    //  They will not be built within the context of this release. It is the responsibility
753
                                    //  of another release to build them.
765
                                    //  of another release to build them.
754
                                    mLogger.info("planRelease {} package not found in archive {}", reason, p.mName);
766
                                    mLogger.info("planRelease {} package not found in archive {}", reason, p.mName);
755
                                    // max 50 chars
767
                                    // max 50 chars
756
                                    rippleBuildExclude(p, p.mId, reason + " package not found in archive", null, null, true);
768
                                    rippleBuildExclude(p, p.mId, reason + " package not found in archive", -7);
757
 
-
 
758
                                    // package is not reproducible, mark reason and discard
-
 
759
                                    p.mBuildFile = -7;
-
 
760
 
-
 
761
                                }
769
                                }
762
                                else if (p.mForcedRippleInstruction == 0)
770
                                else if (p.mForcedRippleInstruction == 0)
763
                                {
771
                                {
764
                                    //  [JATS-331] Unable to rebuild package with Advisory Ripple dependencies
772
                                    //  [JATS-331] Unable to rebuild package with Advisory Ripple dependencies
765
                                    //    Examine this packages dependencies
773
                                    //    Examine this packages dependencies
Line 773... Line 781...
773
                                            // This package cannot be rebuilt as one of its dependents is NOT in this release
781
                                            // This package cannot be rebuilt as one of its dependents is NOT in this release
774
                                            // exclude all dependent package versions
782
                                            // exclude all dependent package versions
775
                                            
783
                                            
776
                                            mLogger.info("planRelease package not found in archive. Cannot be rebuilt due to {}", p.mName);
784
                                            mLogger.info("planRelease package not found in archive. Cannot be rebuilt due to {}", p.mName);
777
                                            // max 50 chars
785
                                            // max 50 chars
778
                                            rippleBuildExclude(p, p.mId, "Package cannot be rebuilt in this release", null, null, true);
786
                                            rippleBuildExclude(p, p.mId, "Package cannot be rebuilt in this release", -4);
779
 
-
 
780
                                            // package is not reproducible, mark reason and discard
-
 
781
                                            p.mBuildFile = -4;
-
 
782
                                            break;
787
                                            break;
783
                                        }
788
                                        }
784
                                    }
789
                                    }
785
                                    
790
                                    
786
                                    //  The package has not been excluded from the build
791
                                    //  The package has not been excluded from the build
Line 800... Line 805...
800
                    }
805
                    }
801
                }
806
                }
802
            }
807
            }
803
 
808
 
804
            //  Daemon Mode Only
809
            //  Daemon Mode Only
805
            //  Process forced ripples
810
            //  Detect bad forced ripples requests and reject them
806
            mLogger.debug("planRelease process forced ripples");
811
            mLogger.debug("planRelease process forced ripples");
807
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
812
            for (Iterator<Package> it = mPackageCollectionRipple.iterator(); it.hasNext(); )
808
            {
813
            {
809
                Package p = it.next();
814
                Package p = it.next();
810
 
815
 
811
                if (p.mBuildFile == 0)
816
                if (p.mBuildFile == 0)
812
                {
817
                {
-
 
818
                    //
-
 
819
                    //    Cannot force a ripple on an SDK based package or a Pegged Package
-
 
820
                    //        Remove the daemon instruction from the database
813
                    // package has yet to be processed
821
                    //        Send a warning email
-
 
822
                    //
814
                    if ( p.mForcedRippleInstruction > 0 )
823
                    if(p.mIsPegged || p.mIsSdk)
815
                    {
824
                    {
816
                        //
-
 
817
                        //    Cannot force a ripple on an SDK based package or a Pegged Package
-
 
818
                        //        Remove the daemon instruction from the database
-
 
819
                        //        Send a warning email
-
 
820
                        //
-
 
821
                        if(p.mIsPegged || p.mIsSdk)
-
 
822
                        {
-
 
823
                            String reason;
825
                        String reason;
824
                            reason = (p.mIsPegged) ? "Pegged" : "SDK Based";
826
                        reason = (p.mIsPegged) ? "Pegged" : "SDK Based";
825
 
827
 
826
                            mLogger.error("planRelease Daemon Instruction of {} package deleted: {}", reason, p.mName);
828
                            mLogger.error("planRelease Daemon Instruction of {} package deleted: {}", reason, p.mName);
827
                            mReleaseManager.markDaemonInstCompleted( p.mForcedRippleInstruction );
829
                            mReleaseManager.markDaemonInstCompleted( p.mForcedRippleInstruction );
828
                            emailRejectedDaemonInstruction("Cannot 'Ripple' a " + reason + " package",p);
830
                            emailRejectedDaemonInstruction("Cannot 'Ripple' a " + reason + " package",p);
829
 
831
 
Line 839... Line 841...
839
                }
841
                }
840
            }
842
            }
841
 
843
 
842
            //  Daemon Mode Only
844
            //  Daemon Mode Only
843
            //  Mark Pegged and SDK packages as not to be built
845
            //  Mark Pegged and SDK packages as not to be built
-
 
846
            //  Mark RippleStoped packages as not to be build
844
            //  Have previously detected conflicts between pegged/sdk packages and daemon instructions
847
            //  Have previously detected conflicts between pegged/sdk packages and daemon instructions
845
            //
848
            //
846
            mLogger.debug("planRelease remove pegged and SDK packages from the build set");
849
            mLogger.debug("planRelease remove pegged and SDK packages from the build set");
847
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
850
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
848
            {
851
            {
849
                Package p = it.next();
852
                Package p = it.next();
850
 
853
 
851
                if (p.mBuildFile == 0)
854
                if (p.mBuildFile == 0)
852
                {
855
                {
-
 
856
                    String reason = null;
-
 
857
                    
853
                    //  Not interested in a pegged package or a package provided from an SDK.
858
                    //  Not interested in a pegged package or a package provided from an SDK or packages with an active RippleStop
854
                    //  Such packages are not built
859
                    //  Such packages are not built
855
                    if (p.mIsPegged || p.mIsSdk)
860
                    if (p.mIsPegged || p.mIsSdk)
856
                    {
861
                    {
857
                        String reason;
862
                        String reason;
858
                        reason = (p.mIsPegged) ? "Pegged" : "SDK";
863
                        reason = (p.mIsPegged) ? "Pegged" : "SDK";
859
 
864
 
860
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
865
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
861
                        p.mBuildFile = -8;
866
                        p.mBuildFile = -8;
-
 
867
                    } else if (p.mIsSdk) {
-
 
868
                        reason = "SDK";
-
 
869
                        p.mBuildFile = -8;
-
 
870
                    } else if (p.mRippleStop == 's' || p.mRippleStop == 'w') {
-
 
871
                        reason = "RippleStop";
-
 
872
                        p.mBuildFile = -11;
-
 
873
                    }
-
 
874
                    
-
 
875
                    if (reason != null)
-
 
876
                    {
-
 
877
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
862
                    }
878
                    }
863
                }
879
                }
864
            }
880
            }
865
 
881
 
866
            //  Daemon Mode Only
882
            //  Daemon Mode Only
867
            //  Locate Test Build Requests that cannot be satisfied - will not be built due to
883
            //  Locate Test Build Requests that cannot be satisfied - will not be built due to
868
            //  errors in dependent packages. Report the error to the user and remove the request
884
            //  errors in dependent packages. Report the error to the user and remove the request
869
            //
885
            //
-
 
886
            for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
-
 
887
            {
-
 
888
                Package p = it.next();
-
 
889
 
-
 
890
                if (p.mBuildFile < 0)
-
 
891
                {
-
 
892
                    String reason;
-
 
893
                    switch (p.mBuildFile)
-
 
894
                    {
-
 
895
                    case -1:  reason = "Not reproducible"; break;
-
 
896
                    case -2:  reason = "Not reproducible on configured build platforms"; break;
-
 
897
                    case -3:  reason = "Marked as 'Do not ripple'"; break;
-
 
898
                    case -4:  reason = "Dependent on a package not in the release"; break;
-
 
899
                    case -5:  reason = "Indirectly dependent on a package not reproducible in the release"; break;
-
 
900
                    case -6:  reason = "Has a circular dependency"; break;
-
 
901
                    case -7:  reason = "Pegged or SDK package not in dpkg_archive"; break;
-
 
902
                    case -8:  reason = "Is a Pegged or SDK package"; break;
-
 
903
                    case -9:  reason = "Rejected Daemon Instruction"; break;
-
 
904
                    case -10: reason = "Unbuildable package not in dpkg_archive"; break;
-
 
905
                    case -11: reason = "Marked as 'RippleStop'"; break;
-
 
906
                    default:  reason = "Unknown reason. Code:" + p.mBuildFile; break;
-
 
907
                    }
-
 
908
                    mLogger.error("planRelease Test Build of an unbuildable of package deleted: {}", p.mName);
-
 
909
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
-
 
910
                    emailRejectedDaemonInstruction(reason,p);
-
 
911
                }
-
 
912
            }
-
 
913
            
-
 
914
            //  Daemon Mode Only
-
 
915
            //  Examine the build candidates and verify that a new version number can be calculated for each
-
 
916
            //  version that we need to build.
-
 
917
            //
-
 
918
            //  If we can't generate a new version number, then this is considered to be a build failure
-
 
919
            //  The package will be excluded and the user will be emailed
-
 
920
            //
-
 
921
            ArrayList<Package> testVersions = new ArrayList<Package>();
-
 
922
            testVersions.addAll(mPackageCollectionWip);
-
 
923
            testVersions.addAll(mPackageCollectionRipple);
-
 
924
            testVersions.addAll(mPackageCollectionTest);
-
 
925
            
870
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
926
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
871
            {
927
            {
872
                Package p = it.next();
928
                Package p = it.next();
-
 
929
                if (p.mBuildFile >= 0 &&  p.mBuildReason != null) {
-
 
930
                    testVersions.add(p);
-
 
931
                }
-
 
932
            }
-
 
933
                    
-
 
934
            for (Iterator<Package> it = testVersions.iterator(); it.hasNext(); )
-
 
935
            {
-
 
936
                Package p = it.next();
873
 
937
 
874
                if (p.mTestBuildInstruction > 0)
938
                if ( p.mBuildFile >= 0 )
875
                {
939
                {
-
 
940
                    int pvApplied = p.applyPV(mReleaseManager);
-
 
941
 
876
                    if (p.mBuildFile < 0)
942
                    if ( pvApplied == 1 )
877
                    {
943
                    {
878
                        String reason;
944
                        String reason;
879
                        switch (p.mBuildFile)
945
                        switch (p.mBuildFile)
880
                        {
946
                        {
881
                        case -1: reason = "Not reproducible"; break;
947
                        case -1: reason = "Not reproducible"; break;
Line 893... Line 959...
893
                        }
959
                        }
894
                        mLogger.error("planRelease Test Build of an unbuildable of package deleted: {}", p.mName);
960
                        mLogger.error("planRelease Test Build of an unbuildable of package deleted: {}", p.mName);
895
                        mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
961
                        mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
896
                        emailRejectedDaemonInstruction(reason,p);
962
                        emailRejectedDaemonInstruction(reason,p);
897
                    }
963
                    }
-
 
964
                    else if ( pvApplied == 2 )
-
 
965
                    {
-
 
966
                        // max 50 chars
-
 
967
                        rippleBuildExclude(p, p.mId, "Package has reached ripple field limitations", -5);
-
 
968
                    }
-
 
969
                    else if ( pvApplied == 3 )
-
 
970
                    {
-
 
971
                        // max 50 chars
-
 
972
                        rippleBuildExclude(p, p.mId, "Package has invalid change type", -5);
-
 
973
                    }
898
                }
974
                }
899
            }
975
            }
-
 
976
            
900
        }
977
        }
901
        else
978
        else
902
        {
979
        {
903
            // escrow reporting only
980
            // escrow reporting only
904
            // Report packages that are not reproducible
981
            // Report packages that are not reproducible
Line 915... Line 992...
915
                    mDependentFlag = false;
992
                    mDependentFlag = false;
916
                }
993
                }
917
            }
994
            }
918
        }
995
        }
919
    }
996
    }
920
 
997
    
921
    /** Plan the build order.
998
    /** Plan the build order.
922
     *  Assumes that a great deal of work has been done.
999
         *  Assumes that a great deal of work has been done.
923
     *  This is a stand alone method to contain the work
1000
         *  This is a stand alone method to contain the work
924
     *  
1001
         *  
925
     * @throws Exception
1002
         * @throws Exception
926
     * @throws SQLException
1003
         * @throws SQLException
-
 
1004
         */
-
 
1005
        private void planBuildOrder() throws Exception, SQLException 
-
 
1006
        {
-
 
1007
            
-
 
1008
    //TODO - Planning is not working well
-
 
1009
    /**
-
 
1010
     * Current status
-
 
1011
     * The selection of the package to build next is deeply flawed
-
 
1012
     * Currently it will select a directly planned package over a ripple - (perhaps that is good)
-
 
1013
     * 
-
 
1014
     * Currently on the buildPlan of the 'selected' package is included in the BuildOrder
-
 
1015
     * 
-
 
1016
     * The current algorithm is based on time - but all packages have zero build time ( in UTF )
-
 
1017
     * Even if this is fixed the algorithm is broken as we will select the complete build with the shortest time
-
 
1018
     * which will be the ripple of a leaf package ( perhaps that is good )
-
 
1019
     * 
-
 
1020
     * Also:
-
 
1021
     *      [Done] Need to include all packages that we can now build into the final build plan, not just the first one and its build tree
-
 
1022
     * 
-
 
1023
     *      [Done-ish]Need to generate a single package set - so that WIPS and others replace those in the final build set
-
 
1024
     *      [Done]Remove duplicates from the complete package set
-
 
1025
     *      
-
 
1026
     *      [Being Done] Need more test cases
-
 
1027
     *      
-
 
1028
     *      [Done, in the UTF] Need to report all build options, not just the selected one
-
 
1029
     *                         Data to RM may need some more info
-
 
1030
     *      
-
 
1031
     *      Cleanup the ANT build file - don't list all the release dependencies, just those needed to build the current package
-
 
1032
     *      Chances are - all we need is the new package version number
-
 
1033
     *      
-
 
1034
     *      [Fixed] If a WIP on a package that has circular dependencies is added, then the WIP will be excluded. This prevents the problem being fixed.
-
 
1035
     *              Should not exclude a WIP of a package with a circular dependency
-
 
1036
     */
-
 
1037
    
-
 
1038
            // Process remaining packages which are need to be reproduced for this baseline.
-
 
1039
            //    Determine the build file for each package
-
 
1040
            //    For daemon builds:
-
 
1041
            //      Determine the next package that can be built now
-
 
1042
            //          Sounds simple - doesn't it
-
 
1043
            //      Set its mBuildNumber to 1, all remaining reproducible packages to 2
-
 
1044
            //    For escrow builds:
-
 
1045
            //      Determine the package versions that can be built in the build iteration
-
 
1046
            //      Set their mBuildNumber to the build iteration
-
 
1047
            //      Increment the build iteration and repeat until all package versions 
-
 
1048
            //      that need to be reproduced have been assigned a build iteration        
-
 
1049
            
-
 
1050
            //
-
 
1051
            //  Generate a plan for the packages that are in the current release
-
 
1052
            //  These may be the result of a ripple going through the system 
-
 
1053
            //  or a rebuild of a missing package or the result of a merge.
-
 
1054
            //
-
 
1055
            //  This will provide our basic plan, before we consider adding new packages to the
-
 
1056
            //  mix, such as those from user WIPS and RIPPLE requests.
-
 
1057
            //  
-
 
1058
            PlanResults basicPlan = planCollection("Basic", mPackageCollection, true);
-
 
1059
            
-
 
1060
            //  Have not considered any of the WIP or RIPPLE packages
-
 
1061
            //  If any of them are in the basic plan, then we can ignore them as we will build them
-
 
1062
            //  when we build the basic plan
-
 
1063
            //
-
 
1064
            //  Determine a set of packages that will not be included if we build the basic plan
-
 
1065
            //
-
 
1066
            //  At the moment - lets assume there are none
-
 
1067
            //  What do we do ?
-
 
1068
            //      Select the first request
-
 
1069
            //      Replace the package in the released collection
-
 
1070
            //      Run the plan algorithm
-
 
1071
            //      Restore the release collection
-
 
1072
            //
-
 
1073
            if ( mDaemon )
-
 
1074
            {
-
 
1075
                //
-
 
1076
                //  Need to consider the TEST requests
-
 
1077
                //      - Valid requests will be placed first on the build order
-
 
1078
                //
-
 
1079
                mBuildOrder.clear();
-
 
1080
                for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
-
 
1081
                {
-
 
1082
                    Package p = it.next();
-
 
1083
                    if (p.mBuildFile >= 0)
-
 
1084
                    {
-
 
1085
                        mBuildOrder.add( new PlannedPackage(p,0 ) );
-
 
1086
                    }
-
 
1087
                }
-
 
1088
                
-
 
1089
                //  First attempt
-
 
1090
                //  Insert all the WIPs and RIPPLES into the buildset. 
-
 
1091
                //  Generate a plan and see how much the time is extended.
-
 
1092
                //
-
 
1093
                //  Don't modify mPackageCollection, although data in the 'Package' in the underlying packages may change
-
 
1094
                
-
 
1095
                PlanResults fullPlan = postRipplePlan("Full", basicPlan, true);
-
 
1096
                
-
 
1097
                //  Decide with plan to use
-
 
1098
                //  At the moment we have, at most two.
-
 
1099
                //      - (basic) Current Release ripples
-
 
1100
                //      - (full) Current Release + All WIPS and RIPPLES
-
 
1101
                //
-
 
1102
                //  If we have both then if the full plan is < 20% longer than the basic plan, use the full plan
-
 
1103
                //  Otherwise we use basic plan FOLLOWED by the a MODIFIED full plan (one without the natural ripples)
-
 
1104
                //  Add the planned packages into the buildOrder
-
 
1105
    
-
 
1106
                if( !basicPlan.planCollection.isEmpty() && !fullPlan.planCollection.isEmpty() )
-
 
1107
                {
-
 
1108
                    mLogger.info("Two plan selection: {} {}, {} <= {}", basicPlan.planTime,fullPlan.planTime, basicPlan.planTime * 12, fullPlan.planTime * 10);
-
 
1109
                    if ( (basicPlan.planTime * 12) <= (fullPlan.planTime * 10) )
-
 
1110
                    {
-
 
1111
                        //  Use the basic plan FOLLOWED by a plan that does not include
-
 
1112
                        //      Ripples done by the basic plan
-
 
1113
                        //      WIPs/RIPPLES done in the course of doing the basic plan
-
 
1114
    
-
 
1115
                        mBuildOrder.addAll(basicPlan.planCollection);
-
 
1116
                        fullPlan = postRipplePlan("Full-Ripples", basicPlan, false);
-
 
1117
                        mBuildOrder.addAll(fullPlan.planCollection);
-
 
1118
                        
-
 
1119
                    } else {
-
 
1120
                        //  Use the full plan
-
 
1121
                        mBuildOrder.addAll(fullPlan.planCollection);
-
 
1122
                    }
-
 
1123
                } else if (!basicPlan.planCollection.isEmpty() ) {
-
 
1124
                    // Use the basic plan
-
 
1125
                    mBuildOrder.addAll(basicPlan.planCollection);
-
 
1126
                    
-
 
1127
                } else if ( !fullPlan.planCollection.isEmpty() ) {
-
 
1128
                    // Use the full plan
-
 
1129
                    mBuildOrder.addAll(fullPlan.planCollection);
-
 
1130
                    
-
 
1131
                } else {
-
 
1132
                    // Do not have a plan
-
 
1133
                    // May have tests requests
-
 
1134
                }
-
 
1135
                
-
 
1136
                //  Now have an mBuildOrder
-
 
1137
                //  Mark the first package in the build order as the one to be built
-
 
1138
                //
-
 
1139
                Package build = ReleaseManager.NULL_PACKAGE;
-
 
1140
                if (!mBuildOrder.isEmpty()) {
-
 
1141
                    build = mBuildOrder.get(0).mPkg;
-
 
1142
                    build.mBuildFile = 1;
-
 
1143
                    
-
 
1144
                    if ( build.mForcedRippleInstruction > 0 )
-
 
1145
                    {
-
 
1146
                        mReleaseManager.markDaemonInstCompleted( build.mForcedRippleInstruction );
-
 
1147
                    }
-
 
1148
    
-
 
1149
                    if ( build.mTestBuildInstruction > 0 )
-
 
1150
                    {
-
 
1151
                        mReleaseManager.markDaemonInstInProgress( build.mTestBuildInstruction );
-
 
1152
                    }
-
 
1153
                    
-
 
1154
                    //  Now that we know which package we are building
-
 
1155
                    //      Set the previously calculated nextVersion as the packages version number
-
 
1156
                    //      Claim the version number to prevent other builds from using it. Even if doing a test build
-
 
1157
                    //
-
 
1158
                    if (build.mNextVersion != null)
-
 
1159
                    {
-
 
1160
                        mReleaseManager.claimVersion(build.mPid, build.mNextVersion + build.mExtension, mBaseline);
-
 
1161
                        build.mVersion = build.mNextVersion;
-
 
1162
                    }
-
 
1163
                }
-
 
1164
                
-
 
1165
                //
-
 
1166
                //  Massage the package collection
-
 
1167
                //      Replace WIP/TEST/RIPPLE so that the mPackageCollection is a collection of packages we would like in the release
-
 
1168
                //      Don't replace those that we can't build due to errors
-
 
1169
                //  
-
 
1170
 
-
 
1171
                //         Update packages in the basicPlan
-
 
1172
                //         Update / Add packages to the fullPlan
-
 
1173
                //
-
 
1174
                ArrayList<Package> buildCandidates = new ArrayList<Package>();
-
 
1175
                buildCandidates.addAll(mPackageCollectionTest);
-
 
1176
                buildCandidates.addAll(mPackageCollectionWip);
-
 
1177
                buildCandidates.addAll(mPackageCollectionRipple);
-
 
1178
    
-
 
1179
                for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
-
 
1180
                {
-
 
1181
                    Package p = it.next();
-
 
1182
                    if ( p.mBuildFile >= 0 )
-
 
1183
                    {
-
 
1184
                        Package pReleased = findPackage(p.mAlias);
-
 
1185
                        if ( pReleased != ReleaseManager.NULL_PACKAGE)
-
 
1186
                        {
-
 
1187
                            int index = mReleaseManager.findPackageLastIndex;
-
 
1188
                            mPackageCollection.set(index, p);
-
 
1189
                            p.mIsNotReleased = false;
-
 
1190
                        }
-
 
1191
                        else
-
 
1192
                        {
-
 
1193
                            mPackageCollection.add(p);
-
 
1194
                            p.mIsNotReleased = false;
-
 
1195
                        }
-
 
1196
                    }
-
 
1197
                }
-
 
1198
                
-
 
1199
                //
-
 
1200
                //  Report packages that are indirectly excluded
-
 
1201
                //  ie: They will not be built because one, or more, of there dependents is not buildable
-
 
1202
                //
-
 
1203
                mLogger.debug("planBuildOrder process packages which are not ripple buildable");
-
 
1204
 
-
 
1205
                 for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
-
 
1206
                 {
-
 
1207
                     BuildExclusion be = it.next();
-
 
1208
 
-
 
1209
                     for (Iterator<Package> it1 = mPackageCollection.iterator(); it1.hasNext(); )
-
 
1210
                     {
-
 
1211
                         Package p = it1.next();
-
 
1212
 
-
 
1213
                         // ensure only root cause, non test build, build exclusions are excluded
-
 
1214
                         // mBuildExclusionCollection is at this point based on
-
 
1215
                         // relevant (direct and indirect) excluded pv's in the database
-
 
1216
                         
-
 
1217
                         if ( be.compare(p.mId) && be.isARootCause() && p.mTestBuildInstruction == 0 && p.mForcedRippleInstruction == 0 )
-
 
1218
                         {
-
 
1219
                             // package is not reproducible, discard it and its consumers
-
 
1220
                             //
-
 
1221
                             mLogger.info("Excluded Package {}, {}", p.mAlias, be );                                     
-
 
1222
                             
-
 
1223
                             ArrayList<Package> toExclude = new ArrayList<Package>();
-
 
1224
                             toExclude.addAll(usedByAnyPackages(p, mPackageCollection ));
-
 
1225
                             
-
 
1226
                             //  Process packages that we need to exclude indirectly
-
 
1227
                             //
-
 
1228
                             while ( ! toExclude.isEmpty())
-
 
1229
                             {
-
 
1230
                                 Package pkg = toExclude.remove(0);
-
 
1231
                                 
-
 
1232
                                 // If this package has not been excluded (for whatever reason), than add it
-
 
1233
                                 boolean found = false;
-
 
1234
                                 for (Iterator<BuildExclusion> it2 = mBuildExclusionCollection.iterator(); it2.hasNext(); )
-
 
1235
                                 {
-
 
1236
                                     BuildExclusion buildExclusion = it2.next();
-
 
1237
                                     if (buildExclusion.compare(pkg.mId) )
-
 
1238
                                     {
-
 
1239
                                         found = true;
-
 
1240
                                         if  ( buildExclusion.isImported() )
-
 
1241
                                         {
-
 
1242
                                             // An exclusion for this package already exists
-
 
1243
                                             // If it was 'imported' from the database then 
-
 
1244
                                             // mark it as processed so that it will be persisted
-
 
1245
                                             //
-
 
1246
                                             // Otherwise it will be a new one
-
 
1247
                                             //
-
 
1248
                                             buildExclusion.setProcessed();
-
 
1249
                                         }
-
 
1250
                                         break;
-
 
1251
                                     }
-
 
1252
                                 }
-
 
1253
                                 
-
 
1254
                                 if (!found)
-
 
1255
                                 {
-
 
1256
                                     BuildExclusion buildExclusion = new BuildExclusion(pkg.mId, p.mId, null, p.mTestBuildInstruction);
-
 
1257
                                     it.add(buildExclusion);
-
 
1258
                                     mLogger.info("Indirectly Excluded Package {}", pkg.mAlias);  
-
 
1259
 
-
 
1260
                                     ArrayList<Package> usedBy = usedByAnyPackages(p, mPackageCollectionAll );
-
 
1261
                                     toExclude.addAll(usedBy);
-
 
1262
                                 }
-
 
1263
                             }
-
 
1264
                         }
-
 
1265
                     }
-
 
1266
                 }
-
 
1267
                
-
 
1268
                //
-
 
1269
                //  To fit in with the old algorithm ( ie: could be improved )
-
 
1270
                //  Insert marks into all packages
-
 
1271
                //  Not sure exactly why - Its used in the generation of the ant build file
-
 
1272
                //                     Want to set mNoBuildReason, mBuildFile
-
 
1273
                //
-
 
1274
                //      Package we have selected to build: 0     , 1
-
 
1275
                //      Package we could have built      : 0     , 2
-
 
1276
                //      Packages we can't build          : reason, 3
-
 
1277
                //      Packages that are OK             : 3     , 3
-
 
1278
                //      ????                             : 0     , 3
-
 
1279
                
-
 
1280
                for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
-
 
1281
                {
-
 
1282
                    Package p = it.next();
-
 
1283
                    if (p == build ) {
-
 
1284
                        p.mNoBuildReason = 0;
-
 
1285
                        p.mBuildFile = 1;
-
 
1286
                    } 
-
 
1287
                    else if ( p.mBuildFile < 0 )
-
 
1288
                    {
-
 
1289
                        p.mNoBuildReason = p.mBuildFile;
-
 
1290
                        p.mBuildFile = 3;
-
 
1291
                    }
-
 
1292
                    else if (p.mBuildReason != null)
-
 
1293
                    {
-
 
1294
                        p.mNoBuildReason = 0;
-
 
1295
                        p.mBuildFile = 2;
-
 
1296
                    }
-
 
1297
                    else
-
 
1298
                    {
-
 
1299
                        p.mNoBuildReason = 0;
-
 
1300
                        p.mBuildFile = 3;
-
 
1301
                    }
-
 
1302
                }
-
 
1303
    
-
 
1304
            }
-
 
1305
            else
-
 
1306
            {
-
 
1307
                //  Escrow
-
 
1308
                //  The basic plan is the escrow build order
-
 
1309
                mBuildOrder = basicPlan.planCollection;
-
 
1310
            }
-
 
1311
    
-
 
1312
            mLogger.error("Final Plan");
-
 
1313
            for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
-
 
1314
            {
-
 
1315
                PlannedPackage p = it.next();
-
 
1316
                mLogger.error("Plan: {} {} {}", p.mBuildLevel, p.mPkg.mAlias, p.mPkg.mId);
-
 
1317
            }
-
 
1318
               
-
 
1319
    
-
 
1320
        }
-
 
1321
 
-
 
1322
    /** Internal class to contain intermediate results
927
     */
1323
     */
-
 
1324
    class PlanResults {
-
 
1325
        int planTime = 0;
-
 
1326
        ArrayList<PlannedPackage> planCollection = new ArrayList<PlannedPackage>(); 
-
 
1327
    }
-
 
1328
 
-
 
1329
    /**
-
 
1330
     * Process a collection of packages and generate a collection of package plans
928
    private void planBuildOrder() throws Exception, SQLException {
1331
     * A package plan is a collection of packages that can be built
-
 
1332
     *      The first item in the list is a package that can be built right now
-
 
1333
     *      Other items in the list will be packages that can be built now or will need to be built as the result
-
 
1334
     *      of a ripple
-
 
1335
     *      
-
 
1336
     * The method will be called multiple times so that we can evaluate different plans
-
 
1337
     * The underling packages will have data and flags that will need to be rested before a calculation      
-
 
1338
     *
-
 
1339
     * @param name - Name of the plan
-
 
1340
     * @param packageCollection - Base collection of packages to plan
-
 
1341
     * @param mode - true: Include 'Ripples'
-
 
1342
     * 
-
 
1343
     * @return
-
 
1344
     */
-
 
1345
    private PlanResults planCollection(String name, ArrayList<Package> packageCollection, boolean mode)
-
 
1346
    {
-
 
1347
        ArrayList<PlannedPackage> ripplePlan = new ArrayList<PlannedPackage>();
-
 
1348
        PlanResults results = new PlanResults();
929
 
1349
 
930
        // Process remaining packages which are need to be reproduced for this baseline.
-
 
931
        //    Determine the build file for each package
1350
        //  Reset flags used in the calculations
932
        //    For daemon builds:
-
 
933
        //      Determine the first package that can be built now, this means the first package 
-
 
934
        //      not dependent upon packages also to be built.
-
 
935
        //      Set its mBuildNumber to 1, all remaining reproducible packages to 2
-
 
936
        //      Add buildable packages to mBuildableCollection
1351
        Package.resetProcessed(packageCollection);
937
        //    For escrow builds:
-
 
938
        //      Determine the package versions that can be built in the build iteration
-
 
939
        //      Set their mBuildNumber to the build iteration
-
 
940
        //      Increment the build iteration and repeat until all package versions 
-
 
941
        //      that need to be reproduced have been assigned a build iteration        
-
 
942
        
1352
        
-
 
1353
        //  Exclude all packages that cannot be built and all packages that depend on them
943
        if ( mDaemon )
1354
        //      First find packages to be directly excluded
-
 
1355
        ArrayList<Package>exclude = new ArrayList<Package>();
-
 
1356
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
944
        {
1357
        {
-
 
1358
            Package p = it.next();
-
 
1359
            if ( p.mBuildFile == -8 ) {
-
 
1360
 
945
            // Sort the build order such that the unit tests are sorted by instruction id 
1361
                //  Mark SDK or Pegged so that we don't build them, but can build their dependents
-
 
1362
                p.mProcessed = true;
-
 
1363
                p.mIsProcessed = true;
-
 
1364
                mLogger.error("SDK/Peg Exclude: {}", p);
-
 
1365
                
-
 
1366
            } else if (p.mBuildFile < 0 ) {
-
 
1367
                exclude.add(p);
-
 
1368
                mLogger.error("Direct Exclude: {}", p);
-
 
1369
                
-
 
1370
            }
-
 
1371
        }
-
 
1372
        
946
            //  and placed at the head of the list. This is an attempt to have the oldest 
1373
        //  Exclude packages that have failed to be built
-
 
1374
        //      These are recorded in mBuildExclusionCollection
-
 
1375
        for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
-
 
1376
        {
947
            //  unit tests at the head of the list.
1377
            BuildExclusion be = it.next();
-
 
1378
            if ( be.isABuildError() )
948
            //
1379
            {
-
 
1380
                for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
-
 
1381
                {
949
            //  The order of all other elements is preserved
1382
                    Package p = it1.next();
950
            //  The order of the other elements is basically
1383
                    if (p.mBuildFile >= 0 && p.mId == be.mId) {
951
            //      planned - ordered by modified date-time
1384
                        p.mBuildFile  = -3;
952
            //      others  - order by pv_id
1385
                        exclude.add(p);
-
 
1386
                        break;
-
 
1387
                    }
-
 
1388
                }
953
            //
1389
            }
-
 
1390
        }
-
 
1391
 
-
 
1392
        
-
 
1393
        //  Process the list of packages to be excluded
-
 
1394
        //  Add to the list packages that depend on the excluded package that have not already been excluded
-
 
1395
        while( !exclude.isEmpty() )
-
 
1396
        {
954
            Package.setSequence(mPackageCollection);
1397
            Package p = exclude.remove(0);
-
 
1398
            p.mProcessed = true;
-
 
1399
            p.mIsProcessed = true;
955
            Collections.sort(mPackageCollection, Package.UnitTestComparator);
1400
            mLogger.error("planCollection package not buildable {}", p.mName);
-
 
1401
            
-
 
1402
            for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
-
 
1403
            {
-
 
1404
                Package pkg = it1.next();
-
 
1405
                if (pkg.mProcessed) {
-
 
1406
                    continue;
-
 
1407
                }
-
 
1408
                
-
 
1409
                for (Iterator<String> it = pkg.mDependencyCollection.iterator(); it.hasNext(); )
-
 
1410
                {
-
 
1411
                    String alias = it.next();
-
 
1412
                    if ( p.mAlias.compareTo( alias ) == 0 ) {
-
 
1413
                        exclude.add(pkg);
-
 
1414
                    }
-
 
1415
                }
-
 
1416
            }
956
        }
1417
        }
957
        
1418
        
-
 
1419
        //  Now have a collection of packages with those that we cannot build have been marked
-
 
1420
        //  Process the list and determine packages that we can build right now
-
 
1421
        //      ie: they have not been excluded, have not already been discovered and do not depend on any package in the collection
-
 
1422
        //      Continue to do this until all packages have been extracted
-
 
1423
        //      Allocate build levels as we go
-
 
1424
        //
958
        boolean allProcessed = false;
1425
        boolean allProcessed = false;
959
        int buildFile = 1;
1426
        int buildLevel = 1;
960
 
1427
 
961
        do
1428
        do
962
        {
1429
        {
-
 
1430
            //
-
 
1431
            //  Create the mBuildOrder collection
-
 
1432
            //      Same for both Daemon and Escrow modes
-
 
1433
            //      Will have package build order and build level
963
            boolean allDependenciesProcessed = true;
1434
            boolean allDependenciesProcessed = true;
964
            do
1435
            do
965
            {
1436
            {
966
                // assume all dependencies have been processed
-
 
967
                allDependenciesProcessed = true;
1437
                allDependenciesProcessed = true;
968
 
-
 
969
                for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1438
                for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
970
                {
1439
                {
971
                    Package p = it.next();
1440
                    Package p = it.next();
-
 
1441
                    
-
 
1442
                    //  Skip packages that have been processed - have determined build order, or cannot build
-
 
1443
                    if (p.mIsProcessed) {
-
 
1444
                        continue;
-
 
1445
                    }
972
 
1446
 
973
                    if ( (  mDaemon && ( ( !p.mDirectlyPlanned && !p.mIndirectlyPlanned ) || p.mBuildFile < 0 ) ) ||
1447
                    // Package yet to be processed and
974
                         ( !mDaemon && p.mBuildFile == -2 ) )
1448
                    //      Daemon mode: Could be built
-
 
1449
                    //      Escrow mode: Can be reproduced
-
 
1450
                    boolean canBeBuiltNow = true;
-
 
1451
                    boolean allDependenciesForThisPackageProcessed = true;
-
 
1452
 
-
 
1453
                    //  Scan the packages dependencies
-
 
1454
                    for ( Iterator<Package> it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
975
                    {
1455
                    {
976
                        // Daemon: Flag packages with no build requirement as processed
1456
                        // Daemon: Flag packages with no build requirement as processed
977
                        // Escrow: Flag packages with a foreign build environment as processed
1457
                        // Escrow: Flag packages with a foreign build environment as processed
978
                        p.mProcessed = true;
1458
                        p.mProcessed = true;
979
                        mLogger.info("planRelease package has no build requirement {}", p.mName);            
1459
                        mLogger.info("planRelease package has no build requirement {}", p.mName);            
Line 984... Line 1464...
984
                        //  Daemon mode: Has a build requirement
1464
                        //  Daemon mode: Has a build requirement
985
                        //  Escrow mode: Can be reproduced
1465
                        //  Escrow mode: Can be reproduced
986
                        boolean canBeBuiltNow = true;
1466
                        boolean canBeBuiltNow = true;
987
                        boolean allDependenciesForThisPackageProcessed = true;
1467
                        boolean allDependenciesForThisPackageProcessed = true;
988
 
1468
 
989
                        //  Scan the packages dependencies
1469
                        if ( !dependency.mProcessed )
990
                        for ( Iterator<Package> it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
-
 
991
                        {
1470
                        {
992
                            Package dependency = it2.next();
1471
                            Package dependency = it2.next();
993
 
1472
 
994
                            if ( !dependency.mProcessed )
1473
                            if ( !dependency.mProcessed )
995
                            {
1474
                            {
Line 1014... Line 1493...
1014
                                canBeBuiltNow = false;
1493
                                canBeBuiltNow = false;
1015
                                mLogger.info("planRelease package cannot be built in this iteration {}", p.mName);
1494
                                mLogger.info("planRelease package cannot be built in this iteration {}", p.mName);
1016
                                break;
1495
                                break;
1017
                            }
1496
                            }
1018
                        }
1497
                        }
-
 
1498
                        else if (  (  mDaemon && (   dependency.mBuildFile == 0 ) ||  (dependency.mBuildFile == buildLevel)) 
-
 
1499
                                || ( !mDaemon && ( ( dependency.mBuildFile == 0 ) ||
-
 
1500
                                                       ( dependency.mBuildFile == buildLevel &&
-
 
1501
                                                       ( !p.haveSameBuildStandards(dependency)  ) ) ) ) )
-
 
1502
                        {
-
 
1503
                            // Can be built - yet
-
 
1504
                            // Daemon mode:
-
 
1505
                            //    This processed dependency has not been assigned to a build iteration
-
 
1506
                            //    This processed dependency has been assigned to this build iteration
-
 
1507
                            // Escrow mode: This package cannot be built now if
-
 
1508
                            //    This processed dependency has not been assigned to a build iteration or
-
 
1509
                            //    This processed dependency has been assigned to this build iteration, but the 
-
 
1510
                            //    build standards of the package and this dependency prevent the package being
-
 
1511
                            //    built in this iteration.   
-
 
1512
                            canBeBuiltNow = false;
-
 
1513
                            mLogger.info("planRelease package cannot be built in this iteration {}", p.mName);
-
 
1514
                            break;
-
 
1515
                        }
-
 
1516
                    }
1019
 
1517
 
-
 
1518
                    //  All dependencies have been processed. May be able to build this package
-
 
1519
                    //      Add the package to the build order list
-
 
1520
                    //
1020
                        if (allDependenciesForThisPackageProcessed)
1521
                    if (allDependenciesForThisPackageProcessed)
-
 
1522
                    {
-
 
1523
                        p.mProcessed = true;
-
 
1524
                        if ( canBeBuiltNow )
1021
                        {
1525
                        {
1022
                            p.mProcessed = true;
1526
                            p.mProcessed = true;
1023
 
1527
 
1024
                            if ( mDaemon )
1528
                            if ( mDaemon )
1025
                            {
1529
                            {
Line 1049... Line 1553...
1049
                            }
1553
                            }
1050
                        }
1554
                        }
1051
                    }
1555
                    }
1052
                }
1556
                }
1053
            } while( !allDependenciesProcessed );
1557
            } while( !allDependenciesProcessed );
1054
 
-
 
1055
            //
1558
            
1056
            //  Daemon Mode:
-
 
1057
            //  Locate all packages that we would like to build and
1559
            //  Have process all the packages that we can at the moment
1058
            //      Calculate new version - report errors
1560
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1059
            //      Determine a package we would like to build
1561
            //      These will be done at a different build-level
1060
            //
1562
            //  
1061
            if ( mDaemon )
1563
            allProcessed = true;
-
 
1564
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1062
            {
1565
            {
1063
                for (Iterator<Package> it = mBuildOrder.iterator(); it.hasNext(); )
1566
                Package p = it.next();
-
 
1567
                if ( !  p.mIsProcessed )
1064
                {
1568
                {
-
 
1569
                    // more build files are required
1065
                    Package p = it.next();
1570
                    allProcessed = false;
-
 
1571
                    mLogger.info("planRelease more build files are required for {}", p.mName);
-
 
1572
                    break;
-
 
1573
                }
-
 
1574
            }
1066
 
1575
 
-
 
1576
            buildLevel++;
-
 
1577
            if (buildLevel % 500 == 0 ) {
-
 
1578
                mLogger.error("planRelease. Too many build levels {}", buildLevel);
-
 
1579
            }
-
 
1580
        } while( !allProcessed );
-
 
1581
 
-
 
1582
        //  Now we have a collection packages that we can build right now
-
 
1583
        //      The packages currently have a build level set into mBuildFile
-
 
1584
        //
-
 
1585
        if (mDaemon)
-
 
1586
        {
-
 
1587
            //  Determine if we have a reason to build anything in this collection of buildable packages
-
 
1588
            //  Reset the calculated buildLevel - It will be calculated again
-
 
1589
            //
-
 
1590
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
-
 
1591
            for (Iterator<PlannedPackage> it = results.planCollection.iterator(); it.hasNext(); )
-
 
1592
            {
-
 
1593
                PlannedPackage p = it.next();
-
 
1594
                p.mBuildLevel = 0;
-
 
1595
                
1067
                    if ( p.mProcessed && p.mBuildFile == 1 )
1596
                if (p.mPkg.mBuildReason != null) {
-
 
1597
                    if (mode || ( !mode && p.mPkg.mBuildReason != BuildReason.Ripple ))
1068
                    {
1598
                    {
1069
                        p.mBuildFile = buildFile;
1599
                        p.mBuildFile = buildFile;
1070
                        mLogger.info("planRelease 2 set mBuildFile to {} for package {}", buildFile, p.mAlias );
1600
                        mLogger.info("planRelease 2 set mBuildFile to {} for package {}", buildFile, p.mAlias );
1071
 
1601
 
1072
                        if ( buildFile == 1 )
1602
                        if ( buildFile == 1 )
Line 1110... Line 1640...
1110
                            mLogger.info("planRelease package has future (downgraded) build requirement {} {}", p.mName, buildFile);              
1640
                            mLogger.info("planRelease package has future (downgraded) build requirement {} {}", p.mName, buildFile);              
1111
                        }
1641
                        }
1112
                    }
1642
                    }
1113
                }
1643
                }
1114
            }
1644
            }
1115
 
1645
            
1116
            // are more build files required
1646
            //  Need (would like to) build stuff
-
 
1647
            //  Determine the packages that we need to build and the time that it will take
1117
            allProcessed = true;
1648
            //
1118
 
-
 
1119
            if (mDaemon)
1649
            if ( !toBuild.isEmpty() )
1120
            {
1650
            {
1121
                //  Recalculate mBuildOrder
1651
                results.planTime = 0;
1122
                //  Remove any packages that cannot be built due to errors encountered during
-
 
1123
                //  the use of applyPV()
1652
                             
1124
                //
1653
                
1125
                ArrayList<Package> mTempBuildOrder = new ArrayList<Package>();
1654
                //  Need to add elements to the end of the list while processing
1126
 
-
 
1127
                //  Seed mBuildOrder with packages that were prime buildable candidates
1655
                //  Sum the buildTimes of the packages that we add to the list
1128
                //  This includes test builds
1656
                while ( ! toBuild.isEmpty())
1129
                //      Insert the active build at the head of the list - should only be one
-
 
1130
                //
-
 
1131
                for (Iterator<Package> it = mBuildOrder.iterator(); it.hasNext(); )
-
 
1132
                {
1657
                {
1133
                    Package p = it.next();
1658
                    PlannedPackage pkg = toBuild.remove(0);
-
 
1659
                    
1134
                    if(p.mBuildFile > 0)
1660
                    if (pkg.mBuildLevel > 100 ) {
-
 
1661
                        mLogger.error("Circular dependency detected - not handled well");
-
 
1662
                        break;
-
 
1663
                    }
-
 
1664
                    
-
 
1665
                    if ( ! ripplePlan.contains( pkg ))
1135
                    {
1666
                    {
1136
                        mTempBuildOrder.add(p);
1667
                        ripplePlan.add(pkg);
-
 
1668
                        results.planTime += pkg.mPkg.mBuildTime;
1137
                    }
1669
                    }
-
 
1670
                    
-
 
1671
                    ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection, pkg.mBuildLevel + 1);
-
 
1672
                    toBuild.addAll(usedBy);
1138
                }
1673
                }
-
 
1674
                
1139
                mBuildOrder = mTempBuildOrder;
1675
                //  Sort the packages by buildOrder and buildTime
1140
 
-
 
1141
 
-
 
-
 
1676
                Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
-
 
1677
                
-
 
1678
                mLogger.info("Plan Build {} Time: {}", name, results.planTime);
1142
                for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1679
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1143
                {
1680
                {
1144
                    Package p = it.next();
1681
                    PlannedPackage p = it.next();
-
 
1682
                    mLogger.info("Plan: {} {}", p.mBuildLevel, p.mPkg.mAlias);
-
 
1683
                }
-
 
1684
            }
-
 
1685
            
-
 
1686
            //  Daemon mode: Returning calculated plan
-
 
1687
            results.planCollection = ripplePlan;
-
 
1688
        }
-
 
1689
        
-
 
1690
        return results;
-
 
1691
    }
1145
 
1692
 
-
 
1693
    /** Generate a plan based on a modified set of packages
-
 
1694
     * 
-
 
1695
     * @param name      - Name of the plan
-
 
1696
     * @param basicPlan - basicPlan
-
 
1697
     * @param mode      - True: Include natural ripples and WIPS/RIPPLES that would have been done
1146
                    if ( p.mBuildFile < 0 || ( !p.mDirectlyPlanned && !p.mIndirectlyPlanned ) )
1698
     *                          as a part of the basic plan
-
 
1699
     * @return
-
 
1700
     */
-
 
1701
    private PlanResults postRipplePlan(String name, PlanResults basicPlan, boolean mode) {
-
 
1702
 
-
 
1703
        ArrayList<Package> fullPlanCollection = new ArrayList<Package>(mPackageCollection);
-
 
1704
        ArrayList<Package> buildCandidates = new ArrayList<Package>();
-
 
1705
        buildCandidates.addAll(mPackageCollectionWip);
-
 
1706
        buildCandidates.addAll(mPackageCollectionRipple);
-
 
1707
        
-
 
1708
        if ( !buildCandidates.isEmpty() )
-
 
1709
        {
-
 
1710
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
-
 
1711
            {
-
 
1712
                Package p = it.next();
-
 
1713
                if (p.mBuildFile >= 0)
-
 
1714
                {
-
 
1715
                    if (!mode)
1147
                    {
1716
                    {
1148
                        // at this point...
1717
                        // at this point...
1149
                        // only 1 package with a build requirement has a mBuildFile of 1,
1718
                        // only 1 package with a build requirement has a mBuildFile of 1,
1150
                        // all other packages with a build requirement have an mBuildFile of 2
1719
                        // all other packages with a build requirement have an mBuildFile of 2
1151
                        // give packages with no build requirement, reproducible or not, an mBuildFile of 3
1720
                        // give packages with no build requirement, reproducible or not, an mBuildFile of 3
1152
                        p.mNoBuildReason = p.mBuildFile;
1721
                        p.mNoBuildReason = p.mBuildFile;
1153
                        p.mBuildFile = 3;
1722
                        p.mBuildFile = 3;
1154
                        mLogger.info("planRelease 1 set mBuildFile to 3 for package {}", p.mAlias );
1723
                        mLogger.info("planRelease 1 set mBuildFile to 3 for package {}", p.mAlias );
1155
                    }
1724
                    }
-
 
1725
                    
-
 
1726
                    mLogger.info("Test Plan with {}", p.mAlias);
-
 
1727
                    Package foundInRelease = mReleaseManager.findPackage(p.mAlias, fullPlanCollection);
-
 
1728
                    int foundIndex = mReleaseManager.findPackageLastIndex;
-
 
1729
                    if (foundInRelease == ReleaseManager.NULL_PACKAGE)
-
 
1730
                    {
-
 
1731
                        fullPlanCollection.add(p);
-
 
1732
                    }
-
 
1733
                    else
-
 
1734
                    {
-
 
1735
                        fullPlanCollection.set(foundIndex, p);
-
 
1736
                    }
-
 
1737
                    
-
 
1738
                    Package.resetCircularDependency (fullPlanCollection);
-
 
1739
                    if ( p.hasCircularDependency( fullPlanCollection ) )
-
 
1740
                    {
-
 
1741
                        mLogger.info("planRelease circular dependency detected {}", p.mAlias);
-
 
1742
                        
-
 
1743
                        //  Force this package to be marked as having a circular dependency - even if its been excluded
-
 
1744
                        p.mBuildFile = 0;
-
 
1745
                        
-
 
1746
                        // Exclude the package
-
 
1747
                        // max 50 chars
-
 
1748
                        rippleBuildExclude(p, p.mId, "Package has circular dependency", -6);
-
 
1749
                    }
1156
                }
1750
                }
1157
            }
1751
            }
1158
            else
1752
            
-
 
1753
        }
-
 
1754
        return planCollection(name, fullPlanCollection, mode);
-
 
1755
    }
-
 
1756
 
-
 
1757
    /** 
-
 
1758
     *  Calculate a collection of packages that actively use the named package
-
 
1759
     *  A consumer package does NOT use the named package,
-
 
1760
     *      If the consumer is an SDK or is Pegged
-
 
1761
     *      If the consumer is marked as advisoryRipple
-
 
1762
     *      If the consumer cannot be built
-
 
1763
     *   
-
 
1764
     * @param pkg - Package to process
-
 
1765
     * @param planCollection - collection of packages to scan
-
 
1766
     * @param rippleOrder - Set the ripple oder, if >= 0
-
 
1767
     *
-
 
1768
     * @return A collection of packages that actively 'use' the specified package
-
 
1769
 
-
 
1770
     */
-
 
1771
    private ArrayList<PlannedPackage> usedByPackages(PlannedPackage pkg, ArrayList<PlannedPackage> planCollection, int rippleOrder) {
-
 
1772
        
-
 
1773
        ArrayList<PlannedPackage> usedBy = new ArrayList<PlannedPackage>();
-
 
1774
        
-
 
1775
        for (Iterator<PlannedPackage> it = planCollection.iterator(); it.hasNext(); )
-
 
1776
        {
-
 
1777
            PlannedPackage p = it.next();
-
 
1778
            
-
 
1779
            //  Is this package 'actively used' in the current build
-
 
1780
            if (p.mPkg.mBuildFile >= 0)
1159
            {
1781
            {
1160
                // this is escrow mode centric
-
 
1161
                for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1782
                for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); it2.hasNext(); )
1162
                {
1783
                {
1163
                    Package p = it.next();
1784
                    Package p = it.next();
1164
 
1785
 
1165
                    if ( p.mBuildFile == 0 )
1786
                    if ( p.mBuildFile == 0 )
1166
                    {
1787
                    {
Line 1168... Line 1789...
1168
                        allProcessed = false;
1789
                        allProcessed = false;
1169
                        mLogger.info("planRelease more build files are required for {}", p.mName);
1790
                        mLogger.info("planRelease more build files are required for {}", p.mName);
1170
                        break;
1791
                        break;
1171
                    }
1792
                    }
1172
                }
1793
                }
1173
 
-
 
1174
                buildFile++;
-
 
1175
            }
1794
            }
-
 
1795
        }
-
 
1796
        
1176
        } while( !allProcessed );
1797
        return usedBy;
1177
    }
1798
    }
-
 
1799
    
-
 
1800
    /** 
-
 
1801
     *  Calculate a collection of packages that use the named package
-
 
1802
     *   
-
 
1803
     * @param pkg - Package to process
-
 
1804
     * @param pkgCollection - collection of packages to scan
-
 
1805
     *
-
 
1806
     * @return A collection of packages that actively 'use' the specified package
1178
 
1807
 
-
 
1808
     */
-
 
1809
    private ArrayList<Package> usedByAnyPackages(Package pkg, ArrayList<Package> pkgCollection) {
-
 
1810
        
-
 
1811
        ArrayList<Package> usedBy = new ArrayList<Package>();
-
 
1812
        
-
 
1813
        for (Iterator<Package> it = pkgCollection.iterator(); it.hasNext(); )
-
 
1814
        {
-
 
1815
            Package p = it.next();
-
 
1816
            
-
 
1817
            for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
-
 
1818
            {
-
 
1819
                String alias = it2.next();
-
 
1820
                if (  pkg.mAlias.compareTo( alias ) == 0  ) {
-
 
1821
                    usedBy.add(p);
-
 
1822
                    break;
-
 
1823
                }
-
 
1824
            }
-
 
1825
        }
-
 
1826
        
-
 
1827
        return usedBy;
-
 
1828
    }
1179
 
1829
 
1180
    /** Determine if a given PVID is a member of the current release.
1830
    /** Determine if a given PVID is a member of the current release.
1181
     *  Used to determine if a package dependency is out of date
1831
     *  Used to determine if a package dependency is out of date
1182
     * 
1832
     * 
1183
     * @param dpvId
1833
     * @param dpvId
1184
     * @return true - specified pvid is a full member of the Release
1834
     * @return true - specified pvid is a full member of the Release
1185
     */
1835
     */
1186
    private boolean isInRelease(Integer dpvId) {
1836
    private boolean isInRelease(Integer dpvId) {
1187
        
1837
        
1188
        boolean found = false;
1838
        boolean inRelease = false;
1189
 
1839
 
1190
        for ( Iterator<Integer> it4 = mReleasedPvIDCollection.iterator(); it4.hasNext(); )
1840
        for ( Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1191
        {
1841
        {
1192
            Integer pvId = it4.next();
1842
            Package p = it.next();
1193
 
1843
 
1194
            if ( pvId.compareTo(dpvId) == 0 )
1844
            if ( p.mId == dpvId )
1195
            {
1845
            {
1196
                found = true;
1846
                inRelease = ! p.mIsNotReleased;
1197
                break;
1847
                break;
1198
            }
1848
            }
1199
        }
1849
        }
1200
        return found;
1850
        return inRelease;
1201
    }
1851
    }
1202
 
1852
 
1203
 
1853
 
1204
    /**reports what change in build exceptions happens as part of planRelease
1854
    /** Reports what change in build exceptions happens as part of planRelease
-
 
1855
     * 
-
 
1856
     *  There are three types of exceptions
-
 
1857
     *      PlanError - These may be removed, if the error was not seen in the last plan
-
 
1858
     *      BuildErrors - These we persist
-
 
1859
     *      IndirectErrors - Packages that depend on a Plan or Build errors
1205
     */
1860
     */
1206
    public void reportChange() throws SQLException, Exception
1861
    public void reportChange() throws SQLException, Exception
1207
    {
1862
    {
1208
        int counter = 0;
1863
        int counter = 0;
1209
        for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
1864
        for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
1210
        {
1865
        {
1211
            BuildExclusion buildExclusion = it.next();
1866
            BuildExclusion buildExclusion = it.next();
1212
 
1867
 
-
 
1868
            //  Skip 'Processed' entries
-
 
1869
            //  These will be the result of a PlanError that we have seen again
-
 
1870
            //
-
 
1871
            //  PlanErrors - Add/Remove as detected
-
 
1872
            //  BuildErrors - Persist. 
-
 
1873
            //  IndirectErrors - Add/Remove as detected
-
 
1874
            //  
-
 
1875
            
1213
            if ( !buildExclusion.isProcessed() )
1876
            if ( !buildExclusion.isABuildError() )
1214
            {
1877
            {
1215
                if (buildExclusion.isImported() && ! buildExclusion.isARootCause() ) {
1878
                if (buildExclusion.isImported() && ! buildExclusion.isARootCause() ) {
1216
                    // Remove from the exclusion list
1879
                    // Remove from the exclusion list
1217
                    buildExclusion.includeToBuild(mReleaseManager, mBaseline);
1880
                    buildExclusion.includeToBuild(mReleaseManager, mBaseline);
1218
                    mLogger.error("reportChange remove unused exclusion: {}", buildExclusion.info());
1881
                    mLogger.error("reportChange remove unused exclusion: {}", buildExclusion.info());
Line 1332... Line 1995...
1332
        }
1995
        }
1333
    }
1996
    }
1334
 
1997
 
1335
    /**
1998
    /**
1336
     * Find Package by package alias
1999
     * Find Package by package alias
1337
     * Searches the complete package collection
2000
     * Searches the released package collection
1338
     * @param   alias               - alias of package to locate
2001
     * @param   alias               - alias of package to locate
1339
     * @return  Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
2002
     * @return  Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
1340
     */
2003
     */
1341
    public Package findPackage(String alias)
2004
    public Package findPackage(String alias)
1342
    {
2005
    {
Line 1345... Line 2008...
1345
        Package retVal = mReleaseManager.findPackage(alias, mPackageCollection);
2008
        Package retVal = mReleaseManager.findPackage(alias, mPackageCollection);
1346
 
2009
 
1347
        mLogger.info("findPackage returned {}", retVal.mName);
2010
        mLogger.info("findPackage returned {}", retVal.mName);
1348
        return retVal;
2011
        return retVal;
1349
    }
2012
    }
1350
 
2013
    
1351
    /**
2014
    /**
1352
     * Sets the mBuildFile to -5 (indirectly dependent on package versions which are not reproducible) 
2015
     * Sets the mBuildFile to the specified value for the package
1353
     * for the package and all dependent packages 
2016
     * Does not handle dependent packages - this will be done later  
-
 
2017
     *  
1354
     * @param p             The package being excluded 
2018
     * @param p             The package being excluded 
1355
     * @param rootPvId      The PVID of the package that is causing the exclusion. Null or -ve values are special
2019
     * @param rootPvId      The PVID of the package that is causing the exclusion. Null or -ve values are special
1356
     *                      This package is the root cause, -2: Excluded by Ripple Stop 
2020
     *                      This package is the root cause, -2: Excluded by Ripple Stop 
1357
     *                   
-
 
1358
     * @param rootCause     Text message. Max 50 characters imposed by RM database 
2021
     * @param rootCause     Text message. Max 50 characters imposed by RM database 
1359
     * @param list          If not null, add build exclusion to specified list, else use default(mBuildExclusionCollection) list. Allows insertions while iterating the list.
-
 
1360
     * @param be            If not null, process provided BuildExclusion element, otherwise find-existing/create a BuildExclusion element
-
 
1361
     * @param dependentToo  True: Exclude all packages that depend on the excluded package 
2022
     * @param reason        New value for mBuildFile
1362
     */
2023
     */
1363
    private void rippleBuildExclude(Package p, int rootPvId, String rootCause, ListIterator<BuildExclusion> list, BuildExclusion be, boolean dependentToo )
2024
    private void rippleBuildExclude(Package p, int rootPvId, String rootCause, int reason )
1364
    {
2025
    {
1365
        mLogger.debug("rippleBuildExclude");
2026
        mLogger.debug("rippleBuildExclude");
-
 
2027
     
1366
        if ( p.mBuildFile == 0 || p.mBuildFile == 1 )
2028
        if ( p.mBuildFile == 0 || p.mBuildFile == 1 )
1367
        {
2029
        {
1368
            p.mBuildFile = -5;
2030
            p.mBuildFile = -5;
1369
            mLogger.info("rippleBuildExclude set mBuildFile to -5 for package {}", p.mAlias );
2031
            mLogger.info("rippleBuildExclude set mBuildFile to -5 for package {}", p.mAlias );
1370
 
2032
 
1371
            if ( be != null )
2033
                if ( buildExclusion.compare(p.mId, rootPvId, rootCause))
1372
            {
2034
                {
1373
                be.setProcessed();
2035
                    buildExclusion.setProcessed();
-
 
2036
                    found = true;
-
 
2037
                    break;
-
 
2038
                }
1374
            }
2039
            }
-
 
2040
 
1375
            else
2041
            if (!found)
1376
            {
2042
            {
1377
                //  If no be item has been provided, then scan the complete collection looking for a matching item
2043
                // Entry not found in the mBuildExclusionCollection. Its a new error
-
 
2044
                // 
1378
                //  If found, process it, else add it (unprocessed)
2045
                // Mark all occurrences for this package as processed
1379
                boolean found = false;
2046
                // These will be superseded by a new build exclusion entry
1380
                for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
2047
                for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
1381
                {
2048
                {
1382
                    BuildExclusion buildExclusion = it.next();
2049
                    BuildExclusion buildExclusion = it.next();
1383
 
2050
 
1384
                    if ( buildExclusion.compare(p.mId, rootPvId, rootCause))
2051
                    if ( buildExclusion.compare(p.mId))
1385
                    {
2052
                    {
1386
                        buildExclusion.setProcessed();
2053
                        buildExclusion.setProcessed();
1387
                        found = true;
-
 
1388
                        break;
-
 
1389
                    }
2054
                    }
1390
                }
2055
                }
1391
 
2056
 
1392
                if (!found)
-
 
1393
                {
-
 
1394
                    // Entry not found in the mBuildExclusionCollection
-
 
1395
                    // Mark all occurrences for this package as processed
-
 
1396
                    // These will be superseded by a new build exclusion entry
-
 
1397
                    for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
-
 
1398
                    {
-
 
1399
                        BuildExclusion buildExclusion = it.next();
-
 
1400
 
-
 
1401
                        if ( buildExclusion.compare(p.mId))
2057
                //  Add the new build exclusion to a list
1402
                        {
-
 
1403
                            buildExclusion.setProcessed();
-
 
1404
                        }
-
 
1405
                    }
-
 
1406
 
-
 
1407
                    BuildExclusion buildExclusion = new BuildExclusion(p.mId, rootPvId, rootCause, p.mTestBuildInstruction);
2058
                BuildExclusion buildExclusion = new BuildExclusion(p.mId, rootPvId, rootCause, p.mTestBuildInstruction);
1408
 
-
 
1409
                    //
-
 
1410
                    //  Add the new build exclusion to a list
-
 
1411
                    //    Either the default list or a user-specified list
-
 
1412
                    if ( list == null )
-
 
1413
                    {
-
 
1414
                        mBuildExclusionCollection.add(buildExclusion);
2059
                mBuildExclusionCollection.add(buildExclusion);
1415
                    }
-
 
1416
                    else
-
 
1417
                    {
-
 
1418
                        // must use the ListIterator interface to add to the collection whilst iterating through it
-
 
1419
                        list.add(buildExclusion);
-
 
1420
                    }
-
 
1421
                }
-
 
1422
            }
2060
            }
-
 
2061
        }
1423
 
2062
 
1424
            //  Locate ALL packages that depend on this package and exclude them too
2063
            //  Locate ALL packages that depend on this package and exclude them too
1425
            //  This process will be recursive
2064
            //  This process will be recursive
1426
            //    Not sure that this it is efficient 
2065
            //    Not sure that this it is efficient 
1427
            //  Only ripple a build exclusion through for non test builds
2066
            //  Only ripple a build exclusion through for non test builds
Line 1542... Line 2181...
1542
                {
2181
                {
1543
                    Package p = it.next();
2182
                    Package p = it.next();
1544
                    generatePackageInfo(xml, p);
2183
                    generatePackageInfo(xml, p);
1545
                }
2184
                }
1546
 
2185
 
-
 
2186
                xml.addComment("mPackageCollectionWip");
-
 
2187
                for (Iterator<Package> it = mPackageCollectionWip.iterator(); it.hasNext(); )
-
 
2188
                {
-
 
2189
                    Package p = it.next();
-
 
2190
                    if (p.mIsNotReleased )
-
 
2191
                        generatePackageInfo(xml, p);
-
 
2192
                }
-
 
2193
                
-
 
2194
                xml.addComment("mPackageCollectionTest");
-
 
2195
                for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
-
 
2196
                {
-
 
2197
                    Package p = it.next();
-
 
2198
                    if (p.mIsNotReleased )
-
 
2199
                        generatePackageInfo(xml, p);
-
 
2200
                }
-
 
2201
 
-
 
2202
                xml.addComment("mPackageCollectionTestRipple");
-
 
2203
                for (Iterator<Package> it = mPackageCollectionRipple.iterator(); it.hasNext(); )
-
 
2204
                {
-
 
2205
                    Package p = it.next();
-
 
2206
                    if (p.mIsNotReleased )
-
 
2207
                        generatePackageInfo(xml, p);
-
 
2208
                }
-
 
2209
 
1547
                // UTF Support
2210
                // UTF Support
1548
                // Insert build exclusion information
2211
                // Insert build exclusion information
1549
                xml.addComment("mBuildExclusionCollection");
2212
                xml.addComment("mBuildExclusionCollection");
1550
                for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
2213
                for (Iterator<BuildExclusion> it = mBuildExclusionCollection.iterator(); it.hasNext(); )
1551
                {
2214
                {
1552
                    BuildExclusion buildExclusion = it.next();
2215
                    BuildExclusion buildExclusion = it.next();
1553
                    if (!buildExclusion.isProcessed())
-
 
1554
                    {
2216
                    {
1555
                        xml.addComment(buildExclusion.info());
2217
                        xml.addComment(buildExclusion.toString());
1556
                    }
2218
                    }
1557
                }
2219
                }
1558
                
2220
            }
1559
                // UTF Support
2221
            
-
 
2222
            // UTF Support (Also while trailing the changes)
1560
                // Insert build Plan
2223
            // Insert build Plan
1561
                if (mDaemon)
2224
            if (mDaemon)
-
 
2225
            {
-
 
2226
                xml.addComment("mBuildOrder");
-
 
2227
                for (Iterator<PlannedPackage> it = mBuildOrder.iterator(); it.hasNext(); )
1562
                {
2228
                {
1563
                    xml.addComment("mBuildOrder");
2229
                    PlannedPackage p = it.next();
1564
                    int order = 0;
2230
                    String comment =
1565
                    for (Iterator<Package> it = mBuildOrder.iterator(); it.hasNext(); )
-
 
1566
                    {
-
 
1567
                        Package p = it.next();
-
 
1568
                        String comment =
2231
                            "pvid="+ p.mPkg.mId +
1569
                                "pvid="+ p.mId +
2232
                            " order=" + p.mBuildLevel +
1570
                                " order=" +(++order) +
2233
                            " time=" + p.mPkg.mBuildTime +
1571
                                " name=\"" + p.mAlias + "\"";
2234
                            " name=\"" + p.mPkg.mAlias + "\"";
1572
                        xml.addComment(comment);
2235
                    xml.addComment(comment);
1573
                    }
-
 
1574
                }
2236
                }
1575
            }
2237
            }
1576
 
2238
 
1577
            //  Generate Taskdef information
2239
            //  Generate Taskdef information
1578
            generateTaskdef(xml);
2240
            generateTaskdef(xml);
Line 1592... Line 2254...
1592
            //
2254
            //
1593
            //	Generate target rules for each package to be built within the current build file
2255
            //	Generate target rules for each package to be built within the current build file
1594
            //
2256
            //
1595
            boolean daemonHasTarget = false;
2257
            boolean daemonHasTarget = false;
1596
 
2258
 
1597
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2259
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
1598
            {
2260
            {
1599
                Package p = it.next();
2261
                Package p = it.next();
1600
 
2262
 
1601
                if ( p.mBuildFile > 0 && p.mBuildFile <= buildFile )
2263
                if ( p.mBuildFile > 0 && p.mBuildFile <= buildFile )
1602
                {
2264
                {
Line 1670... Line 2332...
1670
            allProcessed = true;
2332
            allProcessed = true;
1671
 
2333
 
1672
            if (!mDaemon)
2334
            if (!mDaemon)
1673
            {
2335
            {
1674
                // this is escrow mode centric
2336
                // this is escrow mode centric
1675
                for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2337
                for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
1676
                {
2338
                {
1677
                    Package p = it.next();
2339
                    Package p = it.next();
1678
 
2340
 
1679
                    if ( p.mBuildFile > buildFile )
2341
                    if ( p.mBuildFile > buildFile )
1680
                    {
2342
                    {
Line 1716... Line 2378...
1716
            element.addProperty("abt_rtag_id", mBaseline);
2378
            element.addProperty("abt_rtag_id", mBaseline);
1717
            element.addProperty("abt_daemon", mReleaseManager.currentTimeMillis());
2379
            element.addProperty("abt_daemon", mReleaseManager.currentTimeMillis());
1718
            element.makePropertyTag("abt_packagetarball", true);
2380
            element.makePropertyTag("abt_packagetarball", true);
1719
            element.makePropertyTag("abt_usetestarchive", !ReleaseManager.getUseMutex());
2381
            element.makePropertyTag("abt_usetestarchive", !ReleaseManager.getUseMutex());
1720
 
2382
 
1721
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2383
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
1722
            {
2384
            {
1723
                Package p = it.next();
2385
                Package p = it.next();
1724
 
2386
 
1725
                if ( p.mBuildFile == 1 )
2387
                if ( p.mBuildFile == 1 )
1726
                {
2388
                {
Line 1821... Line 2483...
1821
     * @param xml	- An xml element to append data to
2483
     * @param xml	- An xml element to append data to
1822
     * @param p	- Package to process
2484
     * @param p	- Package to process
1823
     */
2485
     */
1824
    private void generatePackageInfo (XmlBuilder xml, Package p)
2486
    private void generatePackageInfo (XmlBuilder xml, Package p)
1825
    {
2487
    {
-
 
2488
        StringBuilder comment = new StringBuilder();
-
 
2489
        StringBuilder deps = new StringBuilder();
-
 
2490
        
-
 
2491
        String joiner = "";
-
 
2492
        for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
-
 
2493
        {
-
 
2494
            String alias = it2.next();
-
 
2495
            deps.append(joiner).append(alias); 
-
 
2496
            joiner = ",";
-
 
2497
        }
-
 
2498
        
-
 
2499
        comment.append("pvid=").append(p.mId);
-
 
2500
        comment.append(" name=").append('"').append(p.mAlias).append('"');
-
 
2501
        comment.append(" reason=").append(p.mNoBuildReason);
-
 
2502
        comment.append(" buildFile=").append(p.mBuildFile);
-
 
2503
        comment.append(" directlyPlanned=").append(p.mDirectlyPlanned);
-
 
2504
        comment.append(" indirectlyPlanned=").append(p.mIndirectlyPlanned);
-
 
2505
        comment.append(" depends=[").append(deps).append("]");
1826
 
2506
 
1827
        String comment =
-
 
1828
                "pvid="+ p.mId + 
-
 
1829
                " name=\"" + p.mAlias + "\""+
-
 
1830
                " reason=" + p.mNoBuildReason +" "+ 
-
 
1831
                " buildFile=" + p.mBuildFile + " "+
-
 
1832
                " directlyPlanned=" + p.mDirectlyPlanned + " "+
-
 
1833
                " indirectlyPlanned=" + p.mIndirectlyPlanned;
-
 
1834
 
-
 
1835
        xml.addComment(comment);            
2507
        xml.addComment(comment.toString());            
1836
    }
2508
    }
1837
 
2509
 
1838
    /**returns an ant target for the passed Package
2510
    /**returns an ant target for the passed Package
1839
     * in daemon mode:
2511
     * in daemon mode:
1840
     *  packages are categorized with one of three mBuildFile values:
2512
     *  packages are categorized with one of three mBuildFile values:
Line 2086... Line 2758...
2086
        target.addAttribute("name", "fullstart");
2758
        target.addAttribute("name", "fullstart");
2087
 
2759
 
2088
        if (buildFile == 1)
2760
        if (buildFile == 1)
2089
        {
2761
        {
2090
            antEcho(target, "${line.separator}" + mAnyBuildPlatforms + "${line.separator}${line.separator}");
2762
            antEcho(target, "${line.separator}" + mAnyBuildPlatforms + "${line.separator}${line.separator}");
2091
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2763
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
2092
            {
2764
            {
2093
                Package p = it.next();
2765
                Package p = it.next();
2094
 
2766
 
2095
                if ( p.mBuildFile == -1 )
2767
                if ( p.mBuildFile == -1 )
2096
                {
2768
                {
2097
                    antEcho(target, "${line.separator}" + p.mAlias + "${line.separator}");
2769
                    antEcho(target, "${line.separator}" + p.mAlias + "${line.separator}");
2098
                }
2770
                }
2099
            }
2771
            }
2100
 
2772
 
2101
            antEcho(target, "${line.separator}" + mAssocBuildPlatforms + "${line.separator}${line.separator}");
2773
            antEcho(target, "${line.separator}" + mAssocBuildPlatforms + "${line.separator}${line.separator}");
2102
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2774
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
2103
            {
2775
            {
2104
                Package p = it.next();
2776
                Package p = it.next();
2105
 
2777
 
2106
                if ( p.mBuildFile == -2 )
2778
                if ( p.mBuildFile == -2 )
2107
                {
2779
                {
2108
                    antEcho(target, "${line.separator}" + p.mAlias + "${line.separator}");
2780
                    antEcho(target, "${line.separator}" + p.mAlias + "${line.separator}");
2109
                }
2781
                }
2110
            }
2782
            }
2111
 
2783
 
2112
            antEcho(target, "${line.separator}" + mNotInBaseline + "${line.separator}${line.separator}");
2784
            antEcho(target, "${line.separator}" + mNotInBaseline + "${line.separator}${line.separator}");
2113
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2785
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
2114
            {
2786
            {
2115
                Package p = it.next();
2787
                Package p = it.next();
2116
 
2788
 
2117
                if ( p.mBuildFile == -4 )
2789
                if ( p.mBuildFile == -4 )
2118
                {
2790
                {
2119
                    antEcho(target, "${line.separator}" + p.mAlias + "${line.separator}");
2791
                    antEcho(target, "${line.separator}" + p.mAlias + "${line.separator}");
2120
                }
2792
                }
2121
            }
2793
            }
2122
 
2794
 
2123
            antEcho(target, "${line.separator}" + mDependent + "${line.separator}${line.separator}");
2795
            antEcho(target, "${line.separator}" + mDependent + "${line.separator}${line.separator}");
2124
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2796
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
2125
            {
2797
            {
2126
                Package p = it.next();
2798
                Package p = it.next();
2127
 
2799
 
2128
                if ( p.mBuildFile == -5 )
2800
                if ( p.mBuildFile == -5 )
2129
                {
2801
                {
Line 2142... Line 2814...
2142
        //      Escrow : All packages
2814
        //      Escrow : All packages
2143
        //      Daemon : Just the package being built
2815
        //      Daemon : Just the package being built
2144
        //
2816
        //
2145
        StringAppender dependList = new StringAppender(",");
2817
        StringAppender dependList = new StringAppender(",");
2146
        dependList.append("fullstart");
2818
        dependList.append("fullstart");
2147
        for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2819
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
2148
        {
2820
        {
2149
            Package p = it.next();
2821
            Package p = it.next();
2150
 
2822
 
2151
            if ( ( p.mBuildFile > 0 ) && ( p.mBuildFile <= buildFile ) )
2823
            if ( ( p.mBuildFile > 0 ) && ( p.mBuildFile <= buildFile ) )
2152
            {
2824
            {
Line 2185... Line 2857...
2185
        mLogger.debug("rippleIndirectlyPlanned");
2857
        mLogger.debug("rippleIndirectlyPlanned");
2186
        if ( !p.mIndirectlyPlanned && p.mBuildFile == 0 )
2858
        if ( !p.mIndirectlyPlanned && p.mBuildFile == 0 )
2187
        {
2859
        {
2188
            p.mIndirectlyPlanned = true;
2860
            p.mIndirectlyPlanned = true;
2189
 
2861
 
2190
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
2862
            for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
2191
            {
2863
            {
2192
                Package pkg = it.next();
2864
                Package pkg = it.next();
2193
 
2865
 
2194
                if ( pkg != p )
2866
                if ( pkg != p )
2195
                {
2867
                {
Line 2352... Line 3024...
2352
                +  "<br>Package: " + p.mAlias 
3024
                +  "<br>Package: " + p.mAlias 
2353
                +  "<br>Rm Ref: " + CreateUrls.generateRmUrl(getRtagId(), p.mId); 
3025
                +  "<br>Rm Ref: " + CreateUrls.generateRmUrl(getRtagId(), p.mId); 
2354
 
3026
 
2355
        mailBody += "<p><hr>";
3027
        mailBody += "<p><hr>";
2356
 
3028
 
2357
        //    Generate the list of email recipients
-
 
2358
        //        Transfer the daemon instruction email list into the package before use
-
 
2359
 
-
 
2360
        p.setTestEmail();
-
 
2361
        String target = p.emailInfoNonAntTask(this);
3029
        String target = p.emailInfoNonAntTask(this);
2362
 
3030
 
2363
        mLogger.error("emailRejectedDaemonInstruction Server: {}", getMailServer());
3031
        mLogger.error("emailRejectedDaemonInstruction Server: {}", getMailServer());
2364
        mLogger.error("emailRejectedDaemonInstruction Sender: {}", getMailSender());
3032
        mLogger.error("emailRejectedDaemonInstruction Sender: {}", getMailSender());
2365
        mLogger.error("emailRejectedDaemonInstruction Target: {}", target);
3033
        mLogger.error("emailRejectedDaemonInstruction Target: {}", target);
2366
 
3034
 
2367
        try
3035
        try
2368
        {
3036
        {
2369
            //    
3037
            //    
2370
            Smtpsend.send(getMailServer(), // mailServer
3038
            Smtpsend.send(getMailServer(),  // mailServer
2371
                    getMailSender(),       // source
3039
                    getMailSender(),        // source
2372
                    target,            // target
3040
                    target,                 // target
2373
                    getMailSender(),       // cc
3041
                    getMailSender(),        // cc
2374
                    null,              // bcc
3042
                    null,                   // bcc
2375
                    subject,           // subject
3043
                    subject,                // subject
2376
                    mailBody,          // body
3044
                    mailBody,               // body
2377
                    null               // attachment
3045
                    null                    // attachment
2378
                    );
3046
                    );
2379
        } catch (Exception e)
3047
        } catch (Exception e)
2380
        {
3048
        {
2381
            mLogger.warn("Email Failure: emailRejectedDaemonInstruction:{}", e.getMessage());
3049
            mLogger.warn("Email Failure: emailRejectedDaemonInstruction:{}", e.getMessage());
2382
        }
3050
        }