-
Notifications
You must be signed in to change notification settings - Fork 2
Breaking/migrate maven to plugin parameters #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
buchananwill
wants to merge
15
commits into
ivangreene:main
Choose a base branch
from
buchananwill:breaking/migrate-maven-to-plugin-parameters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
459e322
Adding gradle-plugin implementation.
buchananwill 8947f14
Test is running but classes need to be build first.
buchananwill 46ca2f1
Test passes.
buchananwill ac91e97
Added a schemas_snapshot.ts to check against the generated output.
buchananwill e9ec9f7
Added a Typescript project with Jest and Zod to check the schemas_sna…
buchananwill 5c15132
Improved the specificity of the validation by checking each field ind…
buchananwill f1c0cfd
Added java-doc on the red-herring fields to note that they should be …
buchananwill d370686
Now building with nested parameters object.
buchananwill fd74614
Gradle build is not compromised by Maven annotations.
buchananwill 1cf8d94
Pulled the settings creation code into a delegate.
buchananwill ef373a8
Pulled all the shared code into a wrapper.
buchananwill 4421897
Moved the PluginParameters and JavaToZodConvertorWrapper into the cor…
buchananwill 7723889
Moved the version to 0.8.0 and build the maven plugin with the nested…
buchananwill 059435b
Build Maven using a local GradleApi jar from a system env.
buchananwill 6735d07
Replacing the local .env with the JetBrains hosted gradle api jar.
buchananwill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
java-to-zod-core/src/main/java/sh/ivan/zod/JavaToZodConvertorWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package sh.ivan.zod; | ||
|
||
import cz.habarta.typescript.generator.*; | ||
import cz.habarta.typescript.generator.parser.Model; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URLClassLoader; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
import sh.ivan.zod.plugins.PluginParameters; | ||
import sh.ivan.zod.schema.ObjectSchema; | ||
|
||
public class JavaToZodConvertorWrapper { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested name: |
||
private final URLClassLoader classLoader; | ||
private final PluginParameters pluginParameters; | ||
private final Supplier<File> getOutputFile; | ||
|
||
public JavaToZodConvertorWrapper( | ||
URLClassLoader classLoader, PluginParameters pluginParameters, Supplier<File> getOutputFile) { | ||
this.classLoader = classLoader; | ||
this.pluginParameters = pluginParameters; | ||
this.getOutputFile = getOutputFile; | ||
} | ||
|
||
public void run() throws IOException { | ||
Settings settings = from(classLoader, pluginParameters); | ||
|
||
Input.Parameters parameters = new Input.Parameters(); | ||
parameters.classNames = pluginParameters.getClasses(); | ||
parameters.classNamePatterns = pluginParameters.getClassPatterns(); | ||
parameters.classesWithAnnotations = pluginParameters.getClassesWithAnnotations(); | ||
parameters.classesImplementingInterfaces = pluginParameters.getClassesImplementingInterfaces(); | ||
parameters.classesExtendingClasses = pluginParameters.getClassesExtendingClasses(); | ||
parameters.jaxrsApplicationClassName = pluginParameters.getClassesFromJaxrsApplication(); | ||
parameters.automaticJaxrsApplication = pluginParameters.isClassesFromAutomaticJaxrsApplication(); | ||
parameters.isClassNameExcluded = settings.getExcludeFilter(); | ||
parameters.classLoader = classLoader; | ||
parameters.scanningAcceptedPackages = pluginParameters.getScanningAcceptedPackages(); | ||
parameters.debug = pluginParameters.getLoggingLevel() == Logger.Level.Debug; | ||
|
||
Input input = Input.from(parameters); | ||
TypeScriptGenerator typeScriptGenerator = new TypeScriptGenerator(settings); | ||
Model model = typeScriptGenerator.getModelParser().parseModel(input.getSourceTypes()); | ||
Configuration configuration = Configuration.builder() | ||
.schemaNamePrefix(pluginParameters.getSchemaNamePrefix()) | ||
.schemaNameSuffix(pluginParameters.getSchemaNameSuffix()) | ||
.build(); | ||
JavaToZodConverter javaToZodConverter = | ||
new JavaToZodConverter(typeScriptGenerator.getModelParser(), configuration); | ||
Map<String, ObjectSchema> beanSchemas = javaToZodConverter.getBeanSchemas(model); | ||
SchemaFileWriter schemaFileWriter = new SchemaFileWriter(beanSchemas, getOutputFile.get()); | ||
schemaFileWriter.write(); | ||
} | ||
|
||
private Settings from(URLClassLoader classLoader, PluginParameters pluginParameters) { | ||
Settings settings = new Settings(); | ||
settings.setExcludeFilter(pluginParameters.getExcludeClasses(), pluginParameters.getExcludeClassPatterns()); | ||
settings.jsonLibrary = pluginParameters.getJsonLibrary(); | ||
settings.setJackson2Configuration(classLoader, pluginParameters.getJackson2Configuration()); | ||
settings.gsonConfiguration = pluginParameters.getGsonConfiguration(); | ||
settings.jsonbConfiguration = pluginParameters.getJsonbConfiguration(); | ||
settings.scanSpringApplication = pluginParameters.isScanSpringApplication(); | ||
settings.loadIncludePropertyAnnotations(classLoader, pluginParameters.getIncludePropertyAnnotations()); | ||
settings.loadExcludePropertyAnnotations(classLoader, pluginParameters.getIncludePropertyAnnotations()); | ||
settings.classLoader = classLoader; | ||
settings.outputKind = TypeScriptOutputKind.global; // Unused, but required by settings validation | ||
settings.outputFileType = TypeScriptFileType.implementationFile; | ||
settings.loadOptionalAnnotations(classLoader, pluginParameters.getOptionalAnnotations()); | ||
return settings; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change the version number. This is all handled automatically when I do the release