org.apache.maven.artifact.factory.DefaultArtifactFactory Java Examples
The following examples show how to use
org.apache.maven.artifact.factory.DefaultArtifactFactory.
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: DefaultVersionsHelperTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource ) throws MojoExecutionException { final DefaultWagonManager wagonManager = new DefaultWagonManager() { public Wagon getWagon( Repository repository ) throws UnsupportedProtocolException, WagonConfigurationException { return new FileWagon(); } }; DefaultVersionsHelper helper = new DefaultVersionsHelper( new DefaultArtifactFactory(), new DefaultArtifactResolver(), metadataSource, new ArrayList(), new ArrayList(), new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ), new DefaultPathTranslator()); return helper; }
Example #2
Source File: AbstractGeneratorTask.java From gradle-plugins with MIT License | 5 votes |
private MojoScanner getMojoScanner() { Map<String, MojoDescriptorExtractor> extractors = new TreeMap<>(); JavaAnnotationsMojoDescriptorExtractor mojoDescriptorExtractor = new JavaAnnotationsMojoDescriptorExtractor(); DefaultMojoAnnotationsScanner delegate = new DefaultMojoAnnotationsScanner(); delegate.enableLogging(new PlexusLoggerWrapper(getLogger())); MojoAnnotationScannerWrapper mojoAnnotationsScanner = new MojoAnnotationScannerWrapper(delegate); mojoAnnotationsScanner.setSourceDirectories(sourceDirectories); mojoAnnotationsScanner.setClassesDirectories(classesDirectories); ArtifactResolver artifactResolver = new DefaultArtifactResolver(); DefaultArtifactFactory artifactFactory = new DefaultArtifactFactory(); ArchiverManager archiverManager = new DefaultArchiverManager(); Map<String, Object> values = new HashMap<>(); values.put("mojoAnnotationsScanner", mojoAnnotationsScanner); values.put("artifactResolver", artifactResolver); values.put("artifactFactory", artifactFactory); values.put("archiverManager", archiverManager); try { Class<JavaAnnotationsMojoDescriptorExtractor> clazz = JavaAnnotationsMojoDescriptorExtractor.class; for (Map.Entry<String, Object> entry : values.entrySet()) { Field declaredField = clazz.getDeclaredField(entry.getKey()); declaredField.setAccessible(true); declaredField.set(mojoDescriptorExtractor, entry.getValue()); } } catch (IllegalAccessException | NoSuchFieldException e) { throw new RuntimeException(e); } extractors.put("java-annotations", mojoDescriptorExtractor); DefaultMojoScanner defaultMojoScanner = new DefaultMojoScanner(extractors); defaultMojoScanner.enableLogging(new PlexusLoggerWrapper(getLogger())); return defaultMojoScanner; }
Example #3
Source File: AbstractGeneratorTask.java From gradle-plugins with MIT License | 5 votes |
private MojoScanner getMojoScanner() { Map<String, MojoDescriptorExtractor> extractors = new TreeMap<>(); JavaAnnotationsMojoDescriptorExtractor mojoDescriptorExtractor = new JavaAnnotationsMojoDescriptorExtractor(); DefaultMojoAnnotationsScanner delegate = new DefaultMojoAnnotationsScanner(); delegate.enableLogging(new PlexusLoggerWrapper(getLogger())); MojoAnnotationScannerWrapper mojoAnnotationsScanner = new MojoAnnotationScannerWrapper(delegate); mojoAnnotationsScanner.setSourceDirectories(sourceDirectories); mojoAnnotationsScanner.setClassesDirectories(classesDirectories); ArtifactResolver artifactResolver = new DefaultArtifactResolver(); DefaultArtifactFactory artifactFactory = new DefaultArtifactFactory(); ArchiverManager archiverManager = new DefaultArchiverManager(); Map<String, Object> values = new HashMap<>(); values.put("mojoAnnotationsScanner", mojoAnnotationsScanner); values.put("artifactResolver", artifactResolver); values.put("artifactFactory", artifactFactory); values.put("archiverManager", archiverManager); try { Class<JavaAnnotationsMojoDescriptorExtractor> clazz = JavaAnnotationsMojoDescriptorExtractor.class; for (Map.Entry<String, Object> entry : values.entrySet()) { Field declaredField = clazz.getDeclaredField(entry.getKey()); declaredField.setAccessible(true); declaredField.set(mojoDescriptorExtractor, entry.getValue()); } } catch (IllegalAccessException | NoSuchFieldException e) { throw new RuntimeException(e); } extractors.put("java-annotations", mojoDescriptorExtractor); DefaultMojoScanner defaultMojoScanner = new DefaultMojoScanner(extractors); defaultMojoScanner.enableLogging(new PlexusLoggerWrapper(getLogger())); return defaultMojoScanner; }
Example #4
Source File: CreateEffectivePomTest.java From flatten-maven-plugin with Apache License 2.0 | 5 votes |
/** * Tests method to create effective POM. * * @throws Exception if something goes wrong. */ @Test public void testCreateEffectivePom() throws Exception { String magicValue = "magic-value"; Properties userProperties = new Properties(); userProperties.setProperty( "cmd.test.property", magicValue ); File pomFile = new File( "src/test/resources/cmdpropertysubstituion/pom.xml" ); ArtifactRepository localRepository = new MavenArtifactRepository(); localRepository.setLayout( new DefaultRepositoryLayout() ); ArtifactFactory artifactFactory = new DefaultArtifactFactory(); ArtifactHandlerManager artifactHandlerManager = new DefaultArtifactHandlerManager(); setDeclaredField( artifactFactory, "artifactHandlerManager", artifactHandlerManager ); Map<String, ArtifactHandler> artifactHandlers = new HashMap<String, ArtifactHandler>(); setDeclaredField( artifactHandlerManager, "artifactHandlers", artifactHandlers ); DefaultDependencyResolver depencencyResolver = new DefaultDependencyResolver(); DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest(); FlattenModelResolver resolver = new FlattenModelResolver( localRepository, artifactFactory, depencencyResolver, projectBuildingRequest, Collections.<MavenProject>emptyList() ); ModelBuildingRequest buildingRequest = new DefaultModelBuildingRequest().setPomFile( pomFile ).setModelResolver( resolver ).setUserProperties( userProperties ); setDeclaredField( tested, "modelBuilderThreadSafetyWorkaround", buildModelBuilderThreadSafetyWorkaroundForTest() ); Model effectivePom = tested.createEffectivePom( buildingRequest, false, FlattenMode.defaults ); assertThat( effectivePom.getName() ).isEqualTo( magicValue ); }