本文整理匯總了Java中org.apache.maven.model.Dependency.getVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java Dependency.getVersion方法的具體用法?Java Dependency.getVersion怎麽用?Java Dependency.getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Dependency
的用法示例。
在下文中一共展示了Dependency.getVersion方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDependencyFromCoordinates
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
static Dependency createDependencyFromCoordinates(String coordinatesString, boolean excludeTransitive) {
final String[] coordinates = coordinatesString.split(":");
int amountOfCoordinates = coordinates.length;
if (amountOfCoordinates < 2) {
throw new IllegalArgumentException(
"Coordinates of the specified strategy [" + coordinatesString + "] doesn't have the correct format.");
}
final Dependency dependency = new Dependency();
dependency.setGroupId(coordinates[0]);
dependency.setArtifactId(coordinates[1]);
if (amountOfCoordinates == 3) {
dependency.setVersion(coordinates[2]);
} else if (amountOfCoordinates >= 4) {
dependency.setType(coordinates[2].isEmpty() ? "jar" : coordinates[2]);
dependency.setClassifier(coordinates[3]);
}
if (amountOfCoordinates >= 5) {
dependency.setVersion(coordinates[4]);
}
if (amountOfCoordinates == 6) {
dependency.setScope(coordinates[5]);
}
if (dependency.getVersion() == null || dependency.getVersion().isEmpty()) {
dependency.setVersion(ExtensionVersion.version().toString());
}
if (excludeTransitive) {
Exclusion exclusion = new Exclusion();
exclusion.setGroupId("*");
exclusion.setArtifactId("*");
dependency.setExclusions(Arrays.asList(exclusion));
}
return dependency;
}
示例2: convertDependencyToJarArtifact
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private static Artifact convertDependencyToJarArtifact(Dependency dependency) {
String groupId = dependency.getGroupId();
String artifactId = dependency.getArtifactId();
String version = dependency.getVersion();
String scope = dependency.getScope();
String type = dependency.getType();
String classifier = dependency.getClassifier();
DefaultArtifact artifact = new DefaultArtifact(groupId, artifactId, version, scope, type, classifier, JAR_ARTIFACT_HANDLER);
return artifact;
}
示例3: toId
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private String toId (Dependency dependency) {
return dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion();
}
示例4: checkRunTest
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
static boolean checkRunTest(final RunConfig config) {
String actionName = config.getActionName();
if (!(ActionProvider.COMMAND_TEST_SINGLE.equals(actionName) ||
ActionProvider.COMMAND_DEBUG_TEST_SINGLE.equals(actionName) ||
ActionProvider.COMMAND_PROFILE_TEST_SINGLE.equals(actionName))) {
return true;
}
if (RunUtils.hasTestCompileOnSaveEnabled(config)) {
String testng = PluginPropertyUtils.getPluginProperty(config.getMavenProject(), Constants.GROUP_APACHE_PLUGINS,
Constants.PLUGIN_SUREFIRE, "testNGArtifactName", "test", "testNGArtifactName"); //NOI18N
if (testng == null) {
testng = "org.testng:testng"; //NOI18N
}
List<Dependency> deps = config.getMavenProject().getTestDependencies();
boolean haveJUnit = false, haveTestNG = false;
String testngVersion = null;
for (Dependency d : deps) {
if (d.getManagementKey().startsWith(testng)) {
testngVersion = d.getVersion();
haveTestNG = true;
} else if (d.getManagementKey().startsWith("junit:junit")) { //NOI18N
haveJUnit = true;
}
}
if (haveJUnit && haveTestNG && new ComparableVersion("6.5.1").compareTo(new ComparableVersion(testngVersion)) >= 0) {
//CoS requires at least TestNG 6.5.2-SNAPSHOT if JUnit is present
return true;
}
String test = config.getProperties().get("test"); //NOI18N
if (test == null) {
//user somehow configured mapping in unknown way.
return true;
}
long stamp = CosChecker.getLastCoSLastTouch(config, true);
//check the COS timestamp against critical files (pom.xml)
// if changed, don't do COS.
if (CosChecker.checkImportantFiles(stamp, config)) {
return true;
}
//check the COS timestamp against resources etc.
//if changed, perform part of the maven build. (or skip COS)
for (CompileOnSaveSkipper skipper : Lookup.getDefault().lookupAll(CompileOnSaveSkipper.class)) {
if (skipper.skip(config, true, stamp)) {
return true;
}
}
return OldJavaRunnerCOS.deprecatedJavaRunnerApproachTest(config, actionName);
} else {
CosChecker.warnNoTestCoS(config);
return true;
}
}
示例5: checkRunTest
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private void checkRunTest(final RunConfig config, ExecutionContext con) {
String actionName = config.getActionName();
if (!(ActionProvider.COMMAND_TEST_SINGLE.equals(actionName) ||
ActionProvider.COMMAND_DEBUG_TEST_SINGLE.equals(actionName) ||
ActionProvider.COMMAND_PROFILE_TEST_SINGLE.equals(actionName))) {
return;
}
if (RunUtils.isCompileOnSaveEnabled(config)) {
String testng = PluginPropertyUtils.getPluginProperty(config.getMavenProject(), Constants.GROUP_APACHE_PLUGINS,
Constants.PLUGIN_SUREFIRE, "testNGArtifactName", "test", "testNGArtifactName"); //NOI18N
if (testng == null) {
testng = "org.testng:testng"; //NOI18N
}
List<Dependency> deps = config.getMavenProject().getTestDependencies();
boolean haveJUnit = false, haveTestNG = false;
String testngVersion = null;
for (Dependency d : deps) {
if (d.getManagementKey().startsWith(testng)) {
testngVersion = d.getVersion();
haveTestNG = true;
} else if (d.getManagementKey().startsWith("junit:junit")) { //NOI18N
haveJUnit = true;
}
}
if (haveJUnit && haveTestNG && new ComparableVersion("6.5.1").compareTo(new ComparableVersion(testngVersion)) >= 0) {
//CoS requires at least TestNG 6.5.2-SNAPSHOT if JUnit is present
return;
}
long stamp = getLastCoSLastTouch(config, true);
//check the COS timestamp against critical files (pom.xml)
// if changed, don't do COS.
if (checkImportantFiles(stamp, config)) {
return;
}
//check the COS timestamp against resources etc.
//if changed, perform part of the maven build. (or skip COS)
for (CompileOnSaveSkipper skipper : Lookup.getDefault().lookupAll(CompileOnSaveSkipper.class)) {
if (skipper.skip(config, true, stamp)) {
return;
}
}
//now attempt to extract
if (config instanceof BeanRunConfig) {
BeanRunConfig brc = (BeanRunConfig) config;
List<String> processedGoals = new ArrayList<String>();
for (String goal : brc.getGoals()) {
if (Constants.DEFAULT_PHASES.contains(goal) || Constants.CLEAN_PHASES.contains(goal)) {
continue;
}
processedGoals.add(goal);
}
if (processedGoals.size() > 0) {
brc.setGoals(processedGoals);
injectDependencyProjects(brc, true, con);
}
} else {
LOG.log(Level.INFO, "could not strip phase goals from RunConfig subclass {0}", config.getClass().getName());
}
} else {
warnNoTestCoS(config);
}
}
示例6: convert2VInfo
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private NBVersionInfo convert2VInfo(Dependency dep) {
return new NBVersionInfo(null, dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getType(), null, null, null, dep.getClassifier());
}
示例7: writeDependency
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private void writeDependency(Dependency dependency, String tagName, XmlSerializer serializer)
throws java.io.IOException {
serializer.startTag(NAMESPACE, tagName);
flush(serializer);
StringBuffer b = b(serializer);
int start = b.length();
if (dependency.getGroupId() != null) {
writeValue(serializer, "groupId", dependency.getGroupId(), dependency);
}
if (dependency.getArtifactId() != null) {
writeValue(serializer, "artifactId", dependency.getArtifactId(), dependency);
}
if (dependency.getVersion() != null) {
writeValue(serializer, "version", dependency.getVersion(), dependency);
}
if ((dependency.getType() != null) && !dependency.getType().equals("jar")) {
writeValue(serializer, "type", dependency.getType(), dependency);
}
if (dependency.getClassifier() != null) {
writeValue(serializer, "classifier", dependency.getClassifier(), dependency);
}
if (dependency.getScope() != null) {
writeValue(serializer, "scope", dependency.getScope(), dependency);
}
if (dependency.getSystemPath() != null) {
writeValue(serializer, "systemPath", dependency.getSystemPath(), dependency);
}
if ((dependency.getExclusions() != null) && (dependency.getExclusions().size() > 0)) {
serializer.startTag(NAMESPACE, "exclusions");
for (Iterator iter = dependency.getExclusions().iterator(); iter.hasNext();) {
Exclusion o = (Exclusion) iter.next();
writeExclusion(o, "exclusion", serializer);
}
serializer.endTag(NAMESPACE, "exclusions");
}
if (dependency.getOptional() != null) {
writeValue(serializer, "optional", dependency.getOptional(), dependency);
}
serializer.endTag(NAMESPACE, tagName).flush();
logLocation(dependency, "", start, b.length());
}
示例8: createProjectDependencyPomModel
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private Model createProjectDependencyPomModel(Model processingPomModel) {
Model templateModel = new Model();
templateModel.setModelVersion(processingPomModel.getModelVersion());
templateModel.setGroupId("org.processing.idea");
templateModel.setArtifactId("core");
templateModel.setVersion("1.0.0");
List<Dependency> artifactDependencies = new ArrayList<>(6);
String joglVersion = null;
for (Dependency dependency : processingPomModel.getDependencies()) {
if (dependency.getGroupId().equals("org.jogamp.jogl") && dependency.getArtifactId().equals("jogl")) {
joglVersion = dependency.getVersion();
}
}
if (joglVersion == null) {
throw new IllegalStateException("Unable to determine JOGL version used for this build of Processing.");
}
Dependency core = new Dependency();
core.setGroupId("org.processing");
core.setArtifactId("core");
core.setVersion(version.toString());
artifactDependencies.add(core);
Dependency pdfExport = new Dependency();
pdfExport.setGroupId(VanillaLibrary.PDF_EXPORT.getGroupId());
pdfExport.setArtifactId(VanillaLibrary.PDF_EXPORT.getArtifactId());
pdfExport.setVersion(version.toString());
artifactDependencies.add(pdfExport);
Dependency serial = new Dependency();
serial.setGroupId(VanillaLibrary.SERIAL.getGroupId());
serial.setArtifactId(VanillaLibrary.SERIAL.getArtifactId());
serial.setVersion(version.toString());
artifactDependencies.add(serial);
Dependency network = new Dependency();
network.setGroupId(VanillaLibrary.NETWORK.getGroupId());
network.setArtifactId(VanillaLibrary.NETWORK.getArtifactId());
network.setVersion(version.toString());
artifactDependencies.add(network);
Dependency gluegenRt = new Dependency();
gluegenRt.setGroupId("org.jogamp.gluegen");
gluegenRt.setArtifactId("gluegen-rt-main");
gluegenRt.setVersion(joglVersion);
artifactDependencies.add(gluegenRt);
Dependency joglAllMain = new Dependency();
joglAllMain.setGroupId("org.jogamp.jogl");
joglAllMain.setArtifactId("jogl-all-main");
joglAllMain.setVersion(joglVersion);
artifactDependencies.add(joglAllMain);
if (SystemInfo.isMac) {
Dependency appleExtensions = new Dependency();
appleExtensions.setGroupId("com.apple");
appleExtensions.setArtifactId("AppleJavaExtensions");
appleExtensions.setVersion("LATEST");
artifactDependencies.add(appleExtensions);
}
templateModel.setDependencies(artifactDependencies);
return templateModel;
}