use of org.eclipse.jkube.kit.common.Dependency in project jkube by eclipse.
the class SpringBootUtilTest method testGetSpringBootDevToolsVersion.
@Test
public void testGetSpringBootDevToolsVersion(@Mocked JavaProject maven_project) {
// Given
Dependency p = Dependency.builder().groupId("org.springframework.boot").version("1.6.3").build();
new Expectations() {
{
maven_project.getDependencies();
result = Collections.singletonList(p);
}
};
// when
Optional<String> result = SpringBootUtil.getSpringBootDevToolsVersion(maven_project);
// Then
assertTrue(result.isPresent());
assertEquals("1.6.3", result.get());
}
use of org.eclipse.jkube.kit.common.Dependency in project jkube by eclipse.
the class SpringBootUtilTest method testGetSpringBootVersion.
@Test
public void testGetSpringBootVersion(@Mocked JavaProject maven_project) {
// Given
Dependency p = Dependency.builder().groupId("org.springframework.boot").version("1.6.3").build();
new Expectations() {
{
maven_project.getDependencies();
result = Collections.singletonList(p);
}
};
// when
Optional<String> result = SpringBootUtil.getSpringBootVersion(maven_project);
// Then
assertTrue(result.isPresent());
assertEquals("1.6.3", result.get());
}
use of org.eclipse.jkube.kit.common.Dependency in project jkube by eclipse.
the class DependencyEnricherTest method getDummyArtifacts.
private List<Dependency> getDummyArtifacts() {
List<Dependency> artifacts = new ArrayList<>();
File aFile = new File(getClass().getResource(ARTIFACT_FILE_PATH).getFile());
Dependency artifact = Dependency.builder().groupId("g1").artifactId("a1").version("v1").type("jar").scope("compile").file(aFile).build();
artifacts.add(artifact);
return artifacts;
}
use of org.eclipse.jkube.kit.common.Dependency in project jkube by eclipse.
the class GradleUtil method extractDependencies.
private static List<Dependency> extractDependencies(Project gradleProject, Function<ResolutionResult, Set<? extends DependencyResult>> resolutionToDependency) {
return new ArrayList<Configuration>(gradleProject.getConfigurations()).stream().filter(GradleUtil::canBeResolved).flatMap(c -> {
final Map<ComponentIdentifier, ResolvedArtifactResult> artifacts = artifactMap(c);
return resolutionToDependency.apply(c.getIncoming().getResolutionResult()).stream().filter(ResolvedDependencyResult.class::isInstance).map(ResolvedDependencyResult.class::cast).map(ResolvedDependencyResult::getSelected).filter(rcr -> Objects.nonNull(rcr.getModuleVersion())).map(rcr -> {
final ModuleVersionIdentifier mvi = rcr.getModuleVersion();
final Dependency.DependencyBuilder db = Dependency.builder().groupId(mvi.getGroup()).artifactId(mvi.getName()).version(mvi.getVersion());
final ResolvedArtifactResult artifact = artifacts.get(rcr.getId());
if (artifact != null) {
db.scope(c.getName().toLowerCase(Locale.ROOT).contains("test") ? "test" : "compile");
db.file(artifact.getFile());
db.type(artifact.getVariant().getAttributes().getAttribute(Attribute.of("artifactType", String.class)));
}
return db.build();
});
}).distinct().collect(Collectors.toList());
}
use of org.eclipse.jkube.kit.common.Dependency in project jkube by eclipse.
the class DependencyEnricher method addArtifactsWithYaml.
private void addArtifactsWithYaml(Set<URI> artifactSet, String dependencyYaml) throws URISyntaxException {
final List<Dependency> artifacts = getContext().getDependencies(isIncludeTransitive());
for (Dependency artifact : artifacts) {
if ("compile".equals(artifact.getScope()) && "jar".equals(artifact.getType())) {
File file = artifact.getFile();
try {
URI uri = new URI("jar:" + file.toURI() + "!/" + dependencyYaml);
artifactSet.add(uri);
} catch (URISyntaxException e) {
getLog().debug("Failed to create URL for %s: %s", file, e);
}
}
}
// lets look on the current plugin classpath too
if (isIncludePlugin()) {
Enumeration<URL> resources = null;
try {
resources = getClass().getClassLoader().getResources(dependencyYaml);
} catch (IOException e) {
getLog().error("Could not find %s on the classpath: %s", dependencyYaml, e);
}
if (resources != null) {
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
URI uri = url.toURI();
artifactSet.add(uri);
}
}
}
}
Aggregations