本文整理匯總了Java中org.apache.maven.model.Model.getVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.getVersion方法的具體用法?Java Model.getVersion怎麽用?Java Model.getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Model
的用法示例。
在下文中一共展示了Model.getVersion方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromPom
import org.apache.maven.model.Model; //導入方法依賴的package包/類
public static CarnotzetModuleCoordinates fromPom(@NonNull Path pom) {
Model result;
try {
BufferedReader in = new BufferedReader(Files.newBufferedReader(pom, StandardCharsets.UTF_8));
MavenXpp3Reader reader = new MavenXpp3Reader();
result = reader.read(in);
}
catch (XmlPullParserException | IOException e) {
throw new CarnotzetDefinitionException(e);
}
String groupId = result.getGroupId();
String version = result.getVersion();
if (groupId == null) {
groupId = result.getParent().getGroupId();
}
if (version == null) {
version = result.getParent().getVersion();
}
return new CarnotzetModuleCoordinates(groupId, result.getArtifactId(), version, null);
}
示例2: loadPomVariables
import org.apache.maven.model.Model; //導入方法依賴的package包/類
private void loadPomVariables() {
logger.debug("Loading maven pom.xml variables");
MavenXpp3Reader reader = new MavenXpp3Reader();
try {
Model model = reader.read(new FileReader("pom.xml"));
ARTIFACT_ID = model.getArtifactId();
VERSION = model.getVersion();
NAME = model.getName();
GROUP_ID = model.getGroupId();
} catch (IOException | XmlPullParserException e) {
e.printStackTrace();
}
}
示例3: getArtifactVersion
import org.apache.maven.model.Model; //導入方法依賴的package包/類
public String getArtifactVersion() {
Model model = getCurrentModel();
if (model!=null && model.getVersion()!=null) {
return model.getVersion();
}
model = getParentModel();
if (model!=null) {
return model.getVersion();
}
return null;
}
示例4: ProjectVersion
import org.apache.maven.model.Model; //導入方法依賴的package包/類
public ProjectVersion(File project) {
PomReader pomReader = new PomReader();
Model model = pomReader.readPom(project);
this.projectName = nameWithoutParent(model.getArtifactId());
this.version = model.getVersion();
this.model = model;
}
示例5: getPomVersion
import org.apache.maven.model.Model; //導入方法依賴的package包/類
public String getPomVersion(Model model) {
String result = model.getVersion();
if (result == null) {
throw new IllegalArgumentException("The artifact does not define a version.");
}
return result;
}