Skip to content

Commit

Permalink
add MavenPlugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Jun 21, 2024
1 parent c869e6f commit bc4c826
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
20 changes: 20 additions & 0 deletions src/main/java/org/apache/xmlbeans/impl/tool/MavenPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ public class MavenPlugin extends AbstractMojo {
@Parameter( defaultValue = "false" )
private boolean copyAnn;

/**
* The source code encoding to use when compiling the generated sources.
*
* @since 5.2.2
*/
@Parameter
private String sourceCodeEncoding;

/**
* Used for File Names.
*
* @since 5.2.2
*/
@Parameter( defaultValue = "false" )
private boolean useShortJavaName;

@Parameter
private List<Extension> extensions;

Expand Down Expand Up @@ -301,6 +317,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
params.setOutputJar(outputJar);
params.setDebug(debug);
params.setExtensions(extensions);
if (sourceCodeEncoding != null && !sourceCodeEncoding.isEmpty()) {
params.setSourceCodeEncoding(sourceCodeEncoding);
}
params.setUseShortJavaName(useShortJavaName);

boolean result = SchemaCompiler.compile(params);

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class Parameters {
private boolean noExt;
private boolean debug;
private boolean copyAnn;
private boolean useShortName;
private boolean useShortJavaName;
private String sourceCodeEncoding;
private boolean incrementalSrcGen;
private String repackage;
Expand Down Expand Up @@ -205,8 +205,8 @@ public boolean isNoAnn() {
return noAnn;
}

public boolean isUseShortName() {
return useShortName;
public boolean isUseShortJavaName() {
return useShortJavaName;
}

public String getSourceCodeEncoding() {
Expand Down Expand Up @@ -249,8 +249,8 @@ public void setDebug(boolean debug) {
this.debug = debug;
}

public void setUseShortName(boolean useShortName) {
this.useShortName = useShortName;
public void setUseShortJavaName(boolean useShortJavaName) {
this.useShortJavaName = useShortJavaName;
}

public void setSourceCodeEncoding(String sourceCodeEncoding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public static void main(String[] args) {
params.setNoExt(noExt);
params.setDebug(debug);
params.setSourceCodeEncoding(sourceCodeEncoding);
params.setUseShortName(useShortJavaName);
params.setUseShortJavaName(useShortJavaName);
params.setErrorListener(err);
params.setRepackage(repackage);
params.setExtensions(extensions);
Expand Down Expand Up @@ -629,7 +629,7 @@ public static boolean compile(Parameters params) {
boolean incrSrcGen = params.isIncrementalSrcGen();
boolean copyAnn = params.isCopyAnn();
String sourceCodeEncoding = params.getSourceCodeEncoding();
boolean useShortName = params.isUseShortName();
boolean useShortName = params.isUseShortJavaName();
Collection<XmlError> outerErrorListener = params.getErrorListener();
Set<BeanMethod> partialMethods = params.getPartialMethods();

Expand Down

0 comments on commit bc4c826

Please sign in to comment.