All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.utils.props.VersionUtils Maven / Gradle / Ivy

package com.undefinedlabs.scope.utils.props;

import com.undefinedlabs.scope.utils.StringUtils;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Paths;

public class VersionUtils {

  public static String getAgentVersion() {
    final String version = SystemProps.class.getPackage().getImplementationVersion();
    if (StringUtils.isEmpty(version)) {
      try {
        // Special case when scope-java-agent project is tested.
        final URLClassLoader classLoader =
            new URLClassLoader(
                new URL[] {Paths.get("../.scope/scope-agent.jar").toUri().toURL()}, null);
        return classLoader
            .loadClass(SystemProps.class.getName())
            .getPackage()
            .getImplementationVersion();
      } catch (Exception e) {
        return "unknown";
      }
    }

    return version;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy