Search in sources :

Example 1 with GenerateInspectionsMojo

use of io.atlasmap.maven.GenerateInspectionsMojo in project syndesis by syndesisio.

the class GenerateMapperInspectionsMojo method process.

private void process(final Set<File> generated, final Connector connector, final ConnectorAction action, final Optional<DataShape> maybeShape) throws MojoFailureException, MojoExecutionException {
    if (!maybeShape.isPresent()) {
        return;
    }
    if (!connector.getId().isPresent()) {
        return;
    }
    if (!DataShapeKinds.JAVA.equals(maybeShape.get().getKind())) {
        return;
    }
    final DataShape shape = maybeShape.get();
    getLog().info("Generating for connector: " + connector.getId().get() + ", and type: " + shape.getType());
    final File outputFile = new File(outputDir, resourceDir + "/" + connector.getId().get() + "/" + shape.getType() + ".json");
    if (generated.contains(outputFile)) {
        return;
    }
    if (outputFile.getParentFile().mkdirs()) {
        getLog().debug("Created dir: " + outputFile.getParentFile());
    }
    List<String> artifacts = Stream.of(connector, action).map(WithDependencies.class::cast).map(WithDependencies::getDependencies).flatMap(Collection::stream).filter(Dependency::isMaven).map(Dependency::getId).collect(Collectors.toList());
    final GenerateInspectionsMojo generateInspectionsMojo = new GenerateInspectionsMojo();
    generateInspectionsMojo.setLog(getLog());
    generateInspectionsMojo.setPluginContext(getPluginContext());
    generateInspectionsMojo.setSystem(system);
    generateInspectionsMojo.setRemoteRepos(remoteRepos);
    generateInspectionsMojo.setRepoSession(repoSession);
    generateInspectionsMojo.setArtifacts(artifacts);
    generateInspectionsMojo.setClassName(shape.getType());
    generateInspectionsMojo.setArtifacts(artifacts);
    generateInspectionsMojo.setOutputFile(outputFile);
    generateInspectionsMojo.execute();
    generated.add(outputFile);
}
Also used : WithDependencies(io.syndesis.common.model.WithDependencies) GenerateInspectionsMojo(io.atlasmap.maven.GenerateInspectionsMojo) Dependency(io.syndesis.common.model.Dependency) DataShape(io.syndesis.common.model.DataShape) File(java.io.File)

Aggregations

GenerateInspectionsMojo (io.atlasmap.maven.GenerateInspectionsMojo)1 DataShape (io.syndesis.common.model.DataShape)1 Dependency (io.syndesis.common.model.Dependency)1 WithDependencies (io.syndesis.common.model.WithDependencies)1 File (java.io.File)1