List of usage examples for org.apache.maven.toolchain RequirementMatcherFactory createVersionMatcher
public static RequirementMatcher createVersionMatcher(String provideValue)
From source file:org.xolstice.maven.toolchain.protobuf.DefaultProtobufToolchainFactory.java
License:Open Source License
@Override public ToolchainPrivate createToolchain(final ToolchainModel model) throws MisconfiguredToolchainException { if (model == null) { return null; }/* ww w.j a v a 2s. c o m*/ final DefaultProtobufToolchain toolchain = new DefaultProtobufToolchain(model, logger); // populate the configuration section final Properties configuration = toProperties((Xpp3Dom) model.getConfiguration()); final String protocExecutable = configuration.getProperty(DefaultProtobufToolchain.KEY_PROTOC_EXECUTABLE); if (protocExecutable == null) { throw new MisconfiguredToolchainException("Protobuf toolchain without the " + DefaultProtobufToolchain.KEY_PROTOC_EXECUTABLE + " configuration element."); } final String normalizedProtocExecutablePath = FileUtils.normalize(protocExecutable); final File protocExecutableFile = new File(normalizedProtocExecutablePath); if (protocExecutableFile.exists()) { toolchain.setProtocExecutable(normalizedProtocExecutablePath); } else { throw new MisconfiguredToolchainException( "Non-existing protoc executable at " + protocExecutableFile.getAbsolutePath()); } // populate the provides section final Properties provides = getProvidesProperties(model); for (final Map.Entry<Object, Object> provide : provides.entrySet()) { final String key = (String) provide.getKey(); final String value = (String) provide.getValue(); if (value == null) { throw new MisconfiguredToolchainException( "Provides token '" + key + "' doesn't have any value configured."); } final RequirementMatcher matcher; if ("version".equals(key)) { matcher = RequirementMatcherFactory.createVersionMatcher(value); } else { matcher = RequirementMatcherFactory.createExactMatcher(value); } toolchain.addProvideToken(key, matcher); } return toolchain; }