/** * Adds information about artifact dependencies. * * @param dependent The dependent to add artifacts as dependencies * @param dependencies The dependencies information. * @param scannerContext The scanner context */ private <P extends MavenDependentDescriptor, D extends BaseDependencyDescriptor> void addDependencies( P dependent, List<Dependency> dependencies, Class<D> dependencyType, ScannerContext scannerContext) { for (Dependency dependency : dependencies) { MavenArtifactDescriptor dependencyArtifactDescriptor = getMavenArtifactDescriptor(dependency, scannerContext); D dependencyDescriptor = scannerContext.getStore().create(dependent, dependencyType, dependencyArtifactDescriptor); dependencyDescriptor.setOptional(dependency.isOptional()); dependencyDescriptor.setScope(dependency.getScope()); } }
/** * Adds information about profile dependencies. * * @param profileDescriptor The descriptor for the current profile. * @param dependencies The dependencies information. * @param scannerContext The scanner context. */ private void addProfileDependencies( MavenProfileDescriptor profileDescriptor, List<Dependency> dependencies, ScannerContext scannerContext) { for (Dependency dependency : dependencies) { MavenArtifactDescriptor dependencyArtifactDescriptor = getMavenArtifactDescriptor(dependency, scannerContext); ProfileDependsOnDescriptor profileDependsOnDescriptor = scannerContext .getStore() .create( profileDescriptor, ProfileDependsOnDescriptor.class, dependencyArtifactDescriptor); profileDependsOnDescriptor.setOptional(dependency.isOptional()); profileDependsOnDescriptor.setScope(dependency.getScope()); } }
/** * Adds information about defined profile. * * @param pomDescriptor The descriptor for the current POM. * @param model The Maven Model. * @param scannerContext The scanner context. */ private void addProfiles( MavenPomDescriptor pomDescriptor, Model model, ScannerContext scannerContext) { List<Profile> profiles = model.getProfiles(); Store store = scannerContext.getStore(); for (Profile profile : profiles) { MavenProfileDescriptor mavenProfileDescriptor = store.create(MavenProfileDescriptor.class); pomDescriptor.getProfiles().add(mavenProfileDescriptor); mavenProfileDescriptor.setId(profile.getId()); addProperties(mavenProfileDescriptor, profile.getProperties(), store); addModules(mavenProfileDescriptor, profile.getModules(), store); addPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addManagedPlugins(mavenProfileDescriptor, profile.getBuild(), scannerContext); addManagedDependencies( mavenProfileDescriptor, profile.getDependencyManagement(), scannerContext, ProfileManagesDependencyDescriptor.class); addProfileDependencies(mavenProfileDescriptor, profile.getDependencies(), scannerContext); addActivation(mavenProfileDescriptor, profile.getActivation(), store); } }
/** * Create plugin descriptors for the given plugins. * * @param plugins The plugins. * @param context The scanner context. * @return The plugin descriptors. */ private List<MavenPluginDescriptor> createMavenPluginDescriptors( List<Plugin> plugins, ScannerContext context) { Store store = context.getStore(); List<MavenPluginDescriptor> pluginDescriptors = new ArrayList<>(); for (Plugin plugin : plugins) { MavenPluginDescriptor mavenPluginDescriptor = store.create(MavenPluginDescriptor.class); MavenArtifactDescriptor artifactDescriptor = getArtifactResolver(context).resolve(new PluginCoordinates(plugin), context); mavenPluginDescriptor.setArtifact(artifactDescriptor); mavenPluginDescriptor.setInherited(plugin.isInherited()); addDependencies( mavenPluginDescriptor, plugin.getDependencies(), PluginDependsOnDescriptor.class, context); addPluginExecutions(mavenPluginDescriptor, plugin, store); addConfiguration(mavenPluginDescriptor, (Xpp3Dom) plugin.getConfiguration(), store); pluginDescriptors.add(mavenPluginDescriptor); } return pluginDescriptors; }
/** {@inheritDoc} */ @Override public MavenPomDescriptor scan(Model model, String path, Scope scope, Scanner scanner) throws IOException { MavenPomDescriptor pomDescriptor = createMavenPomDescriptor(model, scanner); ScannerContext scannerContext = scanner.getContext(); Store store = scannerContext.getStore(); addParent(pomDescriptor, model, scannerContext); addProfiles(pomDescriptor, model, scannerContext); addProperties(pomDescriptor, model.getProperties(), store); addModules(pomDescriptor, model.getModules(), store); addManagedDependencies( pomDescriptor, model.getDependencyManagement(), scannerContext, PomManagesDependencyDescriptor.class); addDependencies( pomDescriptor, model.getDependencies(), PomDependsOnDescriptor.class, scannerContext); addManagedPlugins(pomDescriptor, model.getBuild(), scannerContext); addPlugins(pomDescriptor, model.getBuild(), scannerContext); addLicenses(pomDescriptor, model, store); return pomDescriptor; }