Skip to content

Commit

Permalink
Simplify code of retrieval of dependencies versions for maven plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
murdos committed Jan 20, 2024
1 parent aca60eb commit 3a7d814
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import tech.jhipster.lite.module.domain.javabuildprofile.BuildProfileId;
import tech.jhipster.lite.module.domain.javadependency.JavaDependenciesVersions;
import tech.jhipster.lite.module.domain.javadependency.JavaDependency;
import tech.jhipster.lite.module.domain.javadependency.JavaDependencyVersion;
import tech.jhipster.lite.module.domain.javadependency.ProjectJavaDependencies;
import tech.jhipster.lite.shared.error.domain.Assert;

Expand Down Expand Up @@ -76,10 +77,7 @@ private static <C extends AddMavenPlugin> Function<MavenPlugin, C> toAddMavenPlu
plugin
.dependencies()
.stream()
.map(JavaDependency::version)
.flatMap(Optional::stream)
.map(JavaDependency.toVersion(versions, projectDependencies))
.flatMap(Optional::stream)
.flatMap(toDependencyVersion(versions, projectDependencies))
.forEach(commandBuilder::addDependencyVersion);
return plugin
.versionSlug()
Expand All @@ -90,6 +88,13 @@ private static <C extends AddMavenPlugin> Function<MavenPlugin, C> toAddMavenPlu
};
}

private static Function<JavaDependency, Stream<JavaDependencyVersion>> toDependencyVersion(
JavaDependenciesVersions versions,
ProjectJavaDependencies projectDependencies
) {
return dependency -> dependency.version().flatMap(JavaDependency.toVersion(versions, projectDependencies)).stream();
}

public static class JHipsterModuleMavenPluginsBuilder<T> {

private final T parentModuleBuilder;
Expand Down

0 comments on commit 3a7d814

Please sign in to comment.