本文整理匯總了Java中org.apache.maven.model.Dependency.getScope方法的典型用法代碼示例。如果您正苦於以下問題:Java Dependency.getScope方法的具體用法?Java Dependency.getScope怎麽用?Java Dependency.getScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.model.Dependency
的用法示例。
在下文中一共展示了Dependency.getScope方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
@Override
public void run() {
FileObject fo = project.getProjectDirectory().getFileObject("pom.xml"); //NOI18N
final DependencyAdder monitor = this;
ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
@Override
public void performOperation(POMModel model) {
synchronized (monitor) {
for (Dependency dep : toAdd) {
org.netbeans.modules.maven.model.pom.Dependency mdlDep =
ModelUtils.checkModelDependency(model, dep.getGroupId(), dep.getArtifactId(), true);
mdlDep.setVersion(dep.getVersion());
if (dep.getScope() != null) {
mdlDep.setScope(dep.getScope());
}
}
toAdd.clear();
}
}
};
Utilities.performPOMModelOperations(fo, Collections.singletonList(operation));
project.getLookup().lookup(NbMavenProject.class).synchronousDependencyDownload();
}
示例2: findConflict
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
/**
* @return 0 -> no conflicts, 1 -> conflict in version, 2 -> conflict in scope
*/
private static int findConflict (List<Dependency> deps, String groupId, String artifactId, String version, String scope) {
if (deps == null) {
return 0;
}
for (Dependency dep : deps) {
if (artifactId != null && artifactId.equals(dep.getArtifactId()) &&
groupId != null && groupId.equals(dep.getGroupId())) {
if (version != null && !version.equals(dep.getVersion())) {
return 1;
}
if (scope != null) {
if (!scope.equals(dep.getScope())) {
return 2;
}
} else if (dep.getScope() != null) {
return 2;
}
}
}
return 0;
}
示例3: filter
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private Collection<NBVersionInfo> filter(NbMavenProject mavProj, List<NBVersionInfo> nbvis, boolean test) {
Map<String, NBVersionInfo> items = new HashMap<String, NBVersionInfo>();
//check dependency already added
List<Dependency> dependencies = new ArrayList<Dependency>();
MavenProject prj = mavProj.getMavenProject();
if (test) {
dependencies.addAll(prj.getTestDependencies());
} else {
dependencies.addAll(prj.getDependencies());
}
for (NBVersionInfo info : nbvis) {
String key = info.getGroupId() + ":" + info.getArtifactId();
boolean b = items.containsKey(key);
if (!b) {
items.put(key, info);
}
for (Dependency dependency : dependencies) {
//check group id and ArtifactId and Scope even
if (dependency.getGroupId() != null && dependency.getGroupId().equals(info.getGroupId())) {
if (dependency.getArtifactId() != null && dependency.getArtifactId().equals(info.getArtifactId())) {
if (!test && dependency.getScope() != null && ("compile".equals(dependency.getScope()))) {//NOI18N
return Collections.emptyList();
}
}
}
}
}
List<NBVersionInfo> filterd = new ArrayList<NBVersionInfo>(items.values());
return filterd;
}
示例4: 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;
}
示例5: removeSystemScopedDependencies
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private void removeSystemScopedDependencies( Set<String> artifactsToRemove, List<Dependency> originalDependencies )
{
for ( Dependency dependency : originalDependencies )
{
if ( dependency.getScope() != null && dependency.getScope().equalsIgnoreCase( "system" ) )
{
artifactsToRemove.add( getId( dependency ) );
}
}
}
示例6: addSystemScopedDependencyFromNonInterpolatedPom
import org.apache.maven.model.Dependency; //導入方法依賴的package包/類
private void addSystemScopedDependencyFromNonInterpolatedPom( List<Dependency> dependencies,
List<Dependency> originalDependencies )
{
for ( Dependency dependency : originalDependencies )
{
if ( dependency.getScope() != null && dependency.getScope().equalsIgnoreCase( "system" ) )
{
dependencies.add( dependency );
}
}
}
示例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());
}