Rev 4123 | Blame | Last modification | View Log | RSS feed
package com.erggroup.buildtool.ripple;import java.util.Iterator;import org.apache.log4j.Logger;/**entity class representing how derived files are produced on a platform* recognises that a package may have different build standards on different platforms* for example, jats may be used to build production code on a win32 build machine and debug code on a solaris build machine* potentially supports mixing build standards* for example, jats may be used to build code on one build machine, and erg ant on another* this is not supported in the release manager*/public class BuildStandard{/**Logger* @attribute*/private static final Logger mLogger = Logger.getLogger(BuildStandard.class);/**engine associated with the baseline in which this packages build standard is owned* @aggregation composite*/private RippleEngine mRippleEngine;/**when true, the intent is to deliver Win32 derived content* in a daemon world, will be built on all Win32 based build machines associated with the baseline* will be accessed by Package::isWin32Built* @attribute*/private boolean mWin32 = true;/**when true, the intent is to deliver Solaris derived content* in a daemon world, will be built on all Solaris based build machines associated with the baseline* will be accessed by Package::isSolarisBuilt* @attribute*/private boolean mSolaris = false;/**when true, the intent is to deliver Linux derived content* in a daemon world, will be built on all Linux based build machines associated with the baseline* will be accessed by Package::isLinuxBuilt* @attribute*/private boolean mLinux = false;/**when true, the intent is to deliver generic content* in a daemon build, will be built only on the build machine configured to run the Master build thread associated with the baseline* @attribute*/private boolean mGeneric = false;/**when true, the intent is to deliver production code using jats* @attribute*/private boolean mProduction = true;/**when true, the intent is to deliver debug code using jats* @attribute*/private boolean mDebug = false;/**when true, the intent is to deliver java 1.4 built code* this is realized by using java 1.4 to launch ant* @attribute*/private boolean mJava1_4 = false;/**when true, the intent is to deliver java 1.5 built code* this is realized by using java 1.5 to launch ant* @attribute*/private boolean mJava1_5 = false;/**when true, the intent is to deliver java 1.6 built code* this is realized by using java 1.6 to launch ant* @attribute*/private boolean mJava1_6 = false;/**when true, the intent is to deliver java 1.7 built code this* is realized by using java 1.7 to launch ant* @attribute*/private boolean mJava1_7 = false;private boolean mJatsNone = false;private boolean mAntNone = false;private boolean mSupported = true;/**constructor*/BuildStandard(RippleEngine rippleEngine){mLogger.debug("BuildStandard");mRippleEngine = rippleEngine;}/**constructor*/BuildStandard(RippleEngine rippleEngine, String buildMachineFamily, String buildStandardAddendum){mLogger.debug("BuildStandard");mRippleEngine = rippleEngine;if ( buildMachineFamily.compareTo("Solaris") == 0 ){setSolaris();}else if ( buildMachineFamily.compareTo("Win32") == 0 ){setWin32();}else if ( buildMachineFamily.compareTo("Linux") == 0 ){setLinux();}else if ( buildMachineFamily.compareTo("Generic") == 0 ){setGeneric();}else{mSupported = false;}if ( buildStandardAddendum.compareTo("Production") == 0 ){setProduction();}else if ( buildStandardAddendum.compareTo("Debug") == 0 ){setDebug();}else if ( buildStandardAddendum.compareTo("Production and Debug") == 0 ){setAll();}else if ( buildStandardAddendum.compareTo("Java 1.4") == 0 ){set1_4();}else if ( buildStandardAddendum.compareTo("Java 1.5") == 0 ){set1_5();}else if ( buildStandardAddendum.compareTo("Java 1.6") == 0 ){set1_6();}else if ( buildStandardAddendum.compareTo("Java 1.7") == 0 ){set1_7();}else{mSupported = false;}}/**returns for xml purposes* "<platform gbe_machtype="win32"/>",* "<platform gbe_machtype="solaris10_sparc32"/>"* "<platform gbe_machtype="solaris10_x86"/>"* "<platform gbe_machtype="sparc"/>"* "<platform gbe_machtype="linux_i386"/>"** returns for non xml purposes* "win32",* "solaris10_sparc32"* "solaris10_x86"* "sparc"* "linux_i386"*/String getPlatform(boolean utf, boolean xml){mLogger.debug("getPlatform");String retVal = new String();if (mGeneric && mRippleEngine.mDaemon){mLogger.info("getPlatform mGeneric && mRippleEngine.mDaemon");if ( xml ){retVal = " <platform gbe_machtype=\"";}if ( utf ){mLogger.info("getPlatform utf");// avoid reliance on environment variablesretVal += "win32\"/>";}else{// Package.mGenericMachtype has been checked to be not nullif ( Package.mGenericMachtype.compareTo("win32") == 0|| Package.mGenericMachtype.compareTo("solaris10_sparc32") == 0|| Package.mGenericMachtype.compareTo("solaris10_x86") == 0|| Package.mGenericMachtype.compareTo("sparc") == 0|| Package.mGenericMachtype.compareTo("linux_i386") == 0 ){retVal += Package.mGenericMachtype;if ( xml ){retVal += "\"/>";}}}}else if (mGeneric){mLogger.info("getPlatform mGeneric");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("win32") == 0 ||gbemachtype.compareTo("linux_i386") == 0 ||gbemachtype.compareTo("sparc") == 0 ||gbemachtype.compareTo("solaris10_x86") == 0 ||gbemachtype.compareTo("solaris10_sparc32") == 0 ){if ( retVal.length() > 0 ){retVal += System.getProperty("line.separator");}if ( xml ){retVal += " <platform gbe_machtype=\"";}retVal += gbemachtype;if ( xml ){retVal += "\"/>";}}}}else if (mWin32){mLogger.info("getPlatform mWin32");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("win32") == 0 ){if ( xml ){retVal = " <platform gbe_machtype=\"win32\"/>";}else{retVal = "win32";}break;}}}else if (mSolaris){mLogger.info("getPlatform mSolaris");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("sparc") == 0 || gbemachtype.compareTo("solaris10_x86") == 0 || gbemachtype.compareTo("solaris10_sparc32") == 0 ){if ( retVal.length() > 0 ){if ( xml ){retVal += System.getProperty("line.separator");}else{retVal += "<br>";}}if ( xml ){retVal += " <platform gbe_machtype=\"";}retVal += gbemachtype;if ( xml ){retVal += "\"/>";}}}}else{mLogger.info("getPlatform mLinux");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("linux_i386") == 0 ){if ( xml ){retVal = " <platform gbe_machtype=\"linux_i386\"/>";}else{retVal = "linux_i386";}break;}}}mLogger.info("getPlatform returned " + retVal);return retVal;}/**returns for xml purposes* "<ant java="1.4"/>",* "<ant java="1.5"/>",* "<ant java="1.6"/>",* "<ant java="none"/>",* "<jats target="production"/>",* "<jats target="debug"/>",* "<jats target="all"/>",* "<jats target="none"/>"** returns for non xml purposes* "ant java 1.4",* "ant java 1.5",* "ant java 1.6",* "ant java 1.7",* "ant none",* "jats production",* "jats debug",* "jats all",* "jats none"*/String getBuildStandard(boolean utf, boolean xml){mLogger.debug("getBuildStandard");boolean validPlatform = false;int numberOfPlatforms = 0;String retVal = new String();if (mGeneric && mRippleEngine.mDaemon){mLogger.info("getBuildStandard mGeneric && mRippleEngine.mDaemon");if ( utf ){mLogger.info("getBuildStandard utf");// avoid reliance on environment variablesvalidPlatform = true;numberOfPlatforms = 1;}else{// Package.mGenericMachtype has been checked to be not nullif ( Package.mGenericMachtype.compareTo("win32") == 0|| Package.mGenericMachtype.compareTo("solaris10_sparc32") == 0|| Package.mGenericMachtype.compareTo("solaris10_x86") == 0|| Package.mGenericMachtype.compareTo("sparc") == 0|| Package.mGenericMachtype.compareTo("linux_i386") == 0 ){validPlatform = true;numberOfPlatforms = 1;}}}else if (mGeneric){mLogger.info("getBuildStandard mGeneric");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("win32") == 0 ||gbemachtype.compareTo("linux_i386") == 0 ||gbemachtype.compareTo("sparc") == 0 ||gbemachtype.compareTo("solaris10_x86") == 0 ||gbemachtype.compareTo("solaris10_sparc32") == 0 ){validPlatform = true;numberOfPlatforms++;}}}else if (mWin32){mLogger.info("getBuildStandard mWin32");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("win32") == 0 ){validPlatform = true;numberOfPlatforms = 1;break;}}}else if (mSolaris){mLogger.info("getBuildStandard mSolaris");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("sparc") == 0 || gbemachtype.compareTo("solaris10_x86") == 0 || gbemachtype.compareTo("solaris10_sparc32") == 0 ){validPlatform = true;numberOfPlatforms++;}}}else{mLogger.info("getBuildStandard mLinux");for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); ){String gbemachtype = it.next();if ( gbemachtype.compareTo("linux_i386") == 0 ){validPlatform = true;numberOfPlatforms = 1;break;}}}if (validPlatform){if (mJava1_4){if ( xml ){retVal = " <ant java=\"1.4\"/>";}else{retVal = "ant java 1.4";}}else if (mJava1_5){if ( xml ){retVal = " <ant java=\"1.5\"/>";}else{retVal = "ant java 1.5";}}else if (mJava1_6){if ( xml ){retVal = " <ant java=\"1.6\"/>";}else{retVal = "ant java 1.6";}}else if (mJava1_7){if ( xml ){retVal = " <ant java=\"1.7\"/>";}else{retVal = "ant java 1.7";}}else if (mAntNone){if ( xml ){retVal = " <ant java=\"none\"/>";}else{retVal = "ant none";}}else if (mJatsNone){if ( xml ){retVal = " <jats target=\"none\"/>";}else{retVal = "jats none";}}else{if (mProduction){if (mDebug){if ( xml ){retVal = " <jats target=\"all\"/>";}else{retVal = "jats all";}}else{if ( xml ){retVal = " <jats target=\"production\"/>";}else{retVal = "jats production";}}}else{if ( xml ){retVal = " <jats target=\"debug\"/>";}else{retVal = "jats debug";}}}String line = new String(retVal);for ( int i = 1; i < numberOfPlatforms; i++ ){if ( xml ){retVal += System.getProperty("line.separator");}else{retVal += "<br>";}retVal += line;}}mLogger.info("getBuildStandard returned " + retVal);return retVal;}/** reset the parameters associated with the build standard*/void resetBuildStandard(){mDebug = false;mProduction = false;mJava1_4 = false;mJava1_5 = false;mJava1_6 = false;mJava1_7 = false;mAntNone = false;mJatsNone = false;}/**sets mDebug true, mProduction false, mJava1_4 false, mJava1_5 false, mJava1_6 false*/void setDebug(){mLogger.debug("setDebug");resetBuildStandard();mDebug = true;}/**sets mDebug false, mProduction true, mJava1_4 false, mJava1_5 false, mJava1_6 false*/void setProduction(){mLogger.debug("setProduction");resetBuildStandard();mProduction = true;}/**sets mDebug true, mProduction true, mJava1_4 false, mJava1_5 false, mJava1_6 false*/void setAll(){mLogger.debug("setAll");resetBuildStandard();mDebug = true;mProduction = true;}/**sets mDebug false, mProduction false, mJava1_4 true, mJava1_5 false, mJava1_6 false*/void set1_4(){mLogger.debug("set1_4");resetBuildStandard();mJava1_4 = true;}/**sets mDebug false, mProduction false, mJava1_4 false, mJava1_5 true, mJava1_6 false*/void set1_5(){mLogger.debug("set1_5");resetBuildStandard();mJava1_5 = true;}/**sets mDebug false, mProduction false, mJava1_4 false, mJava1_5 false, mJava1_6 true*/void set1_6(){mLogger.debug("set1_6");resetBuildStandard();mJava1_6 = true;}/**sets mDebug false, mProduction false, mJava1_4 false,* mJava1_5 false, mJava1_7 true*/void set1_7(){mLogger.debug("set1_7");resetBuildStandard();mJava1_7 = true;}void setAntNone(){mLogger.debug("setAntNone");resetBuildStandard();mAntNone = true;}void setJatsNone(){mLogger.debug("setJatsNone");resetBuildStandard();mJatsNone = true;}/** reset parameters associated with config of the build machine*/void resetBuildMachineFamily(){mLinux = false;mSolaris = false;mWin32 = false;mGeneric = false;}/**sets mGeneric true*/void setGeneric(){mLogger.debug("setGeneric");resetBuildMachineFamily();mGeneric = true;}/**sets mLinux true, mSolaris false, mWin32 false*/void setLinux(){mLogger.debug("setLinux");resetBuildMachineFamily();mLinux = true;}/**sets mLinux false, mSolaris true, mWin32 false*/void setSolaris(){mLogger.debug("setSolaris");resetBuildMachineFamily();mSolaris = true;}/**sets mLinux false, mSolaris false, mWin32 true*/void setWin32(){mLogger.debug("setWin32");resetBuildMachineFamily();mWin32 = true;}/**sets mGeneric false*/void clearGeneric(){mLogger.debug("clearGeneric");mGeneric = false;}/**accessor method*/boolean getWin32(){mLogger.debug("getWin32");mLogger.info("getWin32 returned " + mWin32);return mWin32;}/**accessor method*/boolean getGeneric(){mLogger.debug("getGeneric");mLogger.info("getGeneric returned " + mGeneric);return mGeneric;}/**accessor method*/boolean getSolaris(){mLogger.debug("getSolaris");mLogger.info("getSolaris returned " + mSolaris);return mSolaris;}/**accessor method*/boolean getLinux(){mLogger.debug("getLinux");mLogger.info("getLinux returned " + mLinux);return mLinux;}/**accessor method*/boolean supportedBuildStandard(){mLogger.debug("supportedBuildStandard");mLogger.info("supportedBuildStandard returned " + mSupported);return mSupported;}}