All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.maveniverse.maven.mima.runtime.standalonesisu.StandaloneSisuRuntime Maven / Gradle / Ivy

There is a newer version: 3.0.0-alpha-3
Show newest version
/*
 * Copyright (c) 2023-2024 Maveniverse Org.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-v20.html
 */
package eu.maveniverse.maven.mima.runtime.standalonesisu;

import eu.maveniverse.maven.mima.context.Context;
import eu.maveniverse.maven.mima.context.ContextOverrides;
import eu.maveniverse.maven.mima.runtime.shared.PreBoot;
import eu.maveniverse.maven.mima.runtime.shared.StandaloneRuntimeSupport;
import eu.maveniverse.maven.mima.runtime.standalonesisu.internal.SisuBooter;
import eu.maveniverse.maven.mima.runtime.standalonesisu.internal.SisuLookup;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.profile.ProfileSelector;
import org.apache.maven.settings.building.SettingsBuilder;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.sisu.inject.MutableBeanLocator;

@Singleton
@Named
public final class StandaloneSisuRuntime extends StandaloneRuntimeSupport {

    private final RepositorySystem repositorySystem;

    private final SettingsBuilder settingsBuilder;

    private final SettingsDecrypter settingsDecrypter;

    private final ProfileSelector profileSelector;

    private final MutableBeanLocator locator;

    public StandaloneSisuRuntime() {
        this(null, null, null, null, null);
    }

    @Inject
    public StandaloneSisuRuntime(
            RepositorySystem repositorySystem,
            SettingsBuilder settingsBuilder,
            SettingsDecrypter settingsDecrypter,
            ProfileSelector profileSelector,
            MutableBeanLocator locator) {
        super("standalone-sisu", 30);
        this.repositorySystem = repositorySystem;
        this.settingsBuilder = settingsBuilder;
        this.settingsDecrypter = settingsDecrypter;
        this.profileSelector = profileSelector;
        this.locator = locator;
    }

    @Override
    public boolean managedRepositorySystem() {
        return repositorySystem == null;
    }

    @Override
    public Context create(ContextOverrides overrides) {
        PreBoot preBoot = preBoot(overrides);
        // managed or unmanaged context: depending on how we booted
        if (repositorySystem == null) {
            SisuBooter booter = SisuBooter.newSisuBooter(preBoot);
            return buildContext(
                    this,
                    preBoot,
                    booter.repositorySystem,
                    booter.settingsBuilder,
                    booter.settingsDecrypter,
                    booter.profileSelector,
                    new SisuLookup(booter.locator),
                    booter::close);
        } else {
            return buildContext(
                    this,
                    preBoot,
                    repositorySystem,
                    settingsBuilder,
                    settingsDecrypter,
                    profileSelector,
                    new SisuLookup(locator),
                    null);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy