1273N/A/*
1273N/A * CDDL HEADER START
1273N/A *
1273N/A * The contents of this file are subject to the terms of the
1273N/A * Common Development and Distribution License, Version 1.0 only
1273N/A * (the "License"). You may not use this file except in compliance
1273N/A * with the License.
1273N/A *
6983N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6983N/A * or http://forgerock.org/license/CDDLv1.0.html.
1273N/A * See the License for the specific language governing permissions
1273N/A * and limitations under the License.
1273N/A *
1273N/A * When distributing Covered Code, include this CDDL HEADER in each
6983N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
6983N/A * If applicable, add the following below this CDDL HEADER, with the
6983N/A * fields enclosed by brackets "[]" replaced with your own identifying
6983N/A * information:
1273N/A * Portions Copyright [yyyy] [name of copyright owner]
1273N/A *
1273N/A * CDDL HEADER END
1273N/A *
1273N/A *
3231N/A * Copyright 2008 Sun Microsystems, Inc.
1273N/A */
1273N/Apackage org.opends.build.tools;
1273N/A
1273N/Aimport org.apache.tools.ant.taskdefs.condition.Condition;
1273N/Aimport org.apache.tools.ant.BuildException;
1273N/A
1273N/A/**
1273N/A * Ant condition to check whether we have a minimum required Java version.
1273N/A */
1273N/Apublic class ValidJavaVersion implements Condition
1273N/A{
1273N/A // The minimum required Java version.
1273N/A String minVersion;
1273N/A
1273N/A /**
1273N/A * Set the minVersion attribute.
1273N/A * @param minVersion The minimum required Java version.
1273N/A */
1273N/A public void setMinVersion(String minVersion)
1273N/A {
1273N/A this.minVersion = minVersion;
1273N/A }
1273N/A
1273N/A
1273N/A /**
1273N/A * Evaluate the condition.
1273N/A */
1273N/A public boolean eval() throws BuildException
1273N/A {
1273N/A if (minVersion == null)
1273N/A {
1273N/A return true;
1273N/A }
1273N/A
1273N/A String version = System.getProperty("java.version");
1273N/A if (version == null)
1273N/A {
1273N/A return false;
1273N/A }
1273N/A
1273N/A return version.compareTo(minVersion) >= 0;
1273N/A }
1273N/A}