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

es.iti.wakamiti.launcher.WakamitiLauncherFetcher Maven / Gradle / Ivy

There is a newer version: 2.6.3
Show newest version
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

/**
 * @author Luis Iñesta Gelabert - [email protected] | [email protected]
 */
package es.iti.wakamiti.launcher;


import imconfig.Configuration;
import es.iti.wakamiti.core.Wakamiti;
import es.iti.wakamiti.core.WakamitiFetcher;
import net.harawata.appdirs.AppDirsFactory;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;


public class WakamitiLauncherFetcher extends WakamitiFetcher {

    private final CliArguments arguments;


    public WakamitiLauncherFetcher(CliArguments arguments) throws URISyntaxException {
        super(
            WakamitiLauncher.logger(),
            mavenFetcherConfiguration(arguments)
        );
        this.arguments = arguments;
    }


    private static Configuration mavenFetcherConfiguration(CliArguments arguments)
    throws URISyntaxException {
        Path mavenRepo = Paths.get(
            AppDirsFactory.getInstance().getUserDataDir("wakamiti", "repository", "iti")
        );
        return Wakamiti.defaultConfiguration().append(
                arguments.mavenFetcherConfiguration()
                        .appendProperty("localRepository", mavenRepo.toString())
        ).append(arguments.wakamitiConfiguration())
        ;
    }



    public List fetchAndUpdateClasspath() throws URISyntaxException {
        return super.fetch(modulesToFetch(), arguments.mustClean());
    }




    private List modulesToFetch() throws URISyntaxException {
        Configuration conf = arguments.wakamitiConfiguration();
        List modules = new ArrayList<>();
        modules.addAll(arguments.modules());
        modules.addAll(conf.getList("launcher.modules", String.class));
        return modules;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy