当前位置: 首页>>代码示例>>Java>>正文


Java Dependency.setScope方法代码示例

本文整理汇总了Java中org.apache.maven.model.Dependency.setScope方法的典型用法代码示例。如果您正苦于以下问题:Java Dependency.setScope方法的具体用法?Java Dependency.setScope怎么用?Java Dependency.setScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.model.Dependency的用法示例。


在下文中一共展示了Dependency.setScope方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addDependency

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
private void addDependency(MavenDependencyInternal dependency, String artifactId, String scope, String type, String classifier) {
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency.getGroupId());
    mavenDependency.setArtifactId(artifactId);
    mavenDependency.setVersion(mapToMavenSyntax(dependency.getVersion()));
    mavenDependency.setType(type);
    mavenDependency.setScope(scope);
    mavenDependency.setClassifier(classifier);

    for (ExcludeRule excludeRule : dependency.getExcludeRules()) {
        Exclusion exclusion = new Exclusion();
        exclusion.setGroupId(GUtil.elvis(excludeRule.getGroup(), "*"));
        exclusion.setArtifactId(GUtil.elvis(excludeRule.getModule(), "*"));
        mavenDependency.addExclusion(exclusion);
    }

    getModel().addDependency(mavenDependency);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:MavenPomFileGenerator.java

示例2: createDependency

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
private Dependency createDependency( Artifact artifact )
{
    Dependency dep = new Dependency();
    dep.setArtifactId( artifact.getArtifactId() );
    if ( artifact.hasClassifier() )
    {
        dep.setClassifier( artifact.getClassifier() );
    }
    dep.setGroupId( artifact.getGroupId() );
    dep.setOptional( artifact.isOptional() );
    dep.setScope( artifact.getScope() );
    dep.setType( artifact.getType() );
    if ( useBaseVersion )
    {
        dep.setVersion( artifact.getBaseVersion() );
    }
    else
    {
        dep.setVersion( artifact.getVersion() );
    }
    return dep;
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:23,代码来源:ShadeMojo.java

示例3: pomExecution

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
@Override
protected TOExecutionResult pomExecution(String relativePomFile, Model model) {
    TOExecutionResult result;

    Dependency dependency = getDependency(model, groupId, artifactId);
    if (dependency != null) {
        model.removeDependency(dependency);

        if (removeVersion) dependency.setVersion(null); else if (version != null) dependency.setVersion(version);
        if (removeScope) dependency.setScope(null); else if (scope != null) dependency.setScope(scope);
        if (removeType) dependency.setType(null); else if (type != null) dependency.setType(type);
        if (removeOptional) dependency.setOptional(null); else dependency.setOptional(optional);

        model.addDependency(dependency);

        String details = String.format("Dependency %s:%s has been changed in %s", groupId, artifactId, getRelativePath());
        result = TOExecutionResult.success(this, details);
    } else {
        String message = String.format("Dependency %s:%s is not present in %s", groupId, artifactId, getRelativePath());

        switch (ifNotPresent) {
            case Warn:
                result = TOExecutionResult.warning(this, new TransformationOperationException(message));
                break;
            case NoOp:
                result = TOExecutionResult.noOp(this, message);
                break;
            case Fail:
                // Fail is the default
            default:
                result = TOExecutionResult.error(this, new TransformationOperationException(message));
                break;
        }
    }

    return result;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:38,代码来源:PomChangeDependency.java

示例4: getDependency

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
private Dependency getDependency(String coordinates, String scope) {
  String[] coordinateArray = coordinates.split(":");
  Preconditions.checkState(coordinateArray.length == 3);
  Dependency dependency = new Dependency();
  dependency.setGroupId(coordinateArray[0]);
  dependency.setArtifactId(coordinateArray[1]);
  dependency.setVersion(coordinateArray[2]);
  dependency.setScope(scope);
  return dependency;
}
 
开发者ID:bazelbuild,项目名称:migration-tooling,代码行数:11,代码来源:ResolverTest.java

示例5: smartTestingProviderDependency

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
private Dependency smartTestingProviderDependency() {
    final Dependency smartTestingSurefireProvider = new Dependency();
    smartTestingSurefireProvider.setGroupId("org.arquillian.smart.testing");
    smartTestingSurefireProvider.setArtifactId("surefire-provider");
    smartTestingSurefireProvider.setVersion(ExtensionVersion.version().toString());
    smartTestingSurefireProvider.setScope("runtime");
    smartTestingSurefireProvider.setClassifier("shaded");
    return smartTestingSurefireProvider;
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:10,代码来源:DependencyResolver.java

示例6: 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;
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:34,代码来源:MavenCoordinatesResolver.java

示例7: processModules

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
public void processModules(ProjectBuildingRequest projectBuildingRequest, MavenProject project) {
	String modulesText = project.getProperties().getProperty(PROP_CONTRACTORS);
	if (modulesText == null || modulesText.trim().isEmpty()) {
		if (Flag.verbose()) {
			logger.info("No available modules in '{}'", PROP_CONTRACTORS);
		} else if (logger.isDebugEnabled()) {
			logger.debug("No available modules in '{}'", PROP_CONTRACTORS);
		}
		return;
	}
	String[] modulesArray = modulesText.split("[\\s]*[,\\n][\\s]*");
	Set<String> modulesSet = Arrays.stream(modulesArray).collect(Collectors.toSet());
	modulesSet.add("com.commsen.em.contractors:em.contractors.runtime:" + VAL_EXTENSION_VERSION);
	for (String moduleText : modulesSet) {
		String[] coordinates = moduleText.split(":");
		if (coordinates.length != 3) {
			logger.warn("Invalid maven coordinates for module '{}'! It will be ignored!", moduleText);
			continue;
		}

		Dependency dependency = new Dependency();
		dependency.setGroupId(coordinates[0]);
		dependency.setArtifactId(coordinates[1]);
		dependency.setVersion(coordinates[2]);
		dependency.setScope("runtime");
		dependency.setType("pom");

		try {
			Artifact pomArtifact = dependencies.asArtifact(projectBuildingRequest, dependency);
			dependency.setType("jar");
			MavenXpp3Reader reader = new MavenXpp3Reader();
			Model model = reader.read(new FileInputStream(pomArtifact.getFile()));
			DependencyManagement dm = model.getDependencyManagement();

			if (dm == null) {
				dependencies.addToDependencyManagement(project, dependency);
			} else {
				for (Dependency d : dm.getDependencies()) {
					/*
					 * TODO handle variables properly! For now assume variable is referring to the
					 * contract's artifact itself (that's what EM contractors do).
					 */
					if (d.getArtifactId().startsWith("${")) {
						dependencies.addToDependencyManagement(project, dependency);
					} else {
						dependencies.addToDependencyManagement(project, d);
					}
				}
			}

		} catch (Exception e) {
			logger.warn("Could not process modules from " + coordinates[0] + ":" + coordinates[1] + ":"
					+ coordinates[2], e);
		}
	}

}
 
开发者ID:commsen,项目名称:EM,代码行数:58,代码来源:ExportMojo.java

示例8: createDependencyReducedPom

import org.apache.maven.model.Dependency; //导入方法依赖的package包/类
private void createDependencyReducedPom( Set<String> artifactsToRemove )
    throws IOException, DependencyGraphBuilderException, ProjectBuildingException
{
    List<Dependency> dependencies = new ArrayList<Dependency>();

    boolean modified = false;

    List<Dependency> transitiveDeps = new ArrayList<Dependency>();

    // NOTE: By using the getArtifacts() we get the completely evaluated artifacts
    // including the system scoped artifacts with expanded values of properties used.
    for ( Artifact artifact : project.getArtifacts() )
    {
        if ( "pom".equals( artifact.getType() ) )
        {
            // don't include pom type dependencies in dependency reduced pom
            continue;
        }

        // promote
        Dependency dep = createDependency( artifact );

        // we'll figure out the exclusions in a bit.
        transitiveDeps.add( dep );
    }
    List<Dependency> origDeps = project.getDependencies();

    if ( promoteTransitiveDependencies )
    {
        origDeps = transitiveDeps;
    }

    Model model = project.getOriginalModel();
    // MSHADE-185: We will remove all system scoped dependencies which usually
    // have some kind of property usage. At this time the properties within
    // such things are already evaluated.
    List<Dependency> originalDependencies = model.getDependencies();
    removeSystemScopedDependencies( artifactsToRemove, originalDependencies );

    for ( Dependency d : origDeps )
    {
        dependencies.add( d );

        String id = getId( d );

        if ( artifactsToRemove.contains( id ) )
        {
            modified = true;

            if ( keepDependenciesWithProvidedScope )
            {
                d.setScope( "provided" );
            }
            else
            {
                dependencies.remove( d );
            }
        }
    }

    // MSHADE-155
    model.setArtifactId( shadedArtifactId );

    // MSHADE-185: We will add those system scoped dependencies
    // from the non interpolated original pom file. So we keep
    // things like this: <systemPath>${tools.jar}</systemPath> intact.
    addSystemScopedDependencyFromNonInterpolatedPom( dependencies, originalDependencies );

    // Check to see if we have a reduction and if so rewrite the POM.
    rewriteDependencyReducedPomIfWeHaveReduction( dependencies, modified, transitiveDeps, model );
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:72,代码来源:ShadeMojo.java


注:本文中的org.apache.maven.model.Dependency.setScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。