Search in sources :

Example 1 with WithDependencies

use of io.syndesis.common.model.WithDependencies 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)

Example 2 with WithDependencies

use of io.syndesis.common.model.WithDependencies in project syndesis by syndesisio.

the class IntegrationResourceManager method collectDependencies.

/**
 * Collect dependencies.
 */
default Collection<Dependency> collectDependencies(Collection<? extends Step> steps, boolean resolveExtensionTags) {
    final List<Dependency> dependencies = new ArrayList<>();
    for (Step step : steps) {
        step.getAction().filter(WithDependencies.class::isInstance).map(WithDependencies.class::cast).map(WithDependencies::getDependencies).ifPresent(dependencies::addAll);
        List<Dependency> connectorDependencies = step.getConnection().flatMap(Connection::getConnector).map(WithDependencies::getDependencies).orElse(Collections.emptyList());
        dependencies.addAll(connectorDependencies);
        List<Dependency> lookedUpConnectorDependecies = step.getConnection().filter(c -> !c.getConnector().isPresent()).map(Connection::getConnectorId).flatMap(this::loadConnector).map(WithDependencies::getDependencies).orElse(Collections.emptyList());
        dependencies.addAll(lookedUpConnectorDependecies);
        // Connector extension
        Stream.concat(connectorDependencies.stream(), lookedUpConnectorDependecies.stream()).filter(Dependency::isExtension).map(Dependency::getId).map(this::loadExtension).filter(Optional::isPresent).map(Optional::get).map(Extension::getDependencies).forEach(dependencies::addAll);
        // Step extension
        step.getExtension().map(WithDependencies::getDependencies).ifPresent(dependencies::addAll);
        step.getExtension().map(Extension::getExtensionId).map(Dependency::extension).ifPresent(dependencies::add);
    }
    if (resolveExtensionTags) {
        return dependencies.stream().flatMap(dep -> {
            if (dep.isExtensionTag()) {
                List<Extension> extensions = this.loadExtensionsByTag(dep.getId());
                Stream<Dependency> extensionDependency = extensions.stream().map(ext -> Dependency.extension(ext.getExtensionId()));
                Stream<Dependency> transitive = extensions.stream().map(Extension::getDependencies).flatMap(Collection::stream);
                return Stream.concat(extensionDependency, transitive);
            } else {
                return Stream.of(dep);
            }
        }).collect(Collectors.toCollection(ArrayList::new));
    } else {
        return dependencies;
    }
}
Also used : Extension(io.syndesis.common.model.extension.Extension) Step(io.syndesis.common.model.integration.Step) Collection(java.util.Collection) Connector(io.syndesis.common.model.connection.Connector) Extension(io.syndesis.common.model.extension.Extension) WithDependencies(io.syndesis.common.model.WithDependencies) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Dependency(io.syndesis.common.model.Dependency) List(java.util.List) Stream(java.util.stream.Stream) Connection(io.syndesis.common.model.connection.Connection) Optional(java.util.Optional) Integration(io.syndesis.common.model.integration.Integration) Collections(java.util.Collections) InputStream(java.io.InputStream) WithDependencies(io.syndesis.common.model.WithDependencies) Optional(java.util.Optional) ArrayList(java.util.ArrayList) Connection(io.syndesis.common.model.connection.Connection) ArrayList(java.util.ArrayList) List(java.util.List) Stream(java.util.stream.Stream) InputStream(java.io.InputStream) Dependency(io.syndesis.common.model.Dependency) Step(io.syndesis.common.model.integration.Step)

Aggregations

Dependency (io.syndesis.common.model.Dependency)2 WithDependencies (io.syndesis.common.model.WithDependencies)2 GenerateInspectionsMojo (io.atlasmap.maven.GenerateInspectionsMojo)1 DataShape (io.syndesis.common.model.DataShape)1 Connection (io.syndesis.common.model.connection.Connection)1 Connector (io.syndesis.common.model.connection.Connector)1 Extension (io.syndesis.common.model.extension.Extension)1 Integration (io.syndesis.common.model.integration.Integration)1 Step (io.syndesis.common.model.integration.Step)1 File (java.io.File)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1