Skip to content

Commit

Permalink
add option to not generate javadoc
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Feb 17, 2021
1 parent 6902fb3 commit d0785e0
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -100,6 +100,13 @@ public class ResourceGenMojo extends AbstractMojo {
@Parameter(property = "atGenerated", defaultValue = "false")
private boolean atGenerated;

/**
* Generate javadoc comments.
* @since 4.0.1
*/
@Parameter(property = "rs.javadoc", defaultValue = "true")
private boolean javadoc;

/**
* File encoding for generated sources.
* @since 2.12
Expand Down Expand Up @@ -212,9 +219,11 @@ public void execute() throws MojoExecutionException {
throw new MojoExecutionException("Name conflict "+className);
}

clazz.javadoc().add(
"Defines string formatting method for each constant in the resource file"
);
if (javadoc) {
clazz.javadoc().add(
"Defines string formatting method for each constant in the resource file"
);
}

if (atGenerated) {
// no direct dependency on Jakarta annotations API
Expand Down Expand Up @@ -294,7 +303,9 @@ public ResourceBundle getResourceBundle(Locale locale) {
method.body()._return(format);

JMethod method2 = clazz.method(JMod.PUBLIC|JMod.STATIC, String.class, methodBaseName);
method2.javadoc().add(e.getValue());
if (javadoc) {
method2.javadoc().add(escape(e.getValue().toString()));
}

JInvocation localize = JExpr.invoke(method);
for( int i=0; i<countArgs; i++ ) {
Expand Down Expand Up @@ -347,6 +358,10 @@ private String getClassName(File res) {
return NameConverter.smart.toClassName(name)+"Messages";
}

private String escape(String s) {
return s.replaceAll("<", "{@code <}").replaceAll(">", "{@code >}");
}

/**
* Writes all the source files under the specified file folder and inserts a
* license file each java source file.
Expand Down

0 comments on commit d0785e0

Please sign in to comment.