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

com.taobao.drc.clusterclient.util.ManifestUtils Maven / Gradle / Ivy

There is a newer version: 5.0.0.1.beta
Show newest version
package com.taobao.drc.clusterclient.util;

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by haikuo.zhk on 2017/7/21.
 */
public class ManifestUtils {

	private static final Logger logger = LoggerFactory.getLogger(ManifestUtils.class);

    public static String getVersion(Class clazz) throws IOException {
        MavenXpp3Reader reader = new MavenXpp3Reader();
        Model model;
        String pom_file="/META-INF/maven/com.aliyun.dts/consumer-core/pom.xml";
        try {
            model = reader.read(new InputStreamReader(ManifestUtils.class.getResourceAsStream(pom_file)));
        } catch (XmlPullParserException e) {
            logger.debug("pom_file:[{}],erro:[{}]",pom_file,e);
            return "4.8.2.12.2";
        }catch (Exception e) {
            logger.debug("pom_file:[{}],erro:[{}]",pom_file,e);
            return "4.8.2.12.2";
        }
        return model.getVersion();
    }

    public static String getArtifactId(Class clazz) throws IOException {
        MavenXpp3Reader reader = new MavenXpp3Reader();
        Model model;
        String pom_file="/META-INF/maven/com.aliyun.dts/consumer-core/pom.xml";
        try {
            model = reader.read(new InputStreamReader(ManifestUtils.class.getResourceAsStream(pom_file)));
        } catch (XmlPullParserException e) {
            logger.debug("pom_file:[{}],erro:[{}]",pom_file,e);
            return "consumer-core";
        }catch (Exception e) {
            logger.debug("pom_file:[{}],erro:[{}]",pom_file,e);
            return "consumer-core";
        }
        return model.getArtifactId();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy