@Test public void copiesModelFromJarWithNonSourceProjection() throws URISyntaxException { Model model = Model.assembler() .addImport(getClass().getResource("sources/jar-import.jar")) .addImport(getClass().getResource("notsources/d.smithy")) .assemble() .unwrap(); MockManifest manifest = new MockManifest(); ProjectionConfig projection = ProjectionConfig.builder().build(); PluginContext context = PluginContext.builder() .fileManifest(manifest) .projection("foo", projection) .model(model) .originalModel(model) .sources(ListUtils.of(Paths.get(getClass().getResource("sources/jar-import.jar").toURI()))) .build(); new SourcesPlugin().execute(context); String manifestString = manifest.getFileString("manifest").get(); manifestString = manifestString.replace("\\", "/"); assertThat(manifestString, containsString("model.json")); assertThat(manifestString, not(containsString("jar-import"))); assertThat(manifest.getFileString("model.json").get(), containsString("\"foo.baz#A\"")); assertThat(manifest.getFileString("model.json").get(), containsString("\"foo.baz#B\"")); assertThat(manifest.getFileString("model.json").get(), containsString("\"foo.baz#C\"")); }
@Override public void execute(PluginContext context) { if (!context.getOriginalModel().isPresent()) { LOGGER.warning("No original model was provided, so the sources plugin cannot run"); return; } List<String> names; String projectionName = context.getProjectionName(); if (projectionName.equals("source")) { names = copySources(context); LOGGER.fine(() -> String.format("Copying source files to the sources of %s: %s", projectionName, names)); } else { LOGGER.fine(() -> String.format( "Creating the `%s` sources by extracting relevant components from the original model", projectionName)); names = ListUtils.of(PROJECTED_FILENAME); projectSources(context); } if (names.isEmpty()) { LOGGER.info(String.format("Skipping `%s` manifest because no Smithy sources found", projectionName)); } else { LOGGER.fine(() -> String.format("Writing `%s` manifest", projectionName)); String manifest = names.stream().map(name -> name.replace("\\", "/")).collect(Collectors.joining("\n")); context.getFileManifest().writeFile("manifest", manifest + "\n"); } }
SourcesPlugin implements SmithyBuildPlugin { @Override public void execute(PluginContext context) { if (!context.getOriginalModel().isPresent()) { LOGGER.warning("No original model was provided, so the sources plugin cannot run"); return; } List<String> names; String projectionName = context.getProjectionName(); if (projectionName.equals("source")) { names = copySources(context); LOGGER.fine(() -> String.format("Copying source files to the sources of %s: %s", projectionName, names)); } else { LOGGER.fine(() -> String.format( "Creating the `%s` sources by extracting relevant components from the original model", projectionName)); names = ListUtils.of(PROJECTED_FILENAME); projectSources(context); } if (names.isEmpty()) { LOGGER.info(String.format("Skipping `%s` manifest because no Smithy sources found", projectionName)); } else { LOGGER.fine(() -> String.format("Writing `%s` manifest", projectionName)); String manifest = names.stream().map(name -> name.replace("\\", "/")).collect(Collectors.joining("\n")); context.getFileManifest().writeFile("manifest", manifest + "\n"); } } }
SourcesPlugin implements SmithyBuildPlugin { @Override public void execute(PluginContext context) { if (!context.getOriginalModel().isPresent()) { LOGGER.warning("No original model was provided, so the sources plugin cannot run"); return; } List<String> names; String projectionName = context.getProjectionName(); if (projectionName.equals("source")) { names = copySources(context); LOGGER.fine(() -> String.format("Copying source files to the sources of %s: %s", projectionName, names)); } else { LOGGER.fine(() -> String.format( "Creating the `%s` sources by extracting relevant components from the original model", projectionName)); names = ListUtils.of(PROJECTED_FILENAME); projectSources(context); } if (names.isEmpty()) { LOGGER.info(String.format("Skipping `%s` manifest because no Smithy sources found", projectionName)); } else { LOGGER.fine(() -> String.format("Writing `%s` manifest", projectionName)); String manifest = names.stream().map(name -> name.replace("\\", "/")).collect(Collectors.joining("\n")); context.getFileManifest().writeFile("manifest", manifest + "\n"); } }  }
SourcesPlugin implements SmithyBuildPlugin { @Override public void execute(PluginContext context) { if (!context.getOriginalModel().isPresent()) { LOGGER.warning("No original model was provided, so the sources plugin cannot run"); return; } List<String> names; String projectionName = context.getProjectionName(); if (projectionName.equals("source")) { names = copySources(context); LOGGER.fine(() -> String.format("Copying source files to the sources of %s: %s", projectionName, names)); } else { LOGGER.fine(() -> String.format( "Creating the `%s` sources by extracting relevant components from the original model", projectionName)); names = ListUtils.of(PROJECTED_FILENAME); projectSources(context); } if (names.isEmpty()) { LOGGER.info(String.format("Skipping `%s` manifest because no Smithy sources found", projectionName)); } else { LOGGER.fine(() -> String.format("Writing `%s` manifest", projectionName)); String manifest = names.stream().map(name -> name.replace("\\", "/")).collect(Collectors.joining("\n")); context.getFileManifest().writeFile("manifest", manifest + "\n"); } }  @Override String getName(); @Override void execute(PluginContext context); }
SourcesPlugin implements SmithyBuildPlugin { @Override public void execute(PluginContext context) { if (!context.getOriginalModel().isPresent()) { LOGGER.warning("No original model was provided, so the sources plugin cannot run"); return; } List<String> names; String projectionName = context.getProjectionName(); if (projectionName.equals("source")) { names = copySources(context); LOGGER.fine(() -> String.format("Copying source files to the sources of %s: %s", projectionName, names)); } else { LOGGER.fine(() -> String.format( "Creating the `%s` sources by extracting relevant components from the original model", projectionName)); names = ListUtils.of(PROJECTED_FILENAME); projectSources(context); } if (names.isEmpty()) { LOGGER.info(String.format("Skipping `%s` manifest because no Smithy sources found", projectionName)); } else { LOGGER.fine(() -> String.format("Writing `%s` manifest", projectionName)); String manifest = names.stream().map(name -> name.replace("\\", "/")).collect(Collectors.joining("\n")); context.getFileManifest().writeFile("manifest", manifest + "\n"); } }  @Override String getName(); @Override void execute(PluginContext context);  }