Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.polyapi</groupId>
<artifactId>parent-pom</artifactId>
<version>0.15.5-SNAPSHOT</version>
<version>0.15.6-SNAPSHOT</version>
<relativePath>../parent-pom</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.polyapi</groupId>
<artifactId>parent-pom</artifactId>
<version>0.15.5-SNAPSHOT</version>
<version>0.15.6-SNAPSHOT</version>
<relativePath>../parent-pom</relativePath>
</parent>
<artifactId>library</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion parent-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.polyapi</groupId>
<artifactId>parent-pom</artifactId>
<version>0.15.5-SNAPSHOT</version>
<version>0.15.6-SNAPSHOT</version>
<packaging>pom</packaging>
<name>PolyAPI Java parent POM</name>
<url>https://polyapi.io</url>
Expand Down
2 changes: 1 addition & 1 deletion polyapi-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.polyapi</groupId>
<artifactId>parent-pom</artifactId>
<version>0.15.5-SNAPSHOT</version>
<version>0.15.6-SNAPSHOT</version>
<relativePath>../parent-pom</relativePath>
</parent>
<artifactId>polyapi-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ public class GenerateSourcesMojo extends PolyApiMojo {
@Parameter(property = "overwrite", defaultValue = "false")
private Boolean overwrite;

@Parameter(property = "context")
private String context;
@Parameter(property = "contexts")
private String contexts;

@Parameter(property = "functionIds")
private String functionIds;

private PolyGenerationService polyGenerationService;

@Override
public void execute(String host, Integer port) {
log.info("Initiating generation of Poly sources.");
this.polyGenerationService = new PolyGenerationServiceImpl(getHttpClient(), getJsonParser(), host, port, getTokenProvider().getToken());
List<String> contextFilters = Arrays.stream(Optional.ofNullable(context).map(contextCsv -> contextCsv.split(",")).orElse(new String[]{""})).toList();
List<String> contextFilters = Arrays.stream(Optional.ofNullable(contexts).map(contextCsv -> contextCsv.split(",")).orElse(new String[]{""})).toList();
log.debug("Context filters: \"{}\"", join("\", \"", contextFilters));
this.polyGenerationService.generate(contextFilters, overwrite);

List<String> functionIdFilters = Arrays.stream(Optional.ofNullable(functionIds).map(functionIdsCsv -> functionIdsCsv.split(",")).orElse(new String[]{""})).toList();
log.debug("Function ID filters: \"{}\"", join("\", \"", functionIdFilters));

this.polyGenerationService.generate(contextFilters, functionIdFilters, overwrite);
log.info("Poly generation complete.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

public interface PolyGenerationService {

void generate(List<String> contextFilters, boolean overwrite);
void generate(List<String> contextFilters, List<String> functionIdFilters, boolean overwrite);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,21 @@ public PolyGenerationServiceImpl(HttpClient httpClient, JsonParser jsonParser, S
}

@Override
public void generate(List<String> contextFilters, boolean overwrite) {
public void generate(List<String> contextFilters, List<String> functionIdFilters, boolean overwrite) {
var specifications = specificationService.list(contextFilters);
log.debug("Applying function ID filters for: {}", functionIdFilters);
if (functionIdFilters != null && !functionIdFilters.isEmpty()) {
log.info("specifications: {}", specifications);
specifications = specifications.stream()
.filter(spec -> {
if (spec instanceof FunctionSpecification functionSpec) {
log.debug("Applicable function ID: {}", functionSpec.getId());
return functionIdFilters.contains(functionSpec.getId());
}
return true;
})
.toList();
}
var contextModel = new HashMap<String, Object>();
contextModel.put("clientId", UUID.randomUUID().toString());
contextModel.put("host", host);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.polyapi</groupId>
<artifactId>polyapi-java</artifactId>
<version>0.15.5-SNAPSHOT</version>
<version>0.15.6-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>parent-pom</module>
Expand Down