1 package org.apache.maven.profiles.activation; 2 3 import org.apache.maven.model.Activation; 4 import org.apache.maven.model.Profile; 5 import org.codehaus.plexus.util.StringUtils; 6 7 22 23 public class JdkPrefixProfileActivator 24 extends DetectedProfileActivator 25 { 26 private static final String JDK_VERSION = System.getProperty( "java.version" ); 27 28 public boolean isActive( Profile profile ) 29 { 30 Activation activation = profile.getActivation(); 31 32 String jdk = activation.getJdk(); 33 34 boolean reverse = false; 35 36 if ( jdk.startsWith( "!" ) ) 37 { 38 reverse = true; 39 jdk = jdk.substring( 1 ); 40 } 41 42 boolean result = JDK_VERSION.startsWith( jdk ); 44 45 if ( reverse ) 46 { 47 return !result; 48 } 49 else 50 { 51 return result; 52 } 53 } 54 55 protected boolean canDetectActivation( Profile profile ) 56 { 57 return profile.getActivation() != null && StringUtils.isNotEmpty( profile.getActivation().getJdk() ); 58 } 59 60 } 61 | Popular Tags |