public String getDomainName() { if (domainName != null) { return domainName; } return getDomainDescriptor().map(bundleDescriptor -> bundleDescriptor.getArtifactFileName()).orElse(DEFAULT_DOMAIN_NAME); }
/** * Obtains the file corresponding to a given Maven artifact on the local repo * * @param descriptor describes which artifact must be returned. * @return the file corresponding to the given artifact * @throws IllegalArgumentException if the file does not exists in the local Maven repository */ public static File findMavenArtifact(BundleDescriptor descriptor) { File artifact = new File(getMavenLocalRepository(), Paths .get(descriptor.getGroupId().replaceAll("\\.", quoteReplacement(separator)), descriptor.getArtifactId(), descriptor.getVersion(), descriptor.getArtifactFileName() + "." + descriptor.getType()) .toString()); if (!artifact.exists()) { LOGGER.error(format("Artifact file: %s", artifact.getAbsolutePath())); throw new IllegalArgumentException(format("Maven artifact '%s' does not exists in the local Maven repository @ '%s'", descriptor, getMavenLocalRepository())); } return artifact; }
private void listPlugins(ApplicationDescriptor descriptor) { Set<ArtifactPluginDescriptor> plugins = descriptor.getPlugins(); if (!plugins.isEmpty()) { doBody("Application plugins:"); for (ArtifactPluginDescriptor plugin : plugins) { doBody(format(PLUGIN_VALUE_FORMAT, plugin.getName(), plugin.getBundleDescriptor().getArtifactFileName())); } } }
private static BundleDependency createBundleDependency(BundleDescriptor bundleDescriptor, boolean createBundleUri) { try { final BundleDependency.Builder builder = new BundleDependency.Builder(); builder.setDescriptor(bundleDescriptor); builder.setScope(BundleScope.COMPILE); if (createBundleUri) { builder.setBundleUri(temporaryFolder.newFile(bundleDescriptor.getArtifactFileName()).toURI()); } return builder.build(); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Test public void resolvesPluginWithNewestVersionOnDependency() throws Exception { final List<ArtifactPluginDescriptor> pluginDescriptors = createPluginDescriptors(barPlugin, bazPlugin, fooPlugin); barPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(LATEST_BAZ_PLUGIN_DESCRIPTOR)).build()); bazPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(FOO_PLUGIN_DESCRIPTOR)).build()); latestBazPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(FOO_PLUGIN_DESCRIPTOR)).build()); when(artifactDescriptorFactory .create(argThat(hasProperty("absolutePath", endsWith(latestBazPlugin.getBundleDescriptor().getArtifactFileName()))), any(Optional.class))).thenReturn(latestBazPlugin); final List<ArtifactPluginDescriptor> resolvedPluginDescriptors = dependenciesResolver.resolve( emptySet(), pluginDescriptors, true); assertResolvedPlugins(resolvedPluginDescriptors, fooPlugin, bazPlugin, barPlugin); }