Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B5E59ED22 for ; Tue, 25 Jun 2013 20:09:46 +0000 (UTC) Received: (qmail 82719 invoked by uid 500); 25 Jun 2013 20:09:46 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 82675 invoked by uid 500); 25 Jun 2013 20:09:46 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 82668 invoked by uid 99); 25 Jun 2013 20:09:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jun 2013 20:09:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jun 2013 20:09:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7D1422388C8B for ; Tue, 25 Jun 2013 20:08:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r867426 [30/34] - in /websites/production/maven/content/enforcer-archives/enforcer-LATEST: ./ apidocs/ apidocs/org/apache/maven/plugins/enforcer/ apidocs/src-html/org/apache/maven/plugins/enforcer/ enforcer-api/ enforcer-rules/ enforcer-rul... Date: Tue, 25 Jun 2013 20:07:47 -0000 To: commits@maven.apache.org From: rfscholte@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130625200800.7D1422388C8B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: websites/production/maven/content/enforcer-archives/enforcer-LATEST/enforcer-rules/xref/org/apache/maven/plugins/enforcer/RequireOS.html ============================================================================== --- websites/production/maven/content/enforcer-archives/enforcer-LATEST/enforcer-rules/xref/org/apache/maven/plugins/enforcer/RequireOS.html (original) +++ websites/production/maven/content/enforcer-archives/enforcer-LATEST/enforcer-rules/xref/org/apache/maven/plugins/enforcer/RequireOS.html Tue Jun 25 20:07:43 2013 @@ -47,7 +47,7 @@ 37 * is exactly the same as the Maven Os profile activation so the same values are allowed here. 38 * 39 * @author <a href="mailto:brianf@apache.org">Brian Fox</a> -40 * @version $Id: RequireOS.java 1493576 2013-06-16 20:10:59Z rfscholte $ +40 * @version $Id: RequireOS.java 1496229 2013-06-24 21:43:56Z rfscholte $ 41 */ 42 public class RequireOS 43 extends AbstractStandardEnforcerRule @@ -68,325 +68,357 @@ 58 * <li>z/os</li> 59 * <li>os/400</li> 60 * </ul> -61 */ -62 private String family = null; -63 -64 /** The OS name desired. */ -65 private String name = null; -66 -67 /** The OS version desired. */ -68 private String version = null; -69 -70 /** The OS architecture desired. */ -71 private String arch = null; -72 -73 /** Specify an optional message to the user if the rule fails. */ -74 private String message = ""; +61 * +62 * @deprecated the visibility will be reduced to private with the next major version +63 * @see {@link #setFamily(String)} +64 * @see {@link #getFamily()} +65 */ +66 public String family = null; +67 +68 /** The OS name desired. +69 * +70 * @deprecated the visibility will be reduced to private with the next major version +71 * @see {@link #setName(String)} +72 * @see {@link #getName()} +73 */ +74 public String name = null; 75 -76 /** Display detected OS information. */ -77 private boolean display = false; -78 -79 /** -80 * Instantiates a new RequireOS. +76 /** The OS version desired. +77 * +78 * @deprecated the visibility will be reduced to private with the next major version +79 * @see {@link #setVersion(String)} +80 * @see {@link #getVersion()} 81 */ -82 public RequireOS() -83 { -84 -85 } -86 -87 /* -88 * (non-Javadoc) -89 * -90 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper) -91 */ -92 public void execute( EnforcerRuleHelper helper ) -93 throws EnforcerRuleException -94 { -95 -96 displayOSInfo( helper.getLog(), display ); -97 -98 if ( allParamsEmpty() ) -99 { -100 throw new EnforcerRuleException( "All parameters can not be empty. You must pick at least one of (family, name, version, arch) or use -Denforcer.os.display=true to see the current OS information." ); -101 } -102 -103 if ( isValidFamily( this.family ) ) -104 { -105 if ( !isAllowed() ) -106 { -107 if ( StringUtils.isEmpty( message ) ) -108 { -109 message = -110 ( "OS Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME + " Version: " -111 + Os.OS_VERSION + " is not allowed by" + ( arch != null ? " Arch=" + arch : "" ) -112 + ( family != null ? " Family=" + family : "" ) + ( name != null ? " Name=" + name : "" ) + ( version != null ? " Version=" -113 + version -114 : "" ) ); -115 } -116 throw new EnforcerRuleException( message ); -117 } -118 } -119 else +82 public String version = null; +83 +84 /** The OS architecture desired. +85 * +86 * @deprecated the visibility will be reduced to private with the next major version +87 * @see {@link #setArch(String)} +88 * @see {@link #getArch()} +89 */ +90 public String arch = null; +91 +92 /** Display detected OS information. +93 * +94 * @deprecated the visibility will be reduced to private with the next major version +95 * @see {@link #setDisplay(boolean)} +96 * @see {@link #isDisplay()} +97 * */ +98 public boolean display = false; +99 +100 /** +101 * Instantiates a new RequireOS. +102 */ +103 public RequireOS() +104 { +105 +106 } +107 +108 /* +109 * (non-Javadoc) +110 * +111 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper) +112 */ +113 public void execute( EnforcerRuleHelper helper ) +114 throws EnforcerRuleException +115 { +116 +117 displayOSInfo( helper.getLog(), display ); +118 +119 if ( allParamsEmpty() ) 120 { -121 StringBuilder buffer = new StringBuilder( 50 ); -122 Iterator iter = Os.getValidFamilies().iterator(); -123 while ( iter.hasNext() ) -124 { -125 buffer.append( iter.next() ); -126 buffer.append( ", " ); -127 } -128 String help = StringUtils.stripEnd( buffer.toString().trim(), "." ); -129 throw new EnforcerRuleException( "Invalid Family type used. Valid family types are: " + help ); -130 } -131 } -132 -133 /** -134 * Log the current OS information. -135 * -136 * @param log the log -137 * @param info the info -138 */ -139 public void displayOSInfo( Log log, boolean info ) -140 { -141 String string = -142 "OS Info: Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME + " Version: " -143 + Os.OS_VERSION; -144 -145 if ( !info ) -146 { -147 log.debug( string ); -148 } -149 else -150 { -151 log.info( string ); +121 throw new EnforcerRuleException( "All parameters can not be empty. You must pick at least one of (family, name, version, arch) or use -Denforcer.os.display=true to see the current OS information." ); +122 } +123 +124 if ( isValidFamily( this.family ) ) +125 { +126 if ( !isAllowed() ) +127 { +128 String message = getMessage(); +129 if ( StringUtils.isEmpty( message ) ) +130 { +131 message = +132 ( "OS Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME + " Version: " +133 + Os.OS_VERSION + " is not allowed by" + ( arch != null ? " Arch=" + arch : "" ) +134 + ( family != null ? " Family=" + family : "" ) + ( name != null ? " Name=" + name : "" ) + ( version != null ? " Version=" +135 + version +136 : "" ) ); +137 } +138 throw new EnforcerRuleException( message ); +139 } +140 } +141 else +142 { +143 StringBuilder buffer = new StringBuilder( 50 ); +144 Iterator iter = Os.getValidFamilies().iterator(); +145 while ( iter.hasNext() ) +146 { +147 buffer.append( iter.next() ); +148 buffer.append( ", " ); +149 } +150 String help = StringUtils.stripEnd( buffer.toString().trim(), "." ); +151 throw new EnforcerRuleException( "Invalid Family type used. Valid family types are: " + help ); 152 } 153 } 154 155 /** -156 * Helper method to determine if the current OS is allowed based on the injected values for family, name, version -157 * and arch. -158 * -159 * @return true if the version is allowed. +156 * Log the current OS information. +157 * +158 * @param log the log +159 * @param info the info 160 */ -161 public boolean isAllowed() +161 public void displayOSInfo( Log log, boolean info ) 162 { -163 OperatingSystemProfileActivator activator = new OperatingSystemProfileActivator(); -164 -165 return activator.isActive( createProfile() ); -166 } -167 -168 /** -169 * Helper method to check that at least one of family, name, version or arch is set. -170 * -171 * @return true if all parameters are empty. -172 */ -173 public boolean allParamsEmpty() -174 { -175 return ( StringUtils.isEmpty( family ) && StringUtils.isEmpty( arch ) && StringUtils.isEmpty( name ) && StringUtils.isEmpty( version ) ); +163 String string = +164 "OS Info: Arch: " + Os.OS_ARCH + " Family: " + Os.OS_FAMILY + " Name: " + Os.OS_NAME + " Version: " +165 + Os.OS_VERSION; +166 +167 if ( !info ) +168 { +169 log.debug( string ); +170 } +171 else +172 { +173 log.info( string ); +174 } +175 } 176 -177 } -178 -179 /** -180 * Creates a Profile object that contains the activation information. -181 * -182 * @return a properly populated profile to be used for OS validation. -183 */ -184 private Profile createProfile() -185 { -186 Profile profile = new Profile(); -187 profile.setActivation( createActivation() ); -188 return profile; -189 } -190 -191 /** -192 * Creates an Activation object that contains the ActivationOS information. -193 * -194 * @return a properly populated Activation object. -195 */ -196 private Activation createActivation() -197 { -198 Activation activation = new Activation(); -199 activation.setActiveByDefault( false ); -200 activation.setOs( createOsBean() ); -201 return activation; -202 } -203 -204 /** -205 * Creates an ActivationOS object containing family, name, version and arch. -206 * -207 * @return a properly populated ActivationOS object. -208 */ -209 private ActivationOS createOsBean() -210 { -211 ActivationOS os = new ActivationOS(); +177 /** +178 * Helper method to determine if the current OS is allowed based on the injected values for family, name, version +179 * and arch. +180 * +181 * @return true if the version is allowed. +182 */ +183 public boolean isAllowed() +184 { +185 OperatingSystemProfileActivator activator = new OperatingSystemProfileActivator(); +186 +187 return activator.isActive( createProfile() ); +188 } +189 +190 /** +191 * Helper method to check that at least one of family, name, version or arch is set. +192 * +193 * @return true if all parameters are empty. +194 */ +195 public boolean allParamsEmpty() +196 { +197 return ( StringUtils.isEmpty( family ) && StringUtils.isEmpty( arch ) && StringUtils.isEmpty( name ) && StringUtils.isEmpty( version ) ); +198 +199 } +200 +201 /** +202 * Creates a Profile object that contains the activation information. +203 * +204 * @return a properly populated profile to be used for OS validation. +205 */ +206 private Profile createProfile() +207 { +208 Profile profile = new Profile(); +209 profile.setActivation( createActivation() ); +210 return profile; +211 } 212 -213 os.setArch( arch ); -214 os.setFamily( family ); -215 os.setName( name ); -216 os.setVersion( version ); -217 -218 return os; -219 } -220 -221 /** -222 * Helper method to check if the given family is in the following list: -223 * <ul> -224 * <li>dos</li> -225 * <li>mac</li> -226 * <li>netware</li> -227 * <li>os/2</li> -228 * <li>tandem</li> -229 * <li>unix</li> -230 * <li>windows</li> -231 * <li>win9x</li> -232 * <li>z/os</li> -233 * <li>os/400</li> -234 * </ul> -235 * Note: '!' is allowed at the beginning of the string and still considered valid. -236 * -237 * @param theFamily the family to check. -238 * @return true if one of the valid families. -239 */ -240 public boolean isValidFamily( String theFamily ) -241 { +213 /** +214 * Creates an Activation object that contains the ActivationOS information. +215 * +216 * @return a properly populated Activation object. +217 */ +218 private Activation createActivation() +219 { +220 Activation activation = new Activation(); +221 activation.setActiveByDefault( false ); +222 activation.setOs( createOsBean() ); +223 return activation; +224 } +225 +226 /** +227 * Creates an ActivationOS object containing family, name, version and arch. +228 * +229 * @return a properly populated ActivationOS object. +230 */ +231 private ActivationOS createOsBean() +232 { +233 ActivationOS os = new ActivationOS(); +234 +235 os.setArch( arch ); +236 os.setFamily( family ); +237 os.setName( name ); +238 os.setVersion( version ); +239 +240 return os; +241 } 242 -243 // in case they are checking !family -244 theFamily = StringUtils.stripStart( theFamily, "!" ); -245 -246 return ( StringUtils.isEmpty( theFamily ) || Os.getValidFamilies().contains( theFamily ) ); -247 } -248 -249 /** -250 * Gets the arch. -251 * -252 * @return the arch -253 */ -254 public String getArch() -255 { -256 return this.arch; -257 } -258 -259 /** -260 * Sets the arch. -261 * -262 * @param theArch the arch to set -263 */ -264 public void setArch( String theArch ) -265 { -266 this.arch = theArch; -267 } -268 -269 /** -270 * Gets the family. -271 * -272 * @return the family -273 */ -274 public String getFamily() -275 { -276 return this.family; -277 } -278 -279 /** -280 * Sets the family. -281 * -282 * @param theFamily the family to set -283 */ -284 public void setFamily( String theFamily ) -285 { -286 this.family = theFamily; -287 } -288 -289 /** -290 * Gets the name. -291 * -292 * @return the name -293 */ -294 public String getName() -295 { -296 return this.name; -297 } -298 -299 /** -300 * Sets the name. -301 * -302 * @param theName the name to set -303 */ -304 public void setName( String theName ) -305 { -306 this.name = theName; -307 } -308 -309 /** -310 * Gets the version. -311 * -312 * @return the version -313 */ -314 public String getVersion() -315 { -316 return this.version; -317 } -318 -319 /** -320 * Sets the version. -321 * -322 * @param theVersion the version to set -323 */ -324 public void setVersion( String theVersion ) -325 { -326 this.version = theVersion; -327 } -328 -329 /* -330 * (non-Javadoc) -331 * -332 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId() -333 */ -334 public String getCacheId() -335 { -336 // return the hashcodes of all the parameters -337 StringBuffer b = new StringBuffer(); -338 if ( StringUtils.isNotEmpty( version ) ) -339 { -340 b.append( version.hashCode() ); -341 } -342 if ( StringUtils.isNotEmpty( name ) ) -343 { -344 b.append( name.hashCode() ); -345 } -346 if ( StringUtils.isNotEmpty( arch ) ) -347 { -348 b.append( arch.hashCode() ); -349 } -350 if ( StringUtils.isNotEmpty( family ) ) -351 { -352 b.append( family.hashCode() ); -353 } -354 return b.toString(); -355 } -356 -357 /* -358 * (non-Javadoc) -359 * -360 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable() -361 */ -362 public boolean isCacheable() -363 { -364 // the os is not going to change between projects in the same build. -365 return true; -366 } -367 -368 /* -369 * (non-Javadoc) -370 * -371 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule) -372 */ -373 public boolean isResultValid( EnforcerRule theCachedRule ) -374 { -375 // i will always return the hash of the parameters as my id. If my parameters are the same, this -376 // rule must always have the same result. -377 return true; -378 } -379 } +243 /** +244 * Helper method to check if the given family is in the following list: +245 * <ul> +246 * <li>dos</li> +247 * <li>mac</li> +248 * <li>netware</li> +249 * <li>os/2</li> +250 * <li>tandem</li> +251 * <li>unix</li> +252 * <li>windows</li> +253 * <li>win9x</li> +254 * <li>z/os</li> +255 * <li>os/400</li> +256 * </ul> +257 * Note: '!' is allowed at the beginning of the string and still considered valid. +258 * +259 * @param theFamily the family to check. +260 * @return true if one of the valid families. +261 */ +262 public boolean isValidFamily( String theFamily ) +263 { +264 +265 // in case they are checking !family +266 theFamily = StringUtils.stripStart( theFamily, "!" ); +267 +268 return ( StringUtils.isEmpty( theFamily ) || Os.getValidFamilies().contains( theFamily ) ); +269 } +270 +271 /** +272 * Gets the arch. +273 * +274 * @return the arch +275 */ +276 public String getArch() +277 { +278 return this.arch; +279 } +280 +281 /** +282 * Sets the arch. +283 * +284 * @param theArch the arch to set +285 */ +286 public void setArch( String theArch ) +287 { +288 this.arch = theArch; +289 } +290 +291 /** +292 * Gets the family. +293 * +294 * @return the family +295 */ +296 public String getFamily() +297 { +298 return this.family; +299 } +300 +301 /** +302 * Sets the family. +303 * +304 * @param theFamily the family to set +305 */ +306 public void setFamily( String theFamily ) +307 { +308 this.family = theFamily; +309 } +310 +311 /** +312 * Gets the name. +313 * +314 * @return the name +315 */ +316 public String getName() +317 { +318 return this.name; +319 } +320 +321 /** +322 * Sets the name. +323 * +324 * @param theName the name to set +325 */ +326 public void setName( String theName ) +327 { +328 this.name = theName; +329 } +330 +331 /** +332 * Gets the version. +333 * +334 * @return the version +335 */ +336 public String getVersion() +337 { +338 return this.version; +339 } +340 +341 /** +342 * Sets the version. +343 * +344 * @param theVersion the version to set +345 */ +346 public void setVersion( String theVersion ) +347 { +348 this.version = theVersion; +349 } +350 +351 public final void setDisplay( boolean display ) +352 { +353 this.display = display; +354 } +355 +356 public final boolean isDisplay() +357 { +358 return display; +359 } +360 +361 /* +362 * (non-Javadoc) +363 * +364 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#getCacheId() +365 */ +366 public String getCacheId() +367 { +368 // return the hashcodes of all the parameters +369 StringBuffer b = new StringBuffer(); +370 if ( StringUtils.isNotEmpty( version ) ) +371 { +372 b.append( version.hashCode() ); +373 } +374 if ( StringUtils.isNotEmpty( name ) ) +375 { +376 b.append( name.hashCode() ); +377 } +378 if ( StringUtils.isNotEmpty( arch ) ) +379 { +380 b.append( arch.hashCode() ); +381 } +382 if ( StringUtils.isNotEmpty( family ) ) +383 { +384 b.append( family.hashCode() ); +385 } +386 return b.toString(); +387 } +388 +389 /* +390 * (non-Javadoc) +391 * +392 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isCacheable() +393 */ +394 public boolean isCacheable() +395 { +396 // the os is not going to change between projects in the same build. +397 return true; +398 } +399 +400 /* +401 * (non-Javadoc) +402 * +403 * @see org.apache.maven.enforcer.rule.api.EnforcerRule#isResultValid(org.apache.maven.enforcer.rule.api.EnforcerRule) +404 */ +405 public boolean isResultValid( EnforcerRule theCachedRule ) +406 { +407 // i will always return the hash of the parameters as my id. If my parameters are the same, this +408 // rule must always have the same result. +409 return true; +410 } +411 }