@Test public void treatsNewlyAddedShapesAsNewSources() throws URISyntaxException { Model originalModel = Model.assembler().assemble().unwrap(); Model newModel = Model.assembler() .addShape(StringShape.builder().id("a.b#MyString").build()) .assemble() .unwrap(); MockManifest manifest = new MockManifest(); ProjectionConfig projection = ProjectionConfig.builder().build(); PluginContext context = PluginContext.builder() .projection("foo", projection) .fileManifest(manifest) .originalModel(originalModel) .model(newModel) .sources(ListUtils.of(Paths.get(getClass().getResource("sources/a.smithy").toURI()).getParent())) .build(); new SourcesPlugin().execute(context); String modelString = manifest.getFileString("model.json").get(); assertThat(modelString, containsString("MyString")); }
@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);  }