SystemPropertyDependencyLoader implements DependencyLoader { @Override public List<Dependency> load(Properties properties, Logger logger) throws LifecycleExecutionException { List<Dependency> dependencyList = new ArrayList<>(); String coordinates = System.getProperty(ExtensionSettings.DEPENDENCIES_SETTING_KEY, ""); if (coordinates.length() > 0) { for (String coordinate : coordinates.split(",")) { dependencyList.add(build(coordinate, properties, logger)); } if (!dependencyList.isEmpty()) { logger.info(String.format("Add %s dependencies found in system properties", dependencyList.size())); } } return dependencyList; }  @Override List<Dependency> load(Properties properties, Logger logger);  }
@Test public void shouldLoadFromSystemProperties() throws LifecycleExecutionException, URISyntaxException { System.setProperty(ExtensionSettings.DEPENDENCIES_SETTING_KEY, "org.foo:foo-artifact:1.0.0,org.bar:bar-artifact:1.5.0"); List<Dependency> dependencyList = loader.load(properties, logger); TestHelper.verifyDependencies(dependencyList); }
@Test public void shouldLoadFromSystemPropertiesWithVersionResolving() throws LifecycleExecutionException, URISyntaxException { System.setProperty(ExtensionSettings.DEPENDENCIES_SETTING_KEY, "org.foo:foo-artifact:@foo.version@,org.bar:bar-artifact:@bar.version@"); properties.put("foo.version", "1.0.0"); properties.put("bar.version", "1.5.0"); List<Dependency> dependencyList = loader.load(properties, logger); TestHelper.verifyDependencies(dependencyList); }
@Test public void shouldHandleNonExistingSystemProperty() throws LifecycleExecutionException { System.setProperty(ExtensionSettings.DEPENDENCIES_SETTING_KEY, ""); List<Dependency> dependencyList = loader.load(properties, logger); Assertions.assertThat(dependencyList).isEmpty(); }