本文整理汇总了Java中org.jboss.forge.addon.dependencies.Dependency类的典型用法代码示例。如果您正苦于以下问题:Java Dependency类的具体用法?Java Dependency怎么用?Java Dependency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dependency类属于org.jboss.forge.addon.dependencies包,在下文中一共展示了Dependency类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isCamelComponentArtifact
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static boolean isCamelComponentArtifact(Dependency dependency) {
try {
// is it a JAR file
File file = dependency.getArtifact().getUnderlyingResourceObject();
if (file != null && file.getName().toLowerCase().endsWith(".jar")) {
URL url = new URL("file:" + file.getAbsolutePath());
URLClassLoader child = new URLClassLoader(new URL[]{url});
// custom component
InputStream is = child.getResourceAsStream("META-INF/services/org/apache/camel/component.properties");
if (is != null) {
IOHelpers.close(is);
return true;
}
}
} catch (Throwable e) {
// ignore
}
return false;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:CamelProjectHelper.java
示例2: hasDependency
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static boolean hasDependency(Project project, String groupId, String artifactId, String version) {
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
for (Dependency d : dependencies) {
boolean match = d.getCoordinate().getGroupId().equals(groupId);
if (match && artifactId != null) {
match = d.getCoordinate().getArtifactId().equals(artifactId);
}
if (match && version != null) {
match = d.getCoordinate().getVersion().equals(version);
}
if (match) {
return match;
}
}
return false;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:CamelProjectHelper.java
示例3: hasManagedDependency
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static boolean hasManagedDependency(Project project, String groupId, String artifactId, String version) {
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getManagedDependencies();
for (Dependency d : dependencies) {
boolean match = d.getCoordinate().getGroupId().equals(groupId);
if (match && artifactId != null) {
match = d.getCoordinate().getArtifactId().equals(artifactId);
}
if (match && version != null) {
match = d.getCoordinate().getVersion().equals(version);
}
if (match) {
return match;
}
}
return false;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:CamelProjectHelper.java
示例4: ensureCamelArtifactIdAdded
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static Result ensureCamelArtifactIdAdded(Project project, CamelComponentDetails details, DependencyInstaller dependencyInstaller) {
String groupId = details.getGroupId();
String artifactId = details.getArtifactId();
Dependency core = CamelProjectHelper.findCamelCoreDependency(project);
if (core == null) {
return Results.fail("The project does not include camel-core");
}
// we want to use same version as camel-core if its a camel component
// otherwise use the version from the dto
String version;
if ("org.apache.camel".equals(groupId)) {
version = core.getCoordinate().getVersion();
} else {
version = details.getVersion();
}
DependencyBuilder component = DependencyBuilder.create().setGroupId(groupId)
.setArtifactId(artifactId).setVersion(version);
// install the component
dependencyInstaller.install(project, component);
return null;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:24,代码来源:CamelCommandsHelper.java
示例5: loadComponentProperties
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static Properties loadComponentProperties(Dependency dependency) {
Properties answer = new Properties();
try {
// is it a JAR file
File file = dependency.getArtifact().getUnderlyingResourceObject();
if (file != null && file.getName().toLowerCase().endsWith(".jar")) {
URL url = new URL("file:" + file.getAbsolutePath());
URLClassLoader child = new URLClassLoader(new URL[]{url});
InputStream is = child.getResourceAsStream("META-INF/services/org/apache/camel/component.properties");
if (is != null) {
answer.load(is);
}
}
} catch (Throwable e) {
// ignore
}
return answer;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:AbstractCamelProjectCommand.java
示例6: extractComponentJavaType
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static String extractComponentJavaType(Dependency dependency, String scheme) {
try {
// is it a JAR file
File file = dependency.getArtifact().getUnderlyingResourceObject();
if (file != null && file.getName().toLowerCase().endsWith(".jar")) {
URL url = new URL("file:" + file.getAbsolutePath());
URLClassLoader child = new URLClassLoader(new URL[]{url});
InputStream is = child.getResourceAsStream("META-INF/services/org/apache/camel/component/" + scheme);
if (is != null) {
Properties props = new Properties();
props.load(is);
return (String) props.get("class");
}
}
} catch (Throwable e) {
// ignore
}
return null;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:AbstractCamelProjectCommand.java
示例7: getValueChoices
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public Iterable<DataFormatDto> getValueChoices() {
if (core == null) {
return null;
}
List<String> names = camelCatalog.findDataFormatNames();
// filter out existing dataformats we already have
Set<Dependency> artifacts = findCamelArtifacts(project);
for (Dependency dep : artifacts) {
Set<String> languages = dataFormatsFromArtifact(camelCatalog, dep.getCoordinate().getArtifactId());
names.removeAll(languages);
}
List<DataFormatDto> answer = new ArrayList<>();
for (String name : names) {
DataFormatDto dto = createDataFormatDto(camelCatalog, name);
answer.add(dto);
}
return answer;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:CamelDataFormatsCompleter.java
示例8: getValueNames
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public Iterable<String> getValueNames(String label) {
// need to find camel-core so we known the camel version
Dependency core = CamelProjectHelper.findCamelCoreDependency(project);
if (core == null) {
return null;
}
List<String> names = getComponentNames();
if (label != null && !"<all>".equals(label)) {
names = filterByLabel(names, label);
}
if (consumerOnly) {
names = filterByConsumerOnly(names);
}
if (producerOnly) {
names = filterByProducerOnly(names);
}
if (mustHaveOptions) {
names = filterByMustHaveOptions(names);
}
return names;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:26,代码来源:CamelComponentsCompleter.java
示例9: getValueChoices
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public Iterable<LanguageDto> getValueChoices() {
if (core == null) {
return null;
}
List<String> names = camelCatalog.findLanguageNames();
// filter out existing languages we already have
Set<Dependency> artifacts = findCamelArtifacts(project);
for (Dependency dep : artifacts) {
Set<String> languages = languagesFromArtifact(camelCatalog, dep.getCoordinate().getArtifactId());
names.removeAll(languages);
}
List<LanguageDto> answer = new ArrayList<>();
for (String name : names) {
LanguageDto dto = createLanguageDto(camelCatalog, name);
answer.add(dto);
}
return answer;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:CamelLanguagesCompleter.java
示例10: getLanguageNamesFromClasspath
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public Set<String> getLanguageNamesFromClasspath() {
if (core == null) {
return null;
}
Set<String> names = new TreeSet<>();
// only include existing languages we already have on classpath
Set<Dependency> artifacts = findCamelArtifacts(project);
for (Dependency dep : artifacts) {
Set<String> languages = languagesFromArtifact(camelCatalog, dep.getCoordinate().getArtifactId());
names.addAll(languages);
}
return names;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:CamelLanguagesCompleter.java
示例11: checkDependency
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public void checkDependency(DependencyFacet dependencies, String groupId, String artifactId, String version, String
scope) {
Optional<Dependency> dep = dependencies.getDependencies().stream().filter((dependency) ->
dependency.getCoordinate().getArtifactId().equals(artifactId))
.findFirst();
assertThat(dep.isPresent()).isTrue();
assertThat(dep.get().getCoordinate().getGroupId()).isEqualTo(groupId);
if (version == null) {
assertThat(dep.get().getCoordinate().getVersion()).isNull();
} else {
assertThat(dep.get().getCoordinate().getVersion()).isEqualTo(version);
}
if (scope != null) {
assertThat(dep.get().getScopeType()).isEqualTo(scope);
}
}
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:17,代码来源:VertxFacetTest.java
示例12: addDependency
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static DependencyBuilder addDependency(Project project, Dependency dependency) {
final DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class);
final DependencyBuilder builder = dependency instanceof DependencyBuilder
? (DependencyBuilder) dependency : DependencyBuilder.create(dependency);
dependencyFacet.addDirectDependency(builder);
return builder;
}
开发者ID:forge,项目名称:springboot-addon,代码行数:10,代码来源:SpringBootHelper.java
示例13: execute
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
UIContext uiContext = context.getUIContext();
Project project = (Project) uiContext.getAttributeMap().get(Project.class);
Archetype chosenArchetype = archetype.getValue();
String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":"
+ chosenArchetype.getVersion();
DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate);
String repository = chosenArchetype.getRepository();
if (!Strings.isNullOrEmpty(repository)) {
if (repository.endsWith(".xml")) {
int lastRepositoryPath = repository.lastIndexOf('/');
if (lastRepositoryPath > -1)
repository = repository.substring(0, lastRepositoryPath);
}
if (!repository.isEmpty()) {
depQuery.setRepositories(new DependencyRepository("archetype", repository));
}
}
Dependency resolvedArtifact = dependencyResolver.resolveArtifact(depQuery);
FileResource<?> artifact = resolvedArtifact.getArtifact();
MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot,
metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion());
JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
archetypeHelper.setPackageName(facet.getBasePackage());
archetypeHelper.execute();
return Results.success();
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:31,代码来源:FunktionArchetypeSelectionWizardStep.java
示例14: findCamelArtifactDependency
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static Dependency findCamelArtifactDependency(Project project, String artifactId) {
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
for (Dependency d : dependencies) {
if ("org.apache.camel".equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
return d;
}
}
return null;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:10,代码来源:CamelProjectHelper.java
示例15: findCamelArtifacts
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static Set<Dependency> findCamelArtifacts(Project project) {
Set<Dependency> answer = new LinkedHashSet<Dependency>();
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
for (Dependency d : dependencies) {
if ("org.apache.camel".equals(d.getCoordinate().getGroupId())) {
answer.add(d);
}
}
return answer;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:12,代码来源:CamelProjectHelper.java
示例16: findCustomCamelArtifacts
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
public static Set<Dependency> findCustomCamelArtifacts(Project project) {
Set<Dependency> answer = new LinkedHashSet<Dependency>();
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
for (Dependency d : dependencies) {
if (isCamelComponentArtifact(d)) {
answer.add(d);
}
}
return answer;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:12,代码来源:CamelProjectHelper.java
示例17: ensureMavenDependencyAdded
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
/**
* Returns true if the dependency was added or false if its already there
*/
public static boolean ensureMavenDependencyAdded(Project project, DependencyInstaller dependencyInstaller, String groupId, String artifactId, String scope) {
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
for (Dependency d : dependencies) {
if (groupId.equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
getLOG().debug("Project already includes: " + groupId + ":" + artifactId + " for version: " + d.getCoordinate().getVersion());
return false;
}
}
DependencyBuilder component = DependencyBuilder.create().
setGroupId(groupId).
setArtifactId(artifactId);
if (scope != null) {
component.setScopeType(scope);
}
String version = MavenHelpers.getVersion(groupId, artifactId);
if (Strings.isNotBlank(version)) {
component = component.setVersion(version);
getLOG().debug("Adding pom.xml dependency: " + groupId + ":" + artifactId + " version: " + version + " scope: " + scope);
} else {
getLOG().debug("No version could be found for: " + groupId + ":" + artifactId);
}
dependencyInstaller.install(project, component);
return true;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:31,代码来源:MavenHelpers.java
示例18: hasDependency
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
/**
* Returns true if the pom has the given dependency
*/
public static boolean hasDependency(Model pom, String groupId, String artifactId) {
if (pom != null) {
List<org.apache.maven.model.Dependency> dependencies = pom.getDependencies();
return hasDependency(dependencies, groupId, artifactId);
}
return false;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:11,代码来源:MavenHelpers.java
示例19: getArchetypeCatalog
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
@Override
public ArchetypeCatalog getArchetypeCatalog() {
if (cachedArchetypes == null) {
String version = VersionHelper.fabric8ArchetypesVersion();
Coordinate coordinate = CoordinateBuilder.create()
.setGroupId("io.fabric8.archetypes")
.setArtifactId("archetypes-catalog")
.setVersion(version)
.setPackaging("jar");
// load the archetype-catalog.xml from inside the JAR
Dependency dependency = resolver.get().resolveArtifact(DependencyQueryBuilder.create(coordinate));
if (dependency != null) {
try {
String name = dependency.getArtifact().getFullyQualifiedName();
URL url = new URL("file", null, name);
URLClassLoader loader = new URLClassLoader(new URL[]{url});
InputStream is = loader.getResourceAsStream("archetype-catalog.xml");
if (is != null) {
cachedArchetypes = new ArchetypeCatalogXpp3Reader().read(is);
}
} catch (Exception e) {
LOG.log(Level.WARNING, "Error while retrieving archetypes due " + e.getMessage(), e);
}
}
}
return cachedArchetypes;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:30,代码来源:FabricArchetypeCatalogFactory.java
示例20: discoverCustomCamelComponentsOnClasspathAndAddToCatalog
import org.jboss.forge.addon.dependencies.Dependency; //导入依赖的package包/类
protected Set<String> discoverCustomCamelComponentsOnClasspathAndAddToCatalog(CamelCatalog camelCatalog, Project project) {
Set<String> answer = new LinkedHashSet<>();
// find the dependency again because forge don't associate artifact on the returned dependency when installed
MavenDependencyFacet facet = project.getFacet(MavenDependencyFacet.class);
List<Dependency> list = facet.getEffectiveDependencies();
for (Dependency dep : list) {
Properties properties = loadComponentProperties(dep);
if (properties != null) {
String components = (String) properties.get("components");
if (components != null) {
String[] part = components.split("\\s");
for (String scheme : part) {
if (!camelCatalog.findComponentNames().contains(scheme)) {
// find the class name
String javaType = extractComponentJavaType(dep, scheme);
if (javaType != null) {
String json = loadComponentJSonSchema(dep, scheme);
if (json != null) {
camelCatalog.addComponent(scheme, javaType, json);
answer.add(scheme);
}
}
}
}
}
}
}
return answer;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:33,代码来源:AbstractCamelProjectCommand.java
注:本文中的org.jboss.forge.addon.dependencies.Dependency类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论