Subversion Repositories DevTools

Rev

Rev 902 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 902 Rev 908
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
 
4
 
-
 
5
import java.sql.SQLException;
5
import java.util.Iterator;
6
import java.util.Iterator;
6
import java.util.Vector;
7
import java.util.Vector;
7
 
8
 
8
import org.apache.log4j.Logger;
9
import org.apache.log4j.Logger;
9
 
10
 
-
 
11
import com.erggroup.buildtool.smtp.Smtpsend;
-
 
12
 
10
public class Package
13
public class Package
11
{
14
{
12
  /**name of package, must not contain spaces
15
  /**name of package, must not contain spaces
13
   * @attribute
16
   * @attribute
14
   */
17
   */
Line 121... Line 124...
121
  /**set true when it is determined to be ripple built
124
  /**set true when it is determined to be ripple built
122
   * @attribute
125
   * @attribute
123
   */
126
   */
124
  boolean mIndirectlyPlanned = false;
127
  boolean mIndirectlyPlanned = false;
125
 
128
 
-
 
129
  /**non zero instruction number when it is determined to be ripple built by force
-
 
130
   * @attribute
-
 
131
   */
-
 
132
  int mForcedRippleInstruction = 0;
-
 
133
 
-
 
134
  /**non zero instruction number when it is determined to be test built
-
 
135
   * @attribute
-
 
136
   */
-
 
137
  int mTestBuildInstruction = 0;
-
 
138
 
-
 
139
  /**test build email destination
-
 
140
   * @attribute
-
 
141
   */
-
 
142
  String mTestBuildEmail;
-
 
143
 
-
 
144
  /**clearcase vob location, must not contain spaces
-
 
145
   * @attribute
-
 
146
   */
-
 
147
  String mTestBuildLocation = new String();
-
 
148
 
-
 
149
  /**clearcase source file instance identifier
-
 
150
   * @attribute
-
 
151
   */
-
 
152
  String mTestBuildLabel = new String();
-
 
153
 
-
 
154
  /**build standards
-
 
155
   * @attribute
-
 
156
   */
-
 
157
  Vector<BuildStandard> mTestBuildStandardCollection = new Vector<BuildStandard>();
-
 
158
 
-
 
159
  /**build dependencies by package alias
-
 
160
   * @attribute
-
 
161
   */
-
 
162
  Vector<String> mTestBuildDependencyCollection = new Vector<String>();
-
 
163
 
126
  /**build dependencies by pv_id (-1 or not used for planned dependencies)
164
  /**build dependencies by pv_id (-1 or not used for planned dependencies)
127
   * @attribute
165
   * @attribute
128
   */
166
   */
129
  Vector<Integer> mDependencyIDCollection = new Vector<Integer>();
167
  Vector<Integer> mDependencyIDCollection = new Vector<Integer>();
130
 
168
 
Line 266... Line 304...
266
    mAlias = "null";
304
    mAlias = "null";
267
    mLabel = "null";
305
    mLabel = "null";
268
    mLocation = "null";
306
    mLocation = "null";
269
  }
307
  }
270
 
308
 
-
 
309
  /**constructor for test build purposes
-
 
310
   */
-
 
311
  Package(String pkg_name, String v_ext, String alias, 
-
 
312
          String pkg_label, String src_path, int testBuildInstruction, String email)
-
 
313
  {
-
 
314
    mLogger.debug("Package 4: pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_label " + pkg_label + " src_path " + src_path);
-
 
315
    // don't need pv_id
-
 
316
    mId = -1;
-
 
317
    mName = pkg_name;
-
 
318
    // avoid interaction with real versions
-
 
319
    mVersion = "0.0.0000";
-
 
320
    mExtension = v_ext;
-
 
321
    mAlias = alias;
-
 
322
    mTestBuildInstruction = testBuildInstruction;
-
 
323
    mTestBuildEmail = email;
-
 
324
    mTestBuildLocation = src_path;
-
 
325
    mTestBuildLabel = pkg_label;
-
 
326
  }
-
 
327
  
271
  /**constructor for unit test purposes
328
/**constructor for unit test purposes
272
  */
329
  */
273
  public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
330
  public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
274
  {
331
  {
275
    mId = -1;
332
    mId = -1;
276
    mRippleField.setLimit();
333
    mRippleField.setLimit();
Line 408... Line 465...
408
   *         2 on ripple field limitations prevent a ripple build
465
   *         2 on ripple field limitations prevent a ripple build
409
   */
466
   */
410
  int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
467
  int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
411
  {
468
  {
412
    mLogger.debug("applyPV on Package " + mName);
469
    mLogger.debug("applyPV on Package " + mName);
413
    // three scenarios, only applyPV for 2 of them
470
    // four scenarios, only applyPV for 3 of them
414
    // WIP exists:                      mDirectlyPlanned == true;   mIndirectlyPlanned == true; mArchivalExistence don't care - applyPV
471
    // WIP/test build exists:           mDirectlyPlanned == true;   mIndirectlyPlanned == true; mArchivalExistence don't care; mForcedRipple don't care - applyPV
415
    // Package version is out of date:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == true    - applyPV
472
    // Package version is out of date:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == true;    mForcedRipple don't care - applyPV
-
 
473
    // Forced ripple:                   mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence don't care; mForcedRipple > 0        - applyPV
416
    // Package version does not exist:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == false   - do not applyPV
474
    // Package version does not exist:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == false;   mForcedRipple = 0    - do not applyPV
417
    if ( !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence )
475
    if ( !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0 )
418
    {
476
    {
419
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
477
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
420
      // do not apply a different package version
478
      // do not apply a different package version
421
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence on Package " + mName);
479
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && zero mForcedRippleInstruction on Package " + mName);
422
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
480
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
423
      mLogger.info("applyPv returned 0");
481
      mLogger.info("applyPv returned 0");
424
      return 0;
482
      return 0;
425
    }
483
    }
-
 
484
 
-
 
485
    // override - no longer doing a rebuild - version number change from this point on
-
 
486
    if ( mTestBuildInstruction == 0 )
-
 
487
    {
-
 
488
      mRequiresSourceControlInteraction = true;
-
 
489
    }
426
    
490
    
427
    MutableInt major = new MutableInt();
491
    MutableInt major = new MutableInt();
428
    major.value = 0;
492
    major.value = 0;
429
    MutableInt minor = new MutableInt();
493
    MutableInt minor = new MutableInt();
430
    minor.value = 0;
494
    minor.value = 0;
Line 894... Line 958...
894
    {
958
    {
895
      mBuildFailureEmailCollection.add(email);
959
      mBuildFailureEmailCollection.add(email);
896
    }
960
    }
897
  }
961
  }
898
 
962
 
-
 
963
  /**accessor method
-
 
964
   */
-
 
965
  void setEmail()
-
 
966
  {
-
 
967
    mBuildFailureEmailCollection.clear();
-
 
968
    addEmail( mTestBuildEmail );
-
 
969
  }
-
 
970
 
-
 
971
  /**accessor method
-
 
972
   */
-
 
973
  void setDependencyCollection()
-
 
974
  {
-
 
975
    // does not worry about mPackageDendencyCollection by design
-
 
976
    mDependencyCollection.clear();
-
 
977
    
-
 
978
    for (Iterator<String> it = mTestBuildDependencyCollection.iterator(); it.hasNext(); )
-
 
979
    {
-
 
980
      String dependency = it.next();
-
 
981
      mDependencyCollection.add(dependency);
-
 
982
    }
-
 
983
  }
-
 
984
 
-
 
985
  /**accessor method
-
 
986
   */
-
 
987
  void setBuildStandardCollection()
-
 
988
  {
-
 
989
    mBuildStandardCollection.clear();
-
 
990
    
-
 
991
    for (Iterator<BuildStandard> it = mTestBuildStandardCollection.iterator(); it.hasNext(); )
-
 
992
    {
-
 
993
      BuildStandard buildStandard = it.next();
-
 
994
      mBuildStandardCollection.add(buildStandard);
-
 
995
    }
-
 
996
  }
-
 
997
 
-
 
998
  /**sends email notification and marks the instruction complete in the database
-
 
999
   */
-
 
1000
  public void completeTestBuild( String mailServer, String mailSender, ReleaseManager releaseManager, String release, boolean success ) throws SQLException, Exception
-
 
1001
  {
-
 
1002
    mLogger.debug("completeTestBuild");
-
 
1003
    
-
 
1004
    if ( mTestBuildInstruction == 0)
-
 
1005
    {
-
 
1006
      return;
-
 
1007
    }
-
 
1008
    
-
 
1009
    String mailBody="Test build issues are identified in preceding build failure email.<p>" +
-
 
1010
                    "Release: " + release + "<br>" +
-
 
1011
                    "Package: " + mAlias + "<br>" +
-
 
1012
                    "Label: " + mLabel + "<br>" +
-
 
1013
                    "Location: " + mLocation + "<p>" +
-
 
1014
                    "Build dependencies:<p>";
-
 
1015
    
-
 
1016
    for (Iterator<Package> it3 = mPackageDependencyCollection.iterator(); it3.hasNext(); )
-
 
1017
    {
-
 
1018
      Package depend = it3.next();
-
 
1019
      
-
 
1020
      String dependsExtension = depend.mExtension;
-
 
1021
      String dependsVersion = depend.mVersion;
-
 
1022
      
-
 
1023
      if ( dependsExtension.length() > 0 )
-
 
1024
      {
-
 
1025
        dependsVersion += dependsExtension;
-
 
1026
      }
-
 
1027
      mailBody += "\'" + depend.mName + "\',\'" + dependsVersion + "\' <br>";
-
 
1028
    }
-
 
1029
 
-
 
1030
    mailBody += "<br>Build standards:<p>";
-
 
1031
 
-
 
1032
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
-
 
1033
    {
-
 
1034
      BuildStandard bs = it.next();
-
 
1035
      
-
 
1036
      String platform = bs.getPlatform(!ReleaseManager.mUseDatabase, false);
-
 
1037
    
-
 
1038
      if ( platform.length() > 0 )
-
 
1039
      {
-
 
1040
        mailBody += platform + ", ";
-
 
1041
      }
-
 
1042
 
-
 
1043
      String standard = bs.getBuildStandard(!ReleaseManager.mUseDatabase, false);
-
 
1044
      
-
 
1045
      if ( standard.length() > 0 )
-
 
1046
      {
-
 
1047
        mailBody += standard + "<br>";
-
 
1048
      }
-
 
1049
    }
-
 
1050
    
-
 
1051
    try
-
 
1052
    {
-
 
1053
      Smtpsend.send(
-
 
1054
      mailServer, // mailServer
-
 
1055
      mailSender, // source
-
 
1056
      emailInfoNonAntTask(), // target
-
 
1057
      null, // cc
-
 
1058
      null, // bcc
-
 
1059
      success == true ? "TEST BUILD COMPLETED SUCCESSFULLY" : "TEST BUILD FAILED", // subject
-
 
1060
      mailBody, // body
-
 
1061
      null // attachment
-
 
1062
      );
-
 
1063
    }
-
 
1064
    catch( Exception e )
-
 
1065
    {
-
 
1066
    }
-
 
1067
    
-
 
1068
    releaseManager.markDaemonInstCompletedConnect(mTestBuildInstruction);
-
 
1069
  }
-
 
1070
  
899
  /**entity class supporting the ERG version numbering standard:
1071
  /**entity class supporting the ERG version numbering standard:
900
   * <major>.<minor>.<patch/build>
1072
   * <major>.<minor>.<patch/build>
901
   * patch/build is at least a 4 digit number whose last 3 digits represent the build
1073
   * patch/build is at least a 4 digit number whose last 3 digits represent the build
902
   */
1074
   */
903
  public class VersionNumberingStandard
1075
  public class VersionNumberingStandard