com.taobao.drc.clusterclient.util.ManifestUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of consumer-core Show documentation
Show all versions of consumer-core Show documentation
The java consumer core component for Data Transmission Service
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();
}
}