Search in sources :

Example 1 with XPathManager

use of org.commonjava.maven.galley.maven.model.view.XPathManager in project pom-manipulation-ext by release-engineering.

the class GalleyInfrastructure method init.

private void init(final File targetDirectory, final List<ArtifactRepository> remoteRepositories, final ArtifactRepository localRepository, final Settings settings, final List<String> activeProfiles, final Location customLocation, final Transport customTransport, File cacheDir_) throws ManipulationException {
    LocationExpander locationExpander;
    try {
        final List<Location> custom = customLocation == null ? Collections.<Location>emptyList() : Collections.singletonList(customLocation);
        locationExpander = new MavenLocationExpander(custom, remoteRepositories, localRepository, mirrorSelector, settings, activeProfiles);
    } catch (final MalformedURLException e) {
        throw new ManipulationException("Failed to setup Maven-specific LocationExpander: %s", e, e.getMessage());
    }
    xml = new XMLInfrastructure();
    xpaths = new XPathManager();
    final TransportManager transports;
    if (customTransport != null) {
        transports = new TransportManagerImpl(customTransport);
    } else {
        transports = new TransportManagerImpl(new HttpClientTransport(new HttpImpl(new MemoryPasswordManager())), new FileTransport(), new ZipJarTransport());
    }
    cacheDir = cacheDir_;
    if (cacheDir == null) {
        cacheDir = new File(targetDirectory, "manipulator-cache");
    }
    final FileEventManager fileEvents = new NoOpFileEventManager();
    final CacheProvider cache = new FileCacheProvider(cacheDir, new HashedLocationPathGenerator(), fileEvents, new NoOpTransferDecorator());
    final NotFoundCache nfc = new MemoryNotFoundCache();
    executor = Executors.newCachedThreadPool();
    final TransportManagerConfig config = new TransportManagerConfig();
    final TransferManager transfers = new TransferManagerImpl(transports, cache, nfc, fileEvents, new DownloadHandler(nfc, config, executor), new UploadHandler(nfc, config, executor), new ListingHandler(nfc), new ExistenceHandler(nfc), new SpecialPathManagerImpl(), executor);
    final TypeMapper types = new StandardTypeMapper();
    final ArtifactMetadataManager metadataManager = new ArtifactMetadataManagerImpl(transfers, locationExpander);
    final VersionResolver versionResolver = new VersionResolverImpl(new MavenMetadataReader(xml, locationExpander, metadataManager, xpaths));
    artifactManager = new ArtifactManagerImpl(transfers, locationExpander, types, versionResolver);
    // TODO: auto-adjust this to the current Maven runtime!
    final MavenPluginDefaults pluginDefaults = new StandardMaven304PluginDefaults();
    final MavenPluginImplications pluginImplications = new StandardMavenPluginImplications(xml);
    pomReader = new MavenPomReader(xml, locationExpander, artifactManager, xpaths, pluginDefaults, pluginImplications);
    metadataReader = new MavenMetadataReader(xml, locationExpander, metadataManager, xpaths);
}
Also used : StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) TypeMapper(org.commonjava.maven.galley.maven.spi.type.TypeMapper) MalformedURLException(java.net.MalformedURLException) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) TransferManagerImpl(org.commonjava.maven.galley.internal.TransferManagerImpl) VersionResolverImpl(org.commonjava.maven.galley.maven.internal.version.VersionResolverImpl) MavenPluginDefaults(org.commonjava.maven.galley.maven.spi.defaults.MavenPluginDefaults) XPathManager(org.commonjava.maven.galley.maven.model.view.XPathManager) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) LocationExpander(org.commonjava.maven.galley.spi.transport.LocationExpander) StandardMavenPluginImplications(org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications) MavenPluginImplications(org.commonjava.maven.galley.maven.spi.defaults.MavenPluginImplications) ArtifactMetadataManager(org.commonjava.maven.galley.maven.ArtifactMetadataManager) MavenMetadataReader(org.commonjava.maven.galley.maven.parse.MavenMetadataReader) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) NotFoundCache(org.commonjava.maven.galley.spi.nfc.NotFoundCache) UploadHandler(org.commonjava.maven.galley.internal.xfer.UploadHandler) StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) ExistenceHandler(org.commonjava.maven.galley.internal.xfer.ExistenceHandler) FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) TransferManager(org.commonjava.maven.galley.TransferManager) ListingHandler(org.commonjava.maven.galley.internal.xfer.ListingHandler) TransportManagerImpl(org.commonjava.maven.galley.transport.TransportManagerImpl) HashedLocationPathGenerator(org.commonjava.maven.galley.io.HashedLocationPathGenerator) DownloadHandler(org.commonjava.maven.galley.internal.xfer.DownloadHandler) TransportManagerConfig(org.commonjava.maven.galley.config.TransportManagerConfig) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) CacheProvider(org.commonjava.maven.galley.spi.cache.CacheProvider) FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) StandardMavenPluginImplications(org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications) ArtifactMetadataManagerImpl(org.commonjava.maven.galley.maven.internal.ArtifactMetadataManagerImpl) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) StandardMaven304PluginDefaults(org.commonjava.maven.galley.maven.internal.defaults.StandardMaven304PluginDefaults) HttpClientTransport(org.commonjava.maven.galley.transport.htcli.HttpClientTransport) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) FileEventManager(org.commonjava.maven.galley.spi.event.FileEventManager) VersionResolver(org.commonjava.maven.galley.maven.spi.version.VersionResolver) FileTransport(org.commonjava.maven.galley.filearc.FileTransport) ZipJarTransport(org.commonjava.maven.galley.filearc.ZipJarTransport) ManipulationException(org.commonjava.maven.ext.common.ManipulationException) XMLInfrastructure(org.commonjava.maven.galley.maven.parse.XMLInfrastructure) ArtifactManagerImpl(org.commonjava.maven.galley.maven.internal.ArtifactManagerImpl) TransportManager(org.commonjava.maven.galley.spi.transport.TransportManager) MavenPomReader(org.commonjava.maven.galley.maven.parse.MavenPomReader) File(java.io.File) Location(org.commonjava.maven.galley.model.Location)

Example 2 with XPathManager

use of org.commonjava.maven.galley.maven.model.view.XPathManager in project galley by Commonjava.

the class TestFixture method initMissingComponents.

@Override
public void initMissingComponents() throws Exception {
    super.initGalley();
    super.initMissingComponents();
    // setup version resolver.
    if (xml == null) {
        xml = new XMLInfrastructure();
    }
    if (xpath == null) {
        xpath = new XPathManager();
    }
    if (metadataManager == null) {
        metadataManager = new ArtifactMetadataManagerImpl(getTransferManager(), getLocationExpander());
    }
    if (metadataReader == null) {
        metadataReader = new MavenMetadataReader(xml, getLocationExpander(), metadataManager, xpath);
    }
    if (versionResolver == null) {
        versionResolver = new VersionResolverImpl(metadataReader);
    }
    if (typeMapper == null) {
        typeMapper = new StandardTypeMapper();
    }
    if (artifactManager == null) {
        Logger logger = LoggerFactory.getLogger(getClass());
        logger.debug("Initializing ArtifactManagerImpl using:\n  TransferManager: {}\n  LocationExpander: {}\n  TypeMapper: {}\n  VersionResolver: {}", getTransferManager(), getLocationExpander(), typeMapper, versionResolver);
        artifactManager = new ArtifactManagerImpl(getTransferManager(), getLocationExpander(), typeMapper, versionResolver);
    } else {
        Logger logger = LoggerFactory.getLogger(getClass());
        logger.debug("Using passed-in ArtifactManager instance: {}", artifactManager);
    }
    if (pluginDefaults == null) {
        pluginDefaults = new StandardMaven350PluginDefaults();
    }
    if (pluginImplications == null) {
        pluginImplications = new StandardMavenPluginImplications(xml);
    }
    if (modelProcessor == null) {
        modelProcessor = new MavenModelProcessor();
    }
    if (pomReader == null) {
        pomReader = new MavenPomReader(xml, getLocationExpander(), getArtifactManager(), getXpath(), getPluginDefaults(), getPluginImplications());
    }
}
Also used : VersionResolverImpl(org.commonjava.maven.galley.maven.internal.version.VersionResolverImpl) XMLInfrastructure(org.commonjava.maven.galley.maven.parse.XMLInfrastructure) ArtifactManagerImpl(org.commonjava.maven.galley.maven.internal.ArtifactManagerImpl) XPathManager(org.commonjava.maven.galley.maven.model.view.XPathManager) MavenPomReader(org.commonjava.maven.galley.maven.parse.MavenPomReader) MavenMetadataReader(org.commonjava.maven.galley.maven.parse.MavenMetadataReader) Logger(org.slf4j.Logger) MavenModelProcessor(org.commonjava.maven.galley.maven.rel.MavenModelProcessor) StandardMavenPluginImplications(org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications) ArtifactMetadataManagerImpl(org.commonjava.maven.galley.maven.internal.ArtifactMetadataManagerImpl) StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) StandardMaven350PluginDefaults(org.commonjava.maven.galley.maven.internal.defaults.StandardMaven350PluginDefaults)

Aggregations

ArtifactManagerImpl (org.commonjava.maven.galley.maven.internal.ArtifactManagerImpl)2 ArtifactMetadataManagerImpl (org.commonjava.maven.galley.maven.internal.ArtifactMetadataManagerImpl)2 StandardMavenPluginImplications (org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications)2 StandardTypeMapper (org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper)2 VersionResolverImpl (org.commonjava.maven.galley.maven.internal.version.VersionResolverImpl)2 XPathManager (org.commonjava.maven.galley.maven.model.view.XPathManager)2 MavenMetadataReader (org.commonjava.maven.galley.maven.parse.MavenMetadataReader)2 MavenPomReader (org.commonjava.maven.galley.maven.parse.MavenPomReader)2 XMLInfrastructure (org.commonjava.maven.galley.maven.parse.XMLInfrastructure)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ManipulationException (org.commonjava.maven.ext.common.ManipulationException)1 TransferManager (org.commonjava.maven.galley.TransferManager)1 MemoryPasswordManager (org.commonjava.maven.galley.auth.MemoryPasswordManager)1 FileCacheProvider (org.commonjava.maven.galley.cache.FileCacheProvider)1 TransportManagerConfig (org.commonjava.maven.galley.config.TransportManagerConfig)1 NoOpFileEventManager (org.commonjava.maven.galley.event.NoOpFileEventManager)1 FileTransport (org.commonjava.maven.galley.filearc.FileTransport)1 ZipJarTransport (org.commonjava.maven.galley.filearc.ZipJarTransport)1 TransferManagerImpl (org.commonjava.maven.galley.internal.TransferManagerImpl)1