Skip to content

Commit 288b5b7

Browse files
committed
Ensure that the Maven plugin configuration keeps working
The Maven Plugin was using the core ModuleDependency type as part of its configuration, which requires that the type has a zero-argument constructor. When this constructor was removed it broke the Maven Plugin configuration. This commit adds a type directly to the Maven Plugin, ensuring that the future evolution of ModuleDependency does not break the Maven Plugin and vice-versa Fixes #1140 Signed-off-by: Tim Ward <timothyjward@apache.org>
1 parent 1d036f7 commit 288b5b7

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

typescript-generator-maven-plugin/src/main/java/cz/habarta/typescript/generator/maven/GenerateMojo.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import cz.habarta.typescript.generator.JsonbConfiguration;
1414
import cz.habarta.typescript.generator.Logger;
1515
import cz.habarta.typescript.generator.MapMapping;
16-
import cz.habarta.typescript.generator.ModuleDependency;
1716
import cz.habarta.typescript.generator.NullabilityDefinition;
1817
import cz.habarta.typescript.generator.OptionalProperties;
1918
import cz.habarta.typescript.generator.OptionalPropertiesDeclaration;
@@ -30,6 +29,7 @@
3029
import java.net.URLClassLoader;
3130
import java.util.ArrayList;
3231
import java.util.List;
32+
import java.util.Optional;
3333
import org.apache.maven.artifact.DependencyResolutionRequiredException;
3434
import org.apache.maven.plugin.AbstractMojo;
3535
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -900,7 +900,13 @@ private Settings createSettings(URLClassLoader classLoader) {
900900
settings.namespace = namespace;
901901
settings.mapPackagesToNamespaces = mapPackagesToNamespaces;
902902
settings.umdNamespace = umdNamespace;
903-
settings.moduleDependencies = moduleDependencies;
903+
settings.moduleDependencies = Optional.ofNullable(moduleDependencies)
904+
.map(list -> list.stream().map(md -> {
905+
return new cz.habarta.typescript.generator.ModuleDependency(false,
906+
md.importFrom, md.importAs, md.infoJson, md.npmPackageName, md.npmVersionRange,
907+
md.npmPackageName != null);
908+
}).toList())
909+
.orElse(List.of());
904910
settings.setExcludeFilter(excludeClasses, excludeClassPatterns);
905911
settings.jsonLibrary = jsonLibrary;
906912
settings.setJackson2Configuration(classLoader, jackson2Configuration);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
package cz.habarta.typescript.generator.maven;
3+
4+
import cz.habarta.typescript.generator.util.Utils;
5+
import java.io.File;
6+
import org.jspecify.annotations.Nullable;
7+
8+
/**
9+
* A simple data class representing a module dependency for the TypeScript
10+
* generator Maven plugin. It decouples the ModuleDependency class from the core
11+
* TypeScript generator library, allowing foreasier maintenance and potential future
12+
* changes in the core library without being limited by the Maven plugin's requirements.
13+
*/
14+
public class ModuleDependency {
15+
@SuppressWarnings("NullAway.Init")
16+
public String importFrom;
17+
@SuppressWarnings("NullAway.Init")
18+
public String importAs;
19+
@SuppressWarnings("NullAway.Init")
20+
public File infoJson;
21+
public @Nullable String npmPackageName;
22+
public @Nullable String npmVersionRange;
23+
24+
@Override
25+
public String toString() {
26+
return Utils.objectToString(this);
27+
}
28+
29+
}

0 commit comments

Comments
 (0)