Subversion Repositories DevTools

Rev

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

Rev 7077 Rev 7078
Line 432... Line 432...
432
        mLogger.debug("planRelease deal with circular dependencies");
432
        mLogger.debug("planRelease deal with circular dependencies");
433
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
433
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
434
        {
434
        {
435
            Package p = it.next();
435
            Package p = it.next();
436
 
436
 
437
            if ( p.hasCircularDependency( this ) )
437
            if ( p.hasCircularDependency( mPackageCollectionAll ) )
438
            {
438
            {
439
                mLogger.info("planRelease circular dependency detected {}", p.mAlias);
439
                mLogger.info("planRelease circular dependency detected {}", p.mAlias);
440
                
440
                
441
                //  Force this package to be marked as having a circular dependency - even if its been excluded
441
                //  Force this package to be marked as having a circular dependency - even if its been excluded
442
                p.mBuildFile = 0;
442
                p.mBuildFile = 0;
Line 807... Line 807...
807
                }
807
                }
808
            }
808
            }
809
 
809
 
810
            //  Daemon Mode Only
810
            //  Daemon Mode Only
811
            //  Mark Pegged and SDK packages as not to be built
811
            //  Mark Pegged and SDK packages as not to be built
-
 
812
            //  Mark RippleStoped packages as not to be build
812
            //  Have previously detected conflicts between pegged/sdk packages and daemon instructions
813
            //  Have previously detected conflicts between pegged/sdk packages and daemon instructions
813
            //
814
            //
814
            mLogger.debug("planRelease remove pegged and SDK packages from the build set");
815
            mLogger.debug("planRelease remove pegged and SDK packages from the build set");
815
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
816
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
816
            {
817
            {
817
                Package p = it.next();
818
                Package p = it.next();
818
 
819
 
819
                if (p.mBuildFile == 0)
820
                if (p.mBuildFile == 0)
820
                {
821
                {
-
 
822
                    String reason = null;
-
 
823
                    
821
                    //  Not interested in a pegged package or a package provided from an SDK.
824
                    //  Not interested in a pegged package or a package provided from an SDK or packages with an active RippleStop
822
                    //  Such packages are not built
825
                    //  Such packages are not built
823
                    if (p.mIsPegged || p.mIsSdk)
826
                    if (p.mIsPegged ) {
-
 
827
                        reason = "Pegged";
-
 
828
                        p.mBuildFile = -8;
-
 
829
                    } else if (p.mIsSdk) {
-
 
830
                        reason = "SDK";
-
 
831
                        p.mBuildFile = -8;
-
 
832
                    } else if (p.mRippleStop == 's' || p.mRippleStop == 'w') {
-
 
833
                        reason = "RippleStop";
-
 
834
                        p.mBuildFile = -11;
-
 
835
                    }
-
 
836
                    
-
 
837
                    if (reason != null)
824
                    {
838
                    {
825
                        String reason;
-
 
826
                        reason = (p.mIsPegged) ? "Pegged" : "SDK";
-
 
827
 
-
 
828
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
839
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
829
                        p.mBuildFile = -8;
-
 
830
                    }
840
                    }
831
                }
841
                }
832
            }
842
            }
833
 
843
 
834
            //  Daemon Mode Only
844
            //  Daemon Mode Only
Line 861... Line 871...
861
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
871
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
862
                    emailRejectedDaemonInstruction(reason,p);
872
                    emailRejectedDaemonInstruction(reason,p);
863
                }
873
                }
864
            }
874
            }
865
            
875
            
-
 
876
            //  Daemon Mode Only
-
 
877
            //  Examine the build candidates and verify that a new version number can be calculated for each
-
 
878
            //  version that we need to build.
-
 
879
            //
-
 
880
            //  If we can't generate a new version number, then this is considered to be a build failure
-
 
881
            //  The package will be excluded and the user will be emailed
-
 
882
            //
-
 
883
            ArrayList<Package> testVersions = new ArrayList<Package>();
-
 
884
            testVersions.addAll(mPackageCollectionWip);
-
 
885
            testVersions.addAll(mPackageCollectionRipple);
-
 
886
            
-
 
887
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
-
 
888
            {
-
 
889
                Package p = it.next();
-
 
890
                if (p.mBuildFile >= 0 &&  p.mBuildReason != null) {
-
 
891
                    testVersions.add(p);
-
 
892
                }
-
 
893
            }
-
 
894
                    
-
 
895
            for (Iterator<Package> it = testVersions.iterator(); it.hasNext(); )
-
 
896
            {
-
 
897
                Package p = it.next();
-
 
898
 
-
 
899
                if ( p.mBuildFile >= 0 )
-
 
900
                {
-
 
901
                    int pvApplied = p.applyPV(mReleaseManager);
-
 
902
 
-
 
903
                    if ( pvApplied == 1 )
-
 
904
                    {
-
 
905
                        // max 50 chars
-
 
906
                        rippleBuildExclude(p, p.mId, "Package has non standard versioning", null, null, true, true);
-
 
907
                    }
-
 
908
                    else if ( pvApplied == 2 )
-
 
909
                    {
-
 
910
                        // max 50 chars
-
 
911
                        rippleBuildExclude(p, p.mId, "Package has reached ripple field limitations", null, null, true, true);
-
 
912
                    }
-
 
913
                    else if ( pvApplied == 3 )
-
 
914
                    {
-
 
915
                        // max 50 chars
-
 
916
                        rippleBuildExclude(p, p.mId, "Package has invalid change type", null, null, true, true);
-
 
917
                    }
-
 
918
                }
-
 
919
            }
-
 
920
            
866
        }
921
        }
867
        else
922
        else
868
        {
923
        {
869
            // escrow reporting only
924
            // escrow reporting only
870
            // Report packages that are not reproducible
925
            // Report packages that are not reproducible
Line 882... Line 937...
882
                }
937
                }
883
            }
938
            }
884
        }
939
        }
885
    }
940
    }
886
 
941
 
887
    /** Plan the build order.
-
 
888
     *  Assumes that a great deal of work has been done.
-
 
889
     *  This is a stand alone method to contain the work
942
    /** Internal class to contain intermediate results
890
     *  
-
 
891
     * @throws Exception
-
 
892
     * @throws SQLException
-
 
893
     */
943
     */
-
 
944
    class PlanResults {
-
 
945
        int planTime = 0;
-
 
946
        ArrayList<Package> planCollection = new ArrayList<Package>(); 
-
 
947
    }
-
 
948
 
-
 
949
    /**
-
 
950
     * Process a collection of packages and generate a collection of package plans
894
    private void planBuildOrder() throws Exception, SQLException 
951
     * A package plan is a collection of packages that can be built
-
 
952
     *      The first item in the list is a package that can be built right now
-
 
953
     *      Other items in the list will be packages that can be built now or will need to be built as the result
-
 
954
     *      of a ripple
-
 
955
     *      
-
 
956
     * The method will be called multiple times so that we can evaluate different plans
-
 
957
     * The underling packages will have data and flags that will need to be rested before a calculation      
-
 
958
     *
-
 
959
     * @param name - Name of the plan
-
 
960
     * @param packageCollection - Base collection of packages to plan
-
 
961
     * @param mode - true: Include 'Ripples'
-
 
962
     * 
-
 
963
     * @return
-
 
964
     */
-
 
965
    private PlanResults planCollection(String name, ArrayList<Package> packageCollection, boolean mode)
895
    {
966
    {
896
        
-
 
897
//TODO - Planning is not working well
-
 
898
/**
-
 
899
 * Current status
-
 
900
 * The selection of the package to build next is deeply flawed
-
 
901
 * Currently it will select a directly planned package over a ripple - (perhaps that is good)
-
 
902
 * 
-
 
903
 * Currently on the buildPlan of the 'selected' package is included in the BuildOrder
-
 
904
 * 
-
 
905
 * The current algorithm is based on time - but all packages have zero build time ( in UTF )
-
 
906
 * Even if this is fixed the algorithm is broken as we will select the complete build with the shortest time
-
 
907
 * which will be the ripple of a leaf package ( perhaps that is good )
-
 
908
 * 
-
 
909
 * Also:
-
 
910
 *      [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
-
 
911
 * 
-
 
912
 *      [Done-ish]Need to generate a single package set - so that WIPS and others replace those in the final build set
-
 
913
 *      [Done]Remove duplicates from the complete package set
967
        ArrayList<Package> ripplePlan = new ArrayList<Package>();
914
 *      
-
 
915
 *      [Being Done] Need more test cases
-
 
916
 *      
-
 
917
 *      [Done, in the UTF] Need to report all build options, not just the selected one
-
 
918
 *                         Data to RM may need some more info
-
 
919
 *      
-
 
920
 *      Cleanup the ANT build file - don't list all the release dependencies, just those needed to build the current package
-
 
921
 *      Chances are - all we need is the new package version number
968
        PlanResults results = new PlanResults();
922
 *      
-
 
923
 *      [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.
-
 
924
 *              Should not exclude a WIP of a package with a circular dependency
-
 
925
 */
-
 
926
 
969
 
927
        // Process remaining packages which are need to be reproduced for this baseline.
-
 
928
        //    Determine the build file for each package
970
        //  Reset flags used in the calculations
929
        //    For daemon builds:
-
 
930
        //      Determine the next package that can be built now
971
        Package.resetProcessed(packageCollection);
931
        //          Sounds simple - doesn't it
-
 
932
        //      Set its mBuildNumber to 1, all remaining reproducible packages to 2
-
 
933
        //    For escrow builds:
-
 
934
        //      Determine the package versions that can be built in the build iteration
-
 
935
        //      Set their mBuildNumber to the build iteration
-
 
936
        //      Increment the build iteration and repeat until all package versions 
-
 
937
        //      that need to be reproduced have been assigned a build iteration        
-
 
938
        
972
        
-
 
973
        //  Exclude all packages that cannot be built and all packages that depend on them
-
 
974
        //      First find packages to be directly excluded
-
 
975
        ArrayList<Package>exclude = new ArrayList<Package>();
-
 
976
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
-
 
977
        {
-
 
978
            Package p = it.next();
-
 
979
            if (p.mBuildFile < 0) {
-
 
980
                exclude.add(p);
-
 
981
            }
-
 
982
        }
-
 
983
        
-
 
984
        //  Process the list of packages to be excluded
-
 
985
        //  Add to the list packages that depend on the excluded package that have not already been excluded
-
 
986
        while( !exclude.isEmpty() )
-
 
987
        {
-
 
988
            Package p = exclude.remove(0);
-
 
989
            p.mProcessed = true;
-
 
990
            p.mIsProcessed = true;
-
 
991
            mLogger.info("planCollection package not buildable {}", p.mName);
-
 
992
            
-
 
993
            for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
-
 
994
            {
-
 
995
                Package pkg = it1.next();
-
 
996
                if (pkg.mProcessed) {
-
 
997
                    continue;
-
 
998
                }
-
 
999
                
-
 
1000
                for (Iterator<String> it = p.mDependencyCollection.iterator(); it.hasNext(); )
-
 
1001
                {
-
 
1002
                    String alias = it.next();
-
 
1003
                    if ( p.mAlias.compareTo( alias ) == 0 ) {
-
 
1004
                        exclude.add(pkg);
-
 
1005
                    }
-
 
1006
                }
-
 
1007
            }
-
 
1008
        }
-
 
1009
        
-
 
1010
        //  Now have a collection of packages with those that we cannot build have been marked
-
 
1011
        //  Process the list and determine packages that we can build right now
-
 
1012
        //      ie: they have not been excluded, have not already been discovered and do not depend on any package in the collection
-
 
1013
        //      Continue to do this until all packages have been extracted
-
 
1014
        //      Allocate build levels as we go
-
 
1015
        //
939
        boolean allProcessed = false;
1016
        boolean allProcessed = false;
940
        int buildFile = 1;
1017
        int buildLevel = 1;
941
 
1018
 
942
        do
1019
        do
943
        {
1020
        {
944
            //
1021
            //
945
            //  Create the mBuildOrder collection
1022
            //  Create the mBuildOrder collection
Line 947... Line 1024...
947
            //      Will have package build order and build level
1024
            //      Will have package build order and build level
948
            boolean allDependenciesProcessed = true;
1025
            boolean allDependenciesProcessed = true;
949
            do
1026
            do
950
            {
1027
            {
951
                allDependenciesProcessed = true;
1028
                allDependenciesProcessed = true;
952
                for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1029
                for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
953
                {
1030
                {
954
                    Package p = it.next();
1031
                    Package p = it.next();
955
 
-
 
956
                    if ( p.mBuildFile < 0  ) 
-
 
957
                    {
1032
                    
958
                        // Daemon: Flag packages that cannot be built
-
 
959
                        // Escrow: Flag packages with a foreign build environment as processed
1033
                    //  Skip packages that have been processed - have determined build order, or cannot build
960
                        p.mProcessed = true;
1034
                    if (p.mIsProcessed) {
961
                        mLogger.info("planRelease package not buildable {}", p.mName);            
1035
                        continue;
962
                    }
1036
                    }
-
 
1037
 
-
 
1038
                    // Package yet to be processed and
-
 
1039
                    //      Daemon mode: Could be built
-
 
1040
                    //      Escrow mode: Can be reproduced
963
                    else if ( p.mBuildFile == 0 )
1041
                    boolean canBeBuiltNow = true;
-
 
1042
                    boolean allDependenciesForThisPackageProcessed = true;
-
 
1043
 
-
 
1044
                    //  Scan the packages dependencies
-
 
1045
                    for ( Iterator<Package> it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
964
                    {
1046
                    {
965
                        // package yet to be processed and
1047
                        Package dependency = it2.next();
966
                        //  Daemon mode: Could be built
-
 
967
                        //  Escrow mode: Can be reproduced
-
 
968
                        boolean canBeBuiltNow = true;
-
 
969
                        boolean allDependenciesForThisPackageProcessed = true;
-
 
970
 
1048
 
971
                        //  Scan the packages dependencies
1049
                        if ( !dependency.mProcessed )
972
                        for ( Iterator<Package> it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
-
 
973
                        {
1050
                        {
974
                            Package dependency = it2.next();
-
 
975
 
-
 
976
                            if ( !dependency.mProcessed )
-
 
977
                            {
-
 
978
                                //  If all the dependencies have been processed, then we can potentially build this package
1051
                            //  If all the dependencies have been processed, then we can potentially build this package
979
                                //  If any of them have not been processed, then cannot calculate canBeBuiltNow until this 
1052
                            //  If any of them have not been processed, then cannot calculate canBeBuiltNow until this 
980
                                //  dependency has been processed
1053
                            //  dependency has been processed
981
                                allDependenciesForThisPackageProcessed = false;
1054
                            allDependenciesForThisPackageProcessed = false;
982
                                allDependenciesProcessed = false;
1055
                            allDependenciesProcessed = false;
983
                            }
1056
                        }
984
                            else if (  (  mDaemon && (   dependency.mBuildFile == 0 ) ) 
1057
                        else if (  (  mDaemon && (   dependency.mBuildFile == 0 ) ||  (dependency.mBuildFile == buildLevel)) 
985
                                    || ( !mDaemon && ( ( dependency.mBuildFile == 0 ) ||
1058
                                || ( !mDaemon && ( ( dependency.mBuildFile == 0 ) ||
986
                                                           ( dependency.mBuildFile == buildFile &&
1059
                                                       ( dependency.mBuildFile == buildLevel &&
987
                                                           ( !p.haveSameBuildStandards(dependency)  ) ) ) ) )
1060
                                                       ( !p.haveSameBuildStandards(dependency)  ) ) ) ) )
988
                            {
1061
                        {
-
 
1062
                            // Can be built - yet
989
                                // Daemon mode:
1063
                            // Daemon mode:
990
                                //    This processed dependency has not been assigned to a build iteration - so can't built yet
1064
                            //    This processed dependency has not been assigned to a build iteration
-
 
1065
                            //    This processed dependency has been assigned to this build iteration
991
                                // Escrow mode: This package cannot be built now if
1066
                            // Escrow mode: This package cannot be built now if
992
                                //    This processed dependency has not been assigned to a build iteration or
1067
                            //    This processed dependency has not been assigned to a build iteration or
993
                                //    This processed dependency has been assigned to this build iteration, but the 
1068
                            //    This processed dependency has been assigned to this build iteration, but the 
994
                                //    build standards of the package and this dependency prevent the package being
1069
                            //    build standards of the package and this dependency prevent the package being
995
                                //    built in this iteration.   
1070
                            //    built in this iteration.   
996
                                canBeBuiltNow = false;
1071
                            canBeBuiltNow = false;
997
                                mLogger.info("planRelease package cannot be built in this iteration {}", p.mName);
1072
                            mLogger.info("planRelease package cannot be built in this iteration {}", p.mName);
998
                                break;
1073
                            break;
999
                            }
-
 
1000
                        }
1074
                        }
-
 
1075
                    }
1001
 
1076
 
1002
                        //  All dependencies have been processed. May be able to build this package
1077
                    //  All dependencies have been processed. May be able to build this package
1003
                        //      Add the package to the build order list
1078
                    //      Add the package to the build order list
1004
                        //
1079
                    //
1005
                        if (allDependenciesForThisPackageProcessed)
1080
                    if (allDependenciesForThisPackageProcessed)
-
 
1081
                    {
-
 
1082
                        p.mProcessed = true;
-
 
1083
                        if ( canBeBuiltNow )
1006
                        {
1084
                        {
1007
                            p.mProcessed = true;
-
 
1008
                            if ( canBeBuiltNow )
1085
                            results.planCollection.add(p);
1009
                            {
-
 
1010
                                mBuildOrder.add(p);
1086
                            p.mBuildFile = buildLevel;
1011
                                p.mBuildFile = buildFile;
1087
                            p.mIsProcessed = true;
1012
                                mLogger.info("planRelease set mBuildFile to {} for package {}",buildFile, p.mAlias );
1088
                            mLogger.info("planRelease set mBuildFile to {} for package {}",buildLevel, p.mAlias );
1013
                            }
-
 
1014
                        }
1089
                        }
1015
                    }
1090
                    }
1016
                }
1091
                }
1017
            } while( !allDependenciesProcessed );
1092
            } while( !allDependenciesProcessed );
1018
            
1093
            
1019
            //  Have process all the packages that we can at the moment
1094
            //  Have process all the packages that we can at the moment
1020
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1095
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1021
            //      These will be done at a different build-level
1096
            //      These will be done at a different build-level
1022
            //  
1097
            //  
1023
            allProcessed = true;
1098
            allProcessed = true;
1024
            for (Iterator<Package> it = mPackageCollection.iterator(); it.hasNext(); )
1099
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1025
            {
1100
            {
1026
                Package p = it.next();
1101
                Package p = it.next();
1027
                if ( p.mBuildFile == 0 )
1102
                if ( !  p.mIsProcessed )
1028
                {
1103
                {
1029
                    // more build files are required
1104
                    // more build files are required
1030
                    allProcessed = false;
1105
                    allProcessed = false;
1031
                    mLogger.info("planRelease more build files are required for {}", p.mName);
1106
                    mLogger.info("planRelease more build files are required for {}", p.mName);
1032
                    break;
1107
                    break;
1033
                }
1108
                }
1034
            }
1109
            }
1035
 
1110
 
1036
            buildFile++;
1111
            buildLevel++;
1037
            if (buildFile % 500 == 0 ) {
1112
            if (buildLevel % 500 == 0 ) {
1038
                mLogger.error("planRelease. Too many build levels {}", buildFile);
1113
                mLogger.error("planRelease. Too many build levels {}", buildLevel);
1039
            }
1114
            }
1040
        } while( !allProcessed );
1115
        } while( !allProcessed );
-
 
1116
 
-
 
1117
        //  Now we have a collection packages that we can build right now
-
 
1118
        //      The packages currently have a build level set into mBuildFile
1041
            
1119
        //
1042
 
-
 
1043
        if ( mDaemon )
1120
        if (mDaemon)
1044
        {
1121
        {
1045
 
-
 
1046
            //
-
 
1047
            //  Daemon Mode:
-
 
1048
            //
-
 
1049
 
-
 
1050
            //  Create a list of build candidates
-
 
1051
            //
-
 
1052
            //  Add in the WIPs, Tests and Ripple Requests so that we can process them as one collections
-
 
1053
            //  Now have a collection of packages that we would like to build right now
-
 
1054
            //  See if any of them can be excluded due to issues with creating a new package version
1122
            //  Determine if we have a reason to build anything in this collection of buildable packages
1055
            ArrayList<Package> buildCandidates = new ArrayList<Package>();
1123
            ArrayList<Package> toBuild = new ArrayList<Package>();
1056
            buildCandidates.addAll(mPackageCollectionWip);
-
 
1057
            buildCandidates.addAll(mPackageCollectionTest);
-
 
1058
            buildCandidates.addAll(mPackageCollectionRipple);
-
 
1059
 
-
 
1060
            //  Locate all packages that we can build now
-
 
1061
            //      Packages that have a build requirement and have no reason we cannot build them
-
 
1062
 
-
 
1063
            for (Iterator<Package> it = mBuildOrder.iterator(); it.hasNext(); )
1124
            for (Iterator<Package> it = results.planCollection.iterator(); it.hasNext(); )
1064
            {
1125
            {
1065
                Package p = it.next();
1126
                Package p = it.next();
1066
                if ( p.mProcessed && p.mBuildFile > 0 )
1127
                if (p.mBuildReason != null) {
1067
                {
-
 
1068
                    if (p.mBuildReason != null)
1128
                    if (mode || ( !mode && p.mBuildReason != BuildReason.Ripple ))
1069
                    {
1129
                    {
1070
                        // Have a reason to build this package
-
 
1071
                        buildCandidates.add(p);
1130
                        toBuild.add(p);
1072
                        mLogger.info("planRelease Candidate {}",p.mAlias);
-
 
1073
                    }
1131
                    }
1074
                }
1132
                }
1075
            }
1133
            }
1076
            
1134
            
1077
            //  Examine the build candidates and verify that a new version number can be calculated for each
1135
            //  Need (would like to) build stuff
1078
            //  version that we need to build.
1136
            //  Determine the packages that we need to build and the time that it will take
1079
            //
1137
            //
1080
            //  If we can't generate a new version number, then this is considered to be a build failure
-
 
1081
            //  The package will be excluded and the user will be emailed
-
 
1082
            //
-
 
1083
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1138
            if ( !toBuild.isEmpty() )
1084
            {
1139
            {
1085
                Package p = it.next();
1140
                results.planTime = 0;
1086
 
-
 
-
 
1141
                             
-
 
1142
                
-
 
1143
                //  Need to add elements to the end of the list while processing
-
 
1144
                //  Sum the buildTimes of the packages that we add to the list
1087
                if ( p.mBuildFile >= 0 )
1145
                while ( ! toBuild.isEmpty())
1088
                {
1146
                {
1089
                    int pvApplied = p.applyPV(mReleaseManager);
-
 
1090
 
-
 
1091
                    if ( pvApplied == 1 )
-
 
1092
                    {
-
 
1093
                        // max 50 chars
-
 
1094
                        rippleBuildExclude(p, p.mId, "Package has non standard versioning", null, null, true, true);
-
 
1095
                    }
-
 
1096
                    else if ( pvApplied == 2 )
1147
                    Package pkg = toBuild.remove(0);
1097
                    {
-
 
1098
                        // max 50 chars
-
 
1099
                        rippleBuildExclude(p, p.mId, "Package has reached ripple field limitations", null, null, true, true);
-
 
1100
                    }
-
 
1101
                    else if ( pvApplied == 3 )
-
 
1102
                    {
-
 
1103
                        // max 50 chars
-
 
1104
                        rippleBuildExclude(p, p.mId, "Package has invalid change type", null, null, true, true);
-
 
1105
                    }
-
 
1106
                    
1148
                    
1107
                    if ( pvApplied != 0) 
1149
                    if (pkg.mRippleOrder > 100 ) {
1108
                    {
-
 
1109
                        // If this package is not a WIP/TEST/RIPPLE, then remove it from this collection
-
 
1110
                        // Want to keep all WIP/TEST/RIPPLE items to simplify reporting
1150
                        mLogger.error("Circular dependency detected - not handled well");
1111
                        if (! p.mIsNotReleased )
-
 
1112
                        {
-
 
1113
                            it.remove();
-
 
1114
                        }
1151
                        break;
1115
                    }
1152
                    }
1116
                    
1153
                    
1117
                    //
-
 
1118
                    //  Ensure that the mRippleTime is known for each package
-
 
1119
                    //  Collection includes: naturalRipples, ForcedRipples, TestBuilds and NewVersions
-
 
1120
                    if ( pvApplied == 0)
1154
                    if ( ! ripplePlan.contains( pkg ))
1121
                    {
1155
                    {
1122
                        if (p.mTestBuildInstruction != 0)
-
 
1123
                        {
1156
                        ripplePlan.add(pkg);
1124
                            // Test Build - there is no ripple effect
-
 
1125
                            // The time impact will be the estimated build time of this one package
-
 
1126
                            p.mRippleTime = p.mBuildTime;
1157
                        results.planTime += pkg.mBuildTime;
1127
                            
-
 
1128
                        }
-
 
1129
                        else 
-
 
1130
                        {
-
 
1131
                            //  Calculate the time to build the package AND all of the packages that depend on it
-
 
1132
                            //  Calculate the build plan for the package
-
 
1133
                            //
-
 
1134
                            calcBuildPlan(p, mPackageCollection);
-
 
1135
                        }
-
 
1136
                    }
1158
                    }
-
 
1159
                    
-
 
1160
                    ArrayList<Package> usedBy = usedByPackages(pkg, results.planCollection, pkg.mRippleOrder + 1);
-
 
1161
                    toBuild.addAll(usedBy);
-
 
1162
                }
-
 
1163
                //  Sort the packages by buildOrder and buildTime
-
 
1164
                Collections.sort(ripplePlan, Package.BuildOrderComparitor);
-
 
1165
                
-
 
1166
                mLogger.error("Plan Build {} Time: {}", name, results.planTime);
-
 
1167
                for (Iterator<Package> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1168
                {
-
 
1169
                    Package p = it.next();
-
 
1170
                    mLogger.error("Plan: {} {}", p.mRippleOrder, p.mAlias);
1137
                }
1171
                }
1138
            }
1172
            }
1139
            
1173
            
1140
            //  Determine the first test build package
1174
            //  Daemon mode: Returning calculated plan
1141
            //  Assume the collection is in build instruction id order, 
1175
            results.planCollection = ripplePlan;
1142
            //      So that the first request will be built first
1176
        }
1143
            //  Add all buildable test-builds to the mBuildOrder collection 
-
 
1144
            Package testBuild = ReleaseManager.NULL_PACKAGE;
1177
        
1145
            mBuildOrder.clear();
1178
        return results;
-
 
1179
    }
1146
 
1180
 
-
 
1181
    /** Generate a plan based on a modified set of packages
-
 
1182
     * 
-
 
1183
     * @param name      - Name of the plan
-
 
1184
     * @param basicPlan - basicPlan
-
 
1185
     * @param mode      - True: Include natural ripples and WIPS/RIPPLES that would have been done
-
 
1186
     *                          as a part of the basic plan
-
 
1187
     * @return
-
 
1188
     */
-
 
1189
    private PlanResults postRipplePlan(String name, PlanResults basicPlan, boolean mode) {
-
 
1190
 
-
 
1191
        ArrayList<Package> fullPlanCollection = new ArrayList<Package>(mPackageCollection);
-
 
1192
        ArrayList<Package> buildCandidates = new ArrayList<Package>();
-
 
1193
        buildCandidates.addAll(mPackageCollectionWip);
-
 
1194
        buildCandidates.addAll(mPackageCollectionRipple);
-
 
1195
        
-
 
1196
        if ( !buildCandidates.isEmpty() )
-
 
1197
        {
1147
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1198
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1148
            {
1199
            {
1149
                
-
 
1150
                Package p = it.next();
1200
                Package p = it.next();
1151
                if ( p.mBuildFile >= 0 )
1201
                if (p.mBuildFile >= 0)
1152
                {
1202
                {
1153
                    if (p.mTestBuildInstruction != 0)
1203
                    if (!mode)
1154
                    {
1204
                    {
1155
                        //  Not a Test Build
1205
                        //  Exclude packages that would have been processed in the basicPlan
1156
                        if (testBuild == ReleaseManager.NULL_PACKAGE)
1206
                        for (Iterator<Package> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1157
                        {
1207
                        {
-
 
1208
                            Package pkg = it1.next();
1158
                            testBuild = p;
1209
                            if (pkg == p)
-
 
1210
                            {
-
 
1211
                                mLogger.error("Test Plan without {}", p.mAlias);
-
 
1212
                                continue;
-
 
1213
                            }
1159
                        }
1214
                        }
-
 
1215
                    }
-
 
1216
                    
-
 
1217
                    mLogger.error("Test Plan with {}", p.mAlias);
-
 
1218
                    Package foundInRelease = mReleaseManager.findPackage(p.mAlias, fullPlanCollection);
-
 
1219
                    int foundIndex = mReleaseManager.findPackageLastIndex;
-
 
1220
                    if (foundInRelease == ReleaseManager.NULL_PACKAGE)
-
 
1221
                    {
-
 
1222
                        fullPlanCollection.add(p);
-
 
1223
                    }
-
 
1224
                    else
-
 
1225
                    {
-
 
1226
                        fullPlanCollection.set(foundIndex, p);
-
 
1227
                    }
-
 
1228
                    
-
 
1229
                    Package.resetCircularDependency (fullPlanCollection);
-
 
1230
                    if ( p.hasCircularDependency( fullPlanCollection ) )
-
 
1231
                    {
-
 
1232
                        mLogger.info("planRelease circular dependency detected {}", p.mAlias);
-
 
1233
                        
-
 
1234
                        //  Force this package to be marked as having a circular dependency - even if its been excluded
-
 
1235
                        p.mBuildFile = 0;
-
 
1236
                        
-
 
1237
                        // exclude all dependent packages
-
 
1238
                        // max 50 chars
-
 
1239
                        rippleBuildExclude(p, p.mId, "Package has circular dependency", null, null, true, false);
-
 
1240
 
-
 
1241
                        // take the package out of the build
1160
                        mBuildOrder.add(p);
1242
                        p.mBuildFile = -6;
-
 
1243
                        mLogger.info("planRelease set mBuildFile to -6 for package {}", p.mAlias );
1161
                    }
1244
                    }
1162
                }
1245
                }
1163
            }
1246
            }
1164
            
1247
            
-
 
1248
        }
-
 
1249
        return planCollection(name, fullPlanCollection, mode);
-
 
1250
    }
-
 
1251
 
-
 
1252
    /** Plan the build order.
-
 
1253
     *  Assumes that a great deal of work has been done.
-
 
1254
     *  This is a stand alone method to contain the work
-
 
1255
     *  
-
 
1256
     * @throws Exception
-
 
1257
     * @throws SQLException
-
 
1258
     */
-
 
1259
    private void planBuildOrder() throws Exception, SQLException 
-
 
1260
    {
-
 
1261
        
-
 
1262
//TODO - Planning is not working well
-
 
1263
/**
-
 
1264
 * Current status
-
 
1265
 * The selection of the package to build next is deeply flawed
-
 
1266
 * Currently it will select a directly planned package over a ripple - (perhaps that is good)
-
 
1267
 * 
-
 
1268
 * Currently on the buildPlan of the 'selected' package is included in the BuildOrder
-
 
1269
 * 
-
 
1270
 * The current algorithm is based on time - but all packages have zero build time ( in UTF )
-
 
1271
 * Even if this is fixed the algorithm is broken as we will select the complete build with the shortest time
-
 
1272
 * which will be the ripple of a leaf package ( perhaps that is good )
-
 
1273
 * 
-
 
1274
 * Also:
-
 
1275
 *      [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
-
 
1276
 * 
-
 
1277
 *      [Done-ish]Need to generate a single package set - so that WIPS and others replace those in the final build set
-
 
1278
 *      [Done]Remove duplicates from the complete package set
-
 
1279
 *      
-
 
1280
 *      [Being Done] Need more test cases
-
 
1281
 *      
-
 
1282
 *      [Done, in the UTF] Need to report all build options, not just the selected one
-
 
1283
 *                         Data to RM may need some more info
-
 
1284
 *      
-
 
1285
 *      Cleanup the ANT build file - don't list all the release dependencies, just those needed to build the current package
-
 
1286
 *      Chances are - all we need is the new package version number
-
 
1287
 *      
-
 
1288
 *      [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.
-
 
1289
 *              Should not exclude a WIP of a package with a circular dependency
-
 
1290
 */
-
 
1291
 
-
 
1292
        // Process remaining packages which are need to be reproduced for this baseline.
-
 
1293
        //    Determine the build file for each package
-
 
1294
        //    For daemon builds:
-
 
1295
        //      Determine the next package that can be built now
-
 
1296
        //          Sounds simple - doesn't it
-
 
1297
        //      Set its mBuildNumber to 1, all remaining reproducible packages to 2
-
 
1298
        //    For escrow builds:
-
 
1299
        //      Determine the package versions that can be built in the build iteration
-
 
1300
        //      Set their mBuildNumber to the build iteration
-
 
1301
        //      Increment the build iteration and repeat until all package versions 
-
 
1302
        //      that need to be reproduced have been assigned a build iteration        
-
 
1303
        
-
 
1304
        //
-
 
1305
        //  Generate a plan for the packages that are in the current release
-
 
1306
        //  These may be the result of a ripple going through the system 
-
 
1307
        //  or a rebuild of a missing package or the result of a merge.
-
 
1308
        //
-
 
1309
        //  This will provide our basic plan, before we consider adding new packages to the
-
 
1310
        //  mix, such as those from user WIPS and RIPPLE requests.
-
 
1311
        //  
-
 
1312
        PlanResults basicPlan = planCollection("Basic", mPackageCollection, true);
-
 
1313
        
-
 
1314
        //  Have not considered any of the WIP or RIPPLE packages
-
 
1315
        //  If any of them are in the basic plan, then we can ignore them as we will build them
-
 
1316
        //  when we build the basic plan
-
 
1317
        //
-
 
1318
        //  Determine a set of packages that will not be included if we build the basic plan
-
 
1319
        //
-
 
1320
        //  At the moment - lets assume there are none
-
 
1321
        //  What do we do ?
-
 
1322
        //      Select the first request
-
 
1323
        //      Replace the package in the released collection
-
 
1324
        //      Run the plan algorithm
-
 
1325
        //      Restore the release collection
-
 
1326
        //
-
 
1327
        if ( mDaemon )
-
 
1328
        {
1165
            //
1329
            //
1166
            //  Determine the NON-test packages the we will build next
1330
            //  Need to consider the TEST requests
1167
            //  This will be the one with the lowest ripple time
1331
            //      - Valid requests will be placed first on the build order
1168
            //
1332
            //
1169
            Package build = ReleaseManager.NULL_PACKAGE;
-
 
1170
            ArrayList<Package> buildNext = new ArrayList<Package>();
-
 
1171
            
-
 
1172
            //  Extract candidates that are left
1333
            mBuildOrder.clear();
1173
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1334
            for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
1174
            {
1335
            {
1175
                Package p = it.next();
1336
                Package p = it.next();
1176
                if ( p.mBuildFile >= 0  &&p.mTestBuildInstruction == 0)
1337
                if (p.mBuildFile >= 0)
1177
                {
1338
                {
1178
                    buildNext.add(p);
1339
                    mBuildOrder.add(p);
-
 
1340
                    p.mRippleOrder = 0;
1179
                }
1341
                }
1180
            }
1342
            }
1181
            
1343
            
1182
            if ( !buildNext.isEmpty() )
1344
            //  First attempt
1183
            {
-
 
1184
                //  Sort on mRippleTime so that
-
 
1185
                //      We can get the lowest first
1345
            //  Insert all the WIPs and RIPPLES into the buildset. 
1186
                //      We can generate the complete plan in a nice order
1346
            //  Generate a plan and see how much the time is extended.
1187
                //
1347
            //
1188
                Collections.sort(buildNext, Package.RippleTimeComparator);
1348
            //  Don't modify mPackageCollection, although data in the 'Package' in the underlying packages may change
1189
                
1349
            
1190
                //  At the moment extract the first one - this is the fastest
1350
            PlanResults fullPlan = null;           
1191
                //  Allowing for a 20% extension.
1351
            fullPlan = postRipplePlan("Full", basicPlan, true);
1192
                //
1352
            
1193
                //  TODO - what if two build sets don't overlap. Do we build the longer one first ?
1353
            //  Decide with plan to use
1194
                //  TODO - what if two build sets do overlay. Can we merge them somehow
1354
            //  At the moment we have, at most two.
1195
                //
1355
            //      - (basic) Current Release ripples
1196
                build = buildNext.get(0);
1356
            //      - (full) Current Release + All WIPS and RIPPLES
1197
                
1357
            //
1198
                //  Determine the amount of time we would allow the 'best' plan to be extended
1358
            //  If we have both then if the full plan is < 20% longer than the basic plan, use the full plan
1199
                //      Allow for a 20% extension in time
1359
            //  Otherwise we use basic plan FOLLOWED by the a MODIFIED full plan (one without the natural ripples)
1200
                //      Minimum of 10 minutes
-
 
1201
                int baseTime = build.mRippleTime;
1360
            //  Add the planned packages into the buildOrder
1202
                baseTime = ( baseTime * 1200) / 1000;
-
 
1203
                if ( baseTime < 10 * 60) {
-
 
1204
                    baseTime = (10 * 60);
-
 
1205
                }
-
 
1206
                mLogger.error("Scan for package to build: {} {}", build.mRippleTime, baseTime);
-
 
1207
 
1361
 
1208
                //  Find last package that does not exceed the extended ripple time
1362
            if( !basicPlan.planCollection.isEmpty() && fullPlan != null )
1209
                for (Iterator<Package> it = buildNext.iterator(); it.hasNext(); )
-
 
1210
                {
1363
            {
1211
                    Package p = it.next();
1364
                mLogger.error("Two plan selection: {} {}, {} <= {}", basicPlan.planTime,fullPlan.planTime, basicPlan.planTime * 12, fullPlan.planTime * 10);
1212
                    if (p.mRippleTime > baseTime)
1365
                if ( (basicPlan.planTime * 12) <= (fullPlan.planTime * 10) )
1213
                    {
1366
                {
1214
                        break;
1367
                    //  Use the basic plan FOLLOWED by a plan that does not include
1215
                    }
1368
                    //      Ripples done by the basic plan
1216
                    build = p;
1369
                    //      WIPs/RIPPLES done in the course of doing the basic plan
1217
                }
-
 
1218
 
1370
 
1219
                //
-
 
1220
                //  Extend mBuildOrder with the selected non-test build package and its build plan
-
 
1221
                //  Really only for display purposes
-
 
1222
                //
-
 
1223
                Package.resetProcessed(buildNext);
-
 
1224
                mBuildOrder.add(build);
1371
                    mBuildOrder.addAll(basicPlan.planCollection);
1225
                updateBuildList(build.mRipplePlan, buildNext);
1372
                    fullPlan = postRipplePlan("Full-Ripples", basicPlan, false);
1226
                mBuildOrder.addAll(build.mRipplePlan);
1373
                    mBuildOrder.addAll(fullPlan.planCollection);
1227
                
-
 
1228
                //  Add in other build candidates
-
 
1229
                for (Iterator<Package> it = buildNext.iterator(); it.hasNext(); )
-
 
1230
                {
-
 
1231
                    Package p = it.next();
-
 
1232
                    if ( p.mBuildFile >= 0 )
-
 
1233
                    {
1374
                    
1234
                        if ( p != build && ! p.mIsProcessed)
-
 
1235
                        {
1375
                } else {
1236
                            //  Not our selected package and not already processed
-
 
1237
                            mBuildOrder.add(p);
1376
                    //  Use the full plan
1238
                            updateBuildList(p.mRipplePlan, buildNext);
-
 
1239
                            mBuildOrder.addAll(p.mRipplePlan);
1377
                    mBuildOrder.addAll(fullPlan.planCollection);
1240
                        }
-
 
1241
                    }
-
 
1242
                }
1378
                }
-
 
1379
            } else if (!basicPlan.planCollection.isEmpty() ) {
-
 
1380
                // Use the basic plan
-
 
1381
                mBuildOrder.addAll(basicPlan.planCollection);
-
 
1382
            } else if ( fullPlan != null ) {
-
 
1383
                // Use the full plan
-
 
1384
                mBuildOrder.addAll(fullPlan.planCollection);
-
 
1385
            } else {
-
 
1386
                // Do not have a plan
-
 
1387
                // May have tests requests
1243
            }
1388
            }
1244
            
1389
            
1245
            //
1390
            //  Now have an mBuildOrder
1246
            //  Mark the first package in the build order as the one to be built
1391
            //  Mark the first package in the build order as the one to be built
1247
            //  This will give test builds priority, while indicating what will be built after that
-
 
1248
            //
1392
            //
1249
            
1393
            Package build = ReleaseManager.NULL_PACKAGE;
1250
            if (!mBuildOrder.isEmpty()) {
1394
            if (!mBuildOrder.isEmpty()) {
1251
                build = mBuildOrder.get(0);
1395
                build = mBuildOrder.get(0);
1252
                build.mBuildFile = 1;
1396
                build.mBuildFile = 1;
1253
                
1397
                
1254
                if ( build.mForcedRippleInstruction > 0 )
1398
                if ( build.mForcedRippleInstruction > 0 )
Line 1274... Line 1418...
1274
            
1418
            
1275
            //
1419
            //
1276
            //  Massage the package collection
1420
            //  Massage the package collection
1277
            //      Replace WIP/TEST/RIPPLE so that the mPackageCollection is a collection of packages we would like in the release
1421
            //      Replace WIP/TEST/RIPPLE so that the mPackageCollection is a collection of packages we would like in the release
1278
            //      Don't replace those that we can't build due to errors
1422
            //      Don't replace those that we can't build due to errors
-
 
1423
            //  
-
 
1424
            //  TODO - Not sure this does anything for us. Once upon a time it might have been nice, but now it may be confusing
1279
            //
1425
            //
-
 
1426
            ArrayList<Package> buildCandidates = new ArrayList<Package>();
-
 
1427
            buildCandidates.addAll(mPackageCollectionTest);
-
 
1428
            buildCandidates.addAll(mPackageCollectionWip);
-
 
1429
            buildCandidates.addAll(mPackageCollectionRipple);
-
 
1430
 
1280
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1431
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1281
            {
1432
            {
1282
                Package p = it.next();
1433
                Package p = it.next();
1283
                if ( p.mBuildFile >= 0 )
1434
                if ( p.mBuildFile >= 0 )
1284
                {
1435
                {
Line 1328... Line 1479...
1328
                    p.mBuildFile = 3;
1479
                    p.mBuildFile = 3;
1329
                }
1480
                }
1330
            }
1481
            }
1331
 
1482
 
1332
        }
1483
        }
1333
 
-
 
1334
    }
-
 
1335
 
-
 
1336
    /** Update a collection of packages such that the collection contains packages from the WIP/RIPPLE collection
-
 
1337
     *  in preference to the package in the main collection
-
 
1338
     *  
1484
        else
1339
     * @param packageList   - List to process and update
-
 
1340
     * @param repList - List of replacement candidates. Assumes valid packages
-
 
1341
     */
-
 
1342
    private void updateBuildList(ArrayList<Package> packageList, ArrayList<Package> repList ) {
-
 
1343
 
-
 
1344
        int baseIndex = 0;
-
 
1345
        for (Iterator<Package> it = packageList.iterator(); it.hasNext(); baseIndex++)
-
 
1346
        {
1485
        {
1347
            Package basePkg = it.next();
-
 
1348
 
-
 
1349
            for (Iterator<Package> repit = repList.iterator(); repit.hasNext(); )
-
 
1350
            {
-
 
1351
                Package repPkg = repit.next();
-
 
1352
                if ( basePkg.mAlias.compareTo( repPkg.mAlias ) == 0 )                    
-
 
1353
                {
-
 
1354
                    //  Replacement package has been found
-
 
1355
                    //  Only looking for non-test packages that can be built
-
 
1356
                    //  Flag that the package is now a part of the official release set
-
 
1357
                    //  Flag that the package has been processed to prevent it being included in a future plan
-
 
1358
                    
1486
            //  Escrow
1359
                    packageList.set(baseIndex, repPkg);
-
 
1360
                    repPkg.mIsNotReleased = false;
1487
            //  The basic plan is the escrow build order
1361
                    repPkg.mIsProcessed = true;
1488
            mBuildOrder = basicPlan.planCollection;
1362
                    break;
-
 
1363
                    
-
 
1364
                }
-
 
1365
            }
-
 
1366
        }
1489
        }
1367
    }
-
 
1368
 
-
 
1369
    /**
-
 
1370
     * Calculate a build plan for the specified package
-
 
1371
     * Calculates : mRippleTime - time to build the package and the ripple effect
-
 
1372
     * Calculates : mBuildPlan - collection of packages in the plan that can be built at the moment
-
 
1373
     * 
-
 
1374
     * Needs to determine all packages that consume the package - and all packages that consume them
-
 
1375
     *  Note: The package may not be in the mPackageCollection ( it may be a WIP/TEST/RIPPLE )
-
 
1376
     *  
-
 
1377
     * Note: The rippleTime of PackageA is not the sum of the rippleTimes of the packages that consume PackageA.
-
 
1378
     *  
-
 
1379
     * Need to:
-
 
1380
     *      Only include a package once.
-
 
1381
     *      Only include packages that can/need to be built at the moment
-
 
1382
     * 
-
 
1383
     * @param p                 - Package to process
-
 
1384
     * @param pkgCollection     - Package Collection to scan
-
 
1385
 
-
 
1386
     */
-
 
1387
    private void calcBuildPlan(Package p, ArrayList<Package> pkgCollection) {
-
 
1388
        
-
 
1389
 
1490
 
1390
        p.mRipplePlan = new ArrayList<Package>(); 
-
 
1391
        p.mRippleTime = p.mBuildTime;
-
 
1392
        
-
 
1393
        //  Need to add elements to the end of the list while processing
-
 
1394
        //  Sum the buildTimes of the packages that we add to the list
-
 
1395
        ArrayList<Package> toProcess = usedByPackages(p, pkgCollection, 1);
-
 
1396
        while ( ! toProcess.isEmpty())
-
 
1397
        {
-
 
1398
            Package pkg = toProcess.remove(0);
-
 
1399
            if ( ! p.mRipplePlan.contains( pkg ))
-
 
1400
            {
-
 
1401
                p.mRipplePlan.add(pkg);
-
 
1402
                p.mRippleTime += pkg.mBuildTime;
-
 
1403
            }
-
 
1404
            
-
 
1405
            ArrayList<Package> usedBy = usedByPackages(pkg, pkgCollection, pkg.mRippleOrder + 1);
-
 
1406
            toProcess.addAll(usedBy);
-
 
1407
        }
-
 
1408
        
-
 
1409
        //
-
 
1410
        //  Need to determine the rippleTime for each package in the plan
-
 
1411
        //      Have a much smaller set of packages to process (need only scan those in p.mRipplePlan)
-
 
1412
        //  Similar to the above code, but 
-
 
1413
        //      Don't care about the mRipplePlan item in the packages
-
 
1414
        //      Don't modify the mRippleOrder
-
 
1415
        //
-
 
1416
        for (ListIterator<Package> it = p.mRipplePlan.listIterator(); it.hasNext(); )
-
 
1417
        {
-
 
1418
            Package p1 = it.next();
-
 
1419
            
-
 
1420
            int rippleTime = 0;
-
 
1421
            ArrayList<Package> ripplePlan = new ArrayList<Package>();
-
 
1422
            ArrayList<Package> toProcess1 = new ArrayList<Package>();
-
 
1423
            
-
 
1424
            toProcess1.add(p1);
1491
        mLogger.error("Final Plan");
1425
            while ( ! toProcess1.isEmpty())
-
 
1426
            {
-
 
1427
                Package pkg = toProcess1.remove(0);
-
 
1428
                if ( ! ripplePlan.contains( pkg ))
-
 
1429
                {
-
 
1430
                    ripplePlan.add(pkg);
-
 
1431
                    rippleTime += pkg.mBuildTime;
-
 
1432
                }
-
 
1433
                
-
 
1434
                ArrayList<Package> usedBy = usedByPackages(pkg, p.mRipplePlan, -1);
-
 
1435
                toProcess1.addAll(usedBy);
-
 
1436
            }
-
 
1437
            
-
 
1438
            p1.mRippleTime = rippleTime;
-
 
1439
        }
-
 
1440
        
-
 
1441
        
-
 
1442
        //
-
 
1443
        //  Sort the ripplePlan so that we build the fastest elements first
-
 
1444
        //  Only care about the ripplePlan for the main Package
-
 
1445
        //
-
 
1446
        Collections.sort(p.mRipplePlan, Package.PlanComparator);
-
 
1447
        
-
 
1448
        //  Debugging
-
 
1449
        mLogger.error("calcBuildPlan. Pkg:{} pvid:{}, Order:{} RippleT:{} BuildT:{}", p.mAlias, p.mId, p.mRippleOrder, p.mRippleTime, p.mBuildTime);
-
 
1450
        for (ListIterator<Package> it = p.mRipplePlan.listIterator(); it.hasNext(); )
1492
        for (Iterator<Package> it = mBuildOrder.iterator(); it.hasNext(); )
1451
        {
1493
        {
1452
            Package pkg = it.next();
1494
            Package p = it.next();
1453
            mLogger.error("calcBuildPlan. Plan: Pkg:{} pvid:{}, Order:{} RippleT:{} BuildT:{}", pkg.mAlias, pkg.mId, pkg.mRippleOrder, pkg.mRippleTime, pkg.mBuildTime);
1495
            mLogger.error("Plan: {} {}", p.mRippleOrder, p.mAlias);
1454
        }
1496
        }
-
 
1497
           
-
 
1498
 
1455
    }
1499
    }
1456
 
1500
 
1457
    /** 
1501
    /** 
1458
     *  Calculate a collection of packages that actively use the named package
1502
     *  Calculate a collection of packages that actively use the named package
1459
     *  A consumer package does NOT use the named package,
1503
     *  A consumer package does NOT use the named package,
Line 1462... Line 1506...
1462
     *      If the consumer cannot be built
1506
     *      If the consumer cannot be built
1463
     *   
1507
     *   
1464
     * @param pkg - Package to process
1508
     * @param pkg - Package to process
1465
     * @param pkgCollection - collection of packages to scan
1509
     * @param pkgCollection - collection of packages to scan
1466
     * @param rippleOrder - Set the ripple oder, if >= 0
1510
     * @param rippleOrder - Set the ripple oder, if >= 0
-
 
1511
     *
1467
     * @return A collection of packages that actively 'use' the specified package
1512
     * @return A collection of packages that actively 'use' the specified package
1468
 
1513
 
1469
     */
1514
     */
1470
    private ArrayList<Package> usedByPackages(Package pkg, ArrayList<Package> pkgCollection, int rippleOrder) {
1515
    private ArrayList<Package> usedByPackages(Package pkg, ArrayList<Package> pkgCollection, int rippleOrder) {
1471
        
1516
        
Line 1918... Line 1963...
1918
                        Package p = it.next();
1963
                        Package p = it.next();
1919
                        String comment =
1964
                        String comment =
1920
                                "pvid="+ p.mId +
1965
                                "pvid="+ p.mId +
1921
                                " order=" + (++order) +
1966
                                " order=" + (++order) +
1922
                                " Rorder=" + (p.mRippleOrder) +
1967
                                " Rorder=" + (p.mRippleOrder) +
1923
                                " time=" + p.mRippleTime +
1968
                                " time=" + p.mBuildTime +
1924
                                " name=\"" + p.mAlias + "\"";
1969
                                " name=\"" + p.mAlias + "\"";
1925
                        xml.addComment(comment);
1970
                        xml.addComment(comment);
1926
                    }
1971
                    }
1927
                }
1972
                }
1928
            }
1973
            }