Java Code Examples for org.apache.maven.model.Model#getRepositories()
The following examples show how to use
org.apache.maven.model.Model#getRepositories() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PomProperty.java From flatten-maven-plugin with Apache License 2.0 | 4 votes |
@Override public List<Repository> get( Model model ) { return model.getRepositories(); }
Example 2
Source File: RepositoryInjectionManipulator.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
/** * Apply the repository injection changes to the the top level pom. */ @Override public Set<Project> applyChanges( final List<Project> projects ) throws ManipulationException { final RepositoryInjectionState state = session.getState( RepositoryInjectionState.class ); if ( !session.isEnabled() || !state.isEnabled() ) { logger.debug("{}: Nothing to do!", getClass().getSimpleName() ); return Collections.emptySet(); } final Set<Project> changed = new HashSet<>(); final Model remoteModel = modelBuilder.resolveRawModel(state.getRemoteRepositoryInjectionMgmt()); final List<Repository> remoteRepositories = remoteModel.getRepositories(); final List<Repository> remotePluginRepositories = remoteModel.getPluginRepositories(); for ( final Project project : projects ) { final String ga = ga( project ); logger.info( "Applying changes to: " + ga ); final Model model = project.getModel(); if ( checkProject( state, project ) ) { // inject repositories final List<Repository> repositories = model.getRepositories(); if ( !remoteRepositories.isEmpty() ) { final Iterator<Repository> i1 = remoteRepositories.iterator(); while ( i1.hasNext() ) { addRepository( repositories, i1.next() ); } changed.add( project ); } // inject plugin repositories final List<Repository> pluginRepositories = model.getPluginRepositories(); if ( !remotePluginRepositories.isEmpty() ) { final Iterator<Repository> i2 = remotePluginRepositories.iterator(); while ( i2.hasNext() ) { addRepository( pluginRepositories, i2.next() ); } changed.add( project ); } } } return changed; }
Example 3
Source File: PluginBundleManager.java From BIMserver with GNU Affero General Public License v3.0 | 4 votes |
private void loadDependencies(String pluginBundleVersion, boolean strictDependencyChecking, Model model, DelegatingClassLoader delegatingClassLoader) throws DependencyCollectionException, InvalidVersionSpecificationException, Exception { if (model.getRepositories() != null) { for (Repository repository : model.getRepositories()) { mavenPluginRepository.addRepository(repository.getId(), "default", repository.getUrl()); } } List<Dependency> dependenciesToResolve = new ArrayList<>(); for (org.apache.maven.model.Dependency dependency2 : model.getDependencies()) { String scope = dependency2.getScope(); if (scope != null && (scope.contentEquals("test"))) { // Skip continue; } Dependency d = new Dependency(new DefaultArtifact(dependency2.getGroupId(), dependency2.getArtifactId(), dependency2.getType(), dependency2.getVersion()), dependency2.getScope()); Set<Exclusion> exclusions = new HashSet<>(); d.setExclusions(exclusions); exclusions.add(new Exclusion("org.opensourcebim", "pluginbase", null, "jar")); exclusions.add(new Exclusion("org.opensourcebim", "shared", null, "jar")); exclusions.add(new Exclusion("org.opensourcebim", "ifcplugins", null, "jar")); dependenciesToResolve.add(d); } CollectRequest collectRequest = new CollectRequest(dependenciesToResolve, null, null); collectRequest.setRepositories(mavenPluginRepository.getRepositoriesAsList()); CollectResult collectDependencies = mavenPluginRepository.getSystem().collectDependencies(mavenPluginRepository.getSession(), collectRequest); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); DependencyNode rootDep = collectDependencies.getRoot(); rootDep.accept(nlg); for (Dependency dependency : nlg.getDependencies(true)) { if (dependency.getScope().contentEquals("test")) { continue; } // LOGGER.info(dependency.getArtifact().getGroupId() + "." + dependency.getArtifact().getArtifactId()); Artifact dependencyArtifact = dependency.getArtifact(); PluginBundleIdentifier pluginBundleIdentifier = new PluginBundleIdentifier(dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId()); if (pluginBundleIdentifierToPluginBundle.containsKey(pluginBundleIdentifier)) { if (strictDependencyChecking) { String version = dependencyArtifact.getVersion(); if (!version.contains("[") && !version.contains("(")) { version = "[" + version + "]"; } VersionRange versionRange = VersionRange.createFromVersionSpec(version); // String version = // pluginBundleIdentifierToPluginBundle.get(pluginBundleIdentifier).getPluginBundleVersion().getVersion(); ArtifactVersion artifactVersion = new DefaultArtifactVersion(pluginBundleVersion); if (versionRange.containsVersion(artifactVersion)) { // OK } else { throw new Exception( "Required dependency " + pluginBundleIdentifier + " is installed, but it's version (" + pluginBundleVersion + ") does not comply to the required version (" + dependencyArtifact.getVersion() + ")"); } } else { LOGGER.info("Skipping strict dependency checking for dependency " + dependencyArtifact.getArtifactId()); } } else { try { if (dependencyArtifact.getGroupId().contentEquals("com.sun.xml.ws")) { continue; } MavenPluginLocation mavenPluginLocation = mavenPluginRepository.getPluginLocation(dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId()); if (dependencyArtifact.getExtension().contentEquals("jar")) { Path depJarFile = mavenPluginLocation.getVersionJar(dependencyArtifact.getVersion()); FileJarClassLoader jarClassLoader = new FileJarClassLoader(pluginManager, delegatingClassLoader, depJarFile); jarClassLoaders.add(jarClassLoader); delegatingClassLoader.add(jarClassLoader); } } catch (Exception e) { e.printStackTrace(); throw new Exception("Required dependency " + pluginBundleIdentifier + " is not installed"); } } } }