Subversion Repositories DevTools

Rev

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

Rev 7176 Rev 7186
Line 1... Line 1...
1
package com.erggroup.buildtool.ripple;
1
package com.erggroup.buildtool.ripple;
2
 
2
 
3
import java.io.File;
3
import java.io.File;
4
import java.util.ArrayList;
-
 
5
import java.util.Comparator;
4
import java.util.Comparator;
6
import java.util.HashMap;
5
import java.util.HashMap;
7
import java.util.Iterator;
6
import java.util.Iterator;
8
import java.util.LinkedHashSet;
7
import java.util.LinkedHashSet;
9
import java.util.Vector;
8
import java.util.Vector;
Line 500... Line 499...
500
    }
499
    }
501
 
500
 
502
    /**
501
    /**
503
     * Constructor for unit test purposes
502
     * Constructor for unit test purposes
504
     *  Will invoke applyPV and save the results for the UTF framework
503
     *  Will invoke applyPV and save the results for the UTF framework
-
 
504
     * @param proj Package Suffix ( or Project extension)
-
 
505
     * @param isaTest - True - Generate testRequest
505
     */
506
     */
506
    public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
507
    public Package(ReleaseManager rm, String version, String proj, boolean isaTest, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
507
    {
508
    {
508
        mId = -1;
509
        mId = -1;
509
        mRippleField.setLimit();
510
        mRippleField.setLimit();
510
        mVersion = version;
511
        mVersion = version;
-
 
512
        mExtension = proj;
511
        mMajorLimit = majorLimit;
513
        mMajorLimit = majorLimit;
512
        mMinorLimit = minorLimit;
514
        mMinorLimit = minorLimit;
513
        mPatchLimit = patchLimit;
515
        mPatchLimit = patchLimit;
514
        mBuildLimit = buildNumberLimit;
516
        mBuildLimit = buildNumberLimit;
515
 
517
 
516
        if (version.endsWith(".cots"))
518
        if (isaTest)
-
 
519
        {
-
 
520
        	mTestBuildInstruction = 77;
-
 
521
        }
-
 
522
        
-
 
523
        if (proj.compareTo(".cots") == 0 || proj.compareTo(".tools") == 0 )
517
        {
524
        {
518
            mExtension = ".cots";
-
 
519
            mVersion = version.substring(0, version.length() - 5);
-
 
520
            mChangeType.setMajor(false);
525
            mChangeType.setMajor(false);
521
            mChangeType.setMinor(false);
526
            mChangeType.setMinor(false);
522
            mChangeType.setPatch(true);
527
            mChangeType.setPatch(true);
523
            mRippleField.setBuild();
528
            mRippleField.setBuild();
524
        }
529
        }
525
 
530
  
526
        try
531
        try
527
        {
532
        {
528
            mId = applyPV(rm);
533
            mId = applyPV(rm);
529
        } catch (Exception e)
534
        } catch (Exception e)
530
        {
535
        {
Line 781... Line 786...
781
 
786
 
782
    /**
787
    /**
783
     * Applies the required version number change. Will calculate mNextVersion
788
     * Applies the required version number change. Will calculate mNextVersion
784
     * while not changing mVersion.
789
     * while not changing mVersion.
785
     * 
790
     * 
-
 
791
     * Special cases
-
 
792
     * 	Cots packages - Can ripple if they have a patchBuild number suffix
-
 
793
     *  Test Builds - do as 99.99.99000
-
 
794
     *  Test Builds of Cots - Can do if they have a patchBuild suffix - do as .99000.cots
-
 
795
     * 
786
     * @param releaseManager    Release Manager instance to work against
796
     * @param releaseManager    Release Manager instance to work against
787
     * 
797
     * 
788
     * @return 0 : success
798
     * @return 0 : success
789
     *         1 : cannot work with non standard versioning
799
     *         1 : cannot work with non standard versioning
790
     *         2 : ripple field limitations prevent a ripple build
800
     *         2 : ripple field limitations prevent a ripple build
Line 795... Line 805...
795
    int applyPV(ReleaseManager releaseManager) throws Exception
805
    int applyPV(ReleaseManager releaseManager) throws Exception
796
    {
806
    {
797
        String logInfo = "applyPV," + mName;
807
        String logInfo = "applyPV," + mName;
798
        String changeType = "";
808
        String changeType = "";
799
        mLogger.warn("applyPV on Package {}", mName);
809
        mLogger.warn("applyPV on Package {}", mName);
-
 
810
        boolean isaCots = mExtension.compareTo(".cots") == 0 || mExtension.compareTo(".tools") == 0;
800
        
811
        
801
        //
812
        //
802
        //  This method used to actually perform the version change
813
        //  This method used to actually perform the version change
803
        //  Now it just calculates the potential value
814
        //  Now it just calculates the potential value
804
        //  Must not alter mVersion as it will be used if the package is not selected to be built,
815
        //  Must not alter mVersion as it will be used if the package is not selected to be built,
Line 829... Line 840...
829
        if (mTestBuildInstruction == 0)
840
        if (mTestBuildInstruction == 0)
830
        {
841
        {
831
            mRequiresSourceControlInteraction = true;
842
            mRequiresSourceControlInteraction = true;
832
        }
843
        }
833
        
844
        
834
        //	Force test builds to use a sensible version number
845
        //	Force test builds of non-COTS packages to use a sensible version number
835
        if (mTestBuildInstruction > 0 )
846
        if (mTestBuildInstruction > 0 && !isaCots )
836
        {
847
        {
837
        	mChangeType.resetData();		// Resolve conflict via build numbers
848
        	mChangeType.resetData();		// Resolve conflict via build numbers
838
        	mRippleField.setBuild();
849
        	mRippleField.setBuild();
839
        	mVersion = "99.99.98999";		// Such that rippling build number will goto 99.99.99000
850
        	mVersion = "99.99.98999";		// Such that rippling build number will goto 99.99.99000
840
        }
851
        }
Line 873... Line 884...
873
        //
884
        //
874
        if (mPrevVersion != null)
885
        if (mPrevVersion != null)
875
        {
886
        {
876
        	mVersion = mPrevVersion;
887
        	mVersion = mPrevVersion;
877
        }
888
        }
-
 
889
        
878
        String[] field = mVersion.split("\\D");
890
        String[] field = mVersion.split("\\D");
879
        String nonStandardCotsVersion = "";
891
        String nonStandardCotsVersion = "";
880
        logInfo += ", Prev:" + mVersion;
892
        logInfo += ", Prev:" + mVersion;
881
 
893
 
882
        if (field.length == 3)
894
        if (field.length == 3)
Line 886... Line 898...
886
            patch.value = Integer.parseInt(field[2]);
898
            patch.value = Integer.parseInt(field[2]);
887
        } 
899
        } 
888
        else
900
        else
889
        {
901
        {
890
            //
902
            //
891
            // Can ripple a .cots package under very controlled conditions
903
            // Can ripple a .cots/.tools package under very controlled conditions
892
            // Its ends with a .patchBuild field
904
            // Its ends with a .patchBuild field
893
            // Package is marked as ripple via build number
905
            // Package is marked as ripple via build number
894
            // Change type of Major and Minor are not allowed
906
            // Change type of Major and Minor are not allowed
895
            //
907
            //
896
            if (!mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && mExtension.compareTo(".cots") == 0 && field.length > 0)
908
            if (isaCots && !mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && field.length > 0)
897
            {
909
            {
898
                // allow and work with (ripple build) versions a.b.c.d....xxxx
910
                // allow and work with (ripple build) versions a.b.c.d....xxxx
899
                // where xxxx.length > 3
911
                // where xxxx.length > 3
900
                String patchStr = field[field.length - 1];
912
                String patchStr = field[field.length - 1];
901
                int patchLen = patchStr.length();
913
                int patchLen = patchStr.length();
Line 909... Line 921...
909
                }
921
                }
910
            }
922
            }
911
 
923
 
912
            if (nonStandardCotsVersion.length() == 0)
924
            if (nonStandardCotsVersion.length() == 0)
913
            {
925
            {
914
                // cannot work with non standard versioning
926
                // cannot work with non standard version number
915
                mLogger.warn("applyPV cannot work with non standard versioning");
927
                mLogger.warn("applyPV cannot work with non standard versioning");
916
                mLogger.info("applyPv returned 1");
928
                mLogger.info("applyPv returned 1");
917
                return 1;
929
                return 1;
918
            }
930
            }
919
        }
931
        }
Line 921... Line 933...
921
        if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
933
        if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
922
        {
934
        {
923
            mLogger.info("applyPV accomodate old style Version of the form 1.0.1");
935
            mLogger.info("applyPV accomodate old style Version of the form 1.0.1");
924
            patch.value = patch.value * 1000;
936
            patch.value = patch.value * 1000;
925
        }
937
        }
-
 
938
        
-
 
939
        //	Force test builds of COTS packages to use a sensible version number
-
 
940
        if (mTestBuildInstruction > 0 )
-
 
941
        {
-
 
942
        	mChangeType.resetData();		// Resolve conflict via build numbers
-
 
943
        	mRippleField.setBuild();
-
 
944
        	patch.value = 98999;			// Such that rippling build number will goto xxxx.99000
-
 
945
        }
926
 
946
 
927
        // mChangeType overrides mRippleField
947
        // mChangeType overrides mRippleField
928
        do
948
        do
929
        {
949
        {
930
            if (mChangeType.mMajor)
950
            if (mChangeType.mMajor)
Line 1373... Line 1393...
1373
     * Returns true if the package is a part of a circular dependency within the provided collection
1393
     * Returns true if the package is a part of a circular dependency within the provided collection
1374
     * 
1394
     * 
1375
     * If the package depends on a package with a circular dependency then the function
1395
     * If the package depends on a package with a circular dependency then the function
1376
     * will return false.
1396
     * will return false.
1377
     */
1397
     */
1378
    public boolean hasCircularDependency(ArrayList<Package> packageCollection)
1398
    public boolean hasCircularDependency(PackageCollection packageCollection)
1379
    {
1399
    {
1380
        mLogger.debug("hasCircularDependency: {}", mAlias);
1400
        mLogger.debug("hasCircularDependency: {}", mAlias);
1381
        boolean retVal = detectCircularDependency(mAlias, packageCollection, null);
1401
        boolean retVal = detectCircularDependency(mAlias, packageCollection, null);
1382
        mLogger.debug("hasCircularDependency returned {} ", retVal);
1402
        mLogger.debug("hasCircularDependency returned {} ", retVal);
1383
        return retVal;
1403
        return retVal;
Line 1385... Line 1405...
1385
    
1405
    
1386
    /** Reset the circular dependency testing information
1406
    /** Reset the circular dependency testing information
1387
     * 
1407
     * 
1388
     * @param packageCollection - Collection of packages to process
1408
     * @param packageCollection - Collection of packages to process
1389
     */
1409
     */
1390
    public static void resetCircularDependency(ArrayList<Package> packageCollection)
1410
    public static void resetCircularDependency(PackageCollection packageCollection)
1391
    {
1411
    {
1392
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1412
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1393
        {
1413
        {
1394
            Package p = it.next();
1414
            Package p = it.next();
1395
            p.mCheckedCircularDependency = false;
1415
            p.mCheckedCircularDependency = false;
Line 1409... Line 1429...
1409
     * 
1429
     * 
1410
     *  Assumes that the caller will walk ALL packages and flag those with a circular
1430
     *  Assumes that the caller will walk ALL packages and flag those with a circular
1411
     *  dependence AND those that depend on that package.
1431
     *  dependence AND those that depend on that package.
1412
     * 
1432
     * 
1413
     */
1433
     */
1414
    private boolean detectCircularDependency(String alias, ArrayList<Package> packageCollection, Package parent)
1434
    private boolean detectCircularDependency(String alias, PackageCollection packageCollection, Package parent)
1415
    {
1435
    {
1416
        mLogger.debug("detectCircularDependency");
1436
        mLogger.debug("detectCircularDependency");
1417
        boolean retVal = false;
1437
        boolean retVal = false;
1418
        
1438
        
1419
        // if this package has yet to be checked for circular dependency
1439
        // if this package has yet to be checked for circular dependency
Line 1439... Line 1459...
1439
                
1459
                
1440
                // Recurse down the dependencies and sub dependencies
1460
                // Recurse down the dependencies and sub dependencies
1441
                for (Iterator<PkgDependency> it2 = mDependencyCollection.iterator(); it2.hasNext();)
1461
                for (Iterator<PkgDependency> it2 = mDependencyCollection.iterator(); it2.hasNext();)
1442
                {
1462
                {
1443
                    PkgDependency depEntry = it2.next();
1463
                    PkgDependency depEntry = it2.next();
1444
                    
-
 
1445
                    // Scan the collection looking for the specified package alias
-
 
1446
                    for (Iterator<Package> it = packageCollection.iterator(); it.hasNext();)
1464
                    Package depPackage = packageCollection.contains(depEntry.alias);
1447
                    {
-
 
1448
                        Package dependency = it.next();
1465
                    if ( depPackage != null ) {
1449
 
-
 
1450
                        if ( dependency.mAlias.compareTo( depEntry.alias ) == 0 )
-
 
1451
                        {
-
 
1452
                            dependency.detectCircularDependency(alias, packageCollection, this);
1466
                    	depPackage.detectCircularDependency(alias, packageCollection, this);
1453
                            break;
-
 
1454
                        }
-
 
1455
                    }
1467
                    }
1456
                }
1468
                }
1457
                
1469
                
1458
                if (mBreadCrumb == 2)
1470
                if (mBreadCrumb == 2)
1459
                {
1471
                {
Line 1477... Line 1489...
1477
    }
1489
    }
1478
    
1490
    
1479
    /** Set the sequence of all packages in the list
1491
    /** Set the sequence of all packages in the list
1480
     *  Used so that the Unit Tests function can preserve the basic ordering of the list 
1492
     *  Used so that the Unit Tests function can preserve the basic ordering of the list 
1481
     */
1493
     */
1482
    public static void setSequence(ArrayList<Package> al)
1494
    public static void setSequence(PackageCollection packageCollection)
1483
    {
1495
    {
1484
        int seq = 1;
1496
        int seq = 1;
1485
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
1497
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1486
        {
1498
        {
1487
            Package p = it.next();
1499
            Package p = it.next();
1488
            p.mSeqId = seq++;
1500
            p.mSeqId = seq++;
1489
        }
1501
        }
1490
    }
1502
    }
1491
 
1503
 
1492
    /** Reset the processed flag on a collection of packages
1504
    /** Reset the processed flag on a collection of packages
1493
     * 
1505
     * 
1494
     */
1506
     */
1495
    public static void resetProcessed (ArrayList<Package> al)
1507
    public static void resetProcessed (PackageCollection packageCollection)
1496
    {
1508
    {
1497
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
1509
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1498
        {
1510
        {
1499
            Package p = it.next();
1511
            Package p = it.next();
1500
            p.mIsProcessed = false;
1512
            p.mIsProcessed = false;
1501
            p.mProcessed = false;
1513
            p.mProcessed = false;
1502
            if (p.mBuildFile > 0)
1514
            if (p.mBuildFile > 0)