public ToolchainPrivate createToolchain()

in src/it/setup-custom-toolchain/src/main/java/org/apache/maven/plugins/toolchains/its/custom/CustomToolchainFactory.java [53:100]


    public ToolchainPrivate createToolchain(ToolchainModel model) throws MisconfiguredToolchainException {
        if (model == null) {
            return null;
        }

        CustomToolchainImpl customToolchain = new CustomToolchainImpl(model, logger);

        // populate the provides section
        Properties provides = getProvidesProperties(model);

        for (Map.Entry<Object, Object> provide : provides.entrySet()) {
            String key = (String) provide.getKey();
            String value = (String) provide.getValue();

            if (value == null) {
                throw new MisconfiguredToolchainException(
                        "Provides token '" + key + "' doesn't have any value configured.");
            }

            RequirementMatcher matcher;
            if ("version".equals(key)) {
                matcher = RequirementMatcherFactory.createVersionMatcher(value);
            } else {
                matcher = RequirementMatcherFactory.createExactMatcher(value);
            }

            customToolchain.addProvideToken(key, matcher);
        }

        // populate the configuration section
        Properties configuration = toProperties((Xpp3Dom) model.getConfiguration());

        String toolHome = configuration.getProperty(CustomToolchainImpl.KEY_TOOLHOME);
        if (toolHome == null) {
            throw new MisconfiguredToolchainException(
                    "Custom toolchain without the " + CustomToolchainImpl.KEY_TOOLHOME + " configuration element.");
        }

        toolHome = FileUtils.normalize(toolHome);
        customToolchain.setToolHome(toolHome);

        if (!new File(toolHome).exists()) {
            throw new MisconfiguredToolchainException(
                    "Non-existing tool home configuration at " + new File(toolHome).getAbsolutePath());
        }

        return customToolchain;
    }