Github user julienledem commented on a diff in the pull request:

    https://github.com/apache/drill/pull/622#discussion_r84139272
  
    --- Diff: exec/java-exec/src/main/codegen/templates/DrillVersionInfo.java 
---
    @@ -0,0 +1,97 @@
    
+/*******************************************************************************
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + 
******************************************************************************/
    +
    +<@pp.dropOutputFile />
    +
    +<@pp.changeOutputFile 
name="/org/apache/drill/common/util/DrillVersionInfo.java" />
    +
    +<#include "/@includes/license.ftl" />
    +
    +package org.apache.drill.common.util;
    +
    +import java.text.MessageFormat;
    +import java.text.ParseException;
    +
    +/**
    + * This file is generated with Freemarker using the template 
src/main/codegen/templates/DrillVersionInfo.java
    + */
    +public class DrillVersionInfo {
    +  private static final String VERSION = "${maven.version}";
    +
    +  private static final int MAJOR_VERSION;
    +  private static final int MINOR_VERSION;
    +  private static final int PATCH_VERSION;
    +
    +  static {
    +      final int[] parseResults;
    +      try {
    +        parseResults = parseVersion(VERSION);
    +        if (parseResults == null || parseResults.length < 3) {
    +          throw new AssertionError("An error occured when parsing Drill 
Version");
    +        }
    +      } catch(ParseException e) {
    +        throw new AssertionError("An error occured when parsing Drill 
Version", e);
    +      }
    +      MAJOR_VERSION = parseResults[0];
    +      MINOR_VERSION = parseResults[1];
    +      PATCH_VERSION = parseResults[2];
    +  }
    +
    +  static int[] parseVersion(String version) throws ParseException {
    +    final MessageFormat versionFormat = new 
MessageFormat("{0,number,integer}.{1,number,integer}.{2,number,integer}");
    +
    +    Object[] parseResult = versionFormat.parse(version);
    +    int[] result = new int[parseResult.length];
    +    for(int i = 0; i<parseResult.length; i++) {
    +      result[i] = ((Number) parseResult[i]).intValue();
    +    }
    +    
    +    return result;
    +  }
    +  /**
    +   * Get the Drill version from pom
    +   * @return the version number as x.y.z
    +   */
    +  public static String getVersion() {
    +    return VERSION;
    +  }
    +
    +  /**
    +   *  Get the Drill major version from pom
    +   *  @return x if assuming the version number is x.y.z
    +   */
    +  public static int getMajorVersion() {
    +    return MAJOR_VERSION;
    +  }
    +
    +  /**
    +   *  Get the Drill minor version from pom
    +   *  @return y if assuming the version number is x.y.z
    +   */
    +  public static int getMinorVersion() {
    +    return MINOR_VERSION;
    +  }
    +
    +  /**
    +   *  Get the Drill patch version from pom
    +   *  @return z if assuming the version number is x.y.z
    --- End diff --
    
    return z if assuming the version number is x.y.z{suffix}


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to