Skip to content

Commit

Permalink
Working on #114.
Browse files Browse the repository at this point in the history
  • Loading branch information
highsource committed May 18, 2018
1 parent 4655249 commit 3c15b7e
Show file tree
Hide file tree
Showing 25 changed files with 235 additions and 59 deletions.
11 changes: 11 additions & 0 deletions plugin-2.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb20.version}</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
Expand All @@ -47,6 +51,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public Options createOptions(OptionsConfiguration optionsConfiguration)
System.setProperty("javax.xml.accessExternalDTD",
optionsConfiguration.getAccessExternalDTD());
}
if (optionsConfiguration.isEnableExternalEntityProcessing()) {
System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
}
// options.contentForWildcard =
// optionsConfiguration.isContentForWildcard()

Expand Down
11 changes: 11 additions & 0 deletions plugin-2.1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
Expand All @@ -59,6 +63,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public Options createOptions(OptionsConfiguration optionsConfiguration)
System.setProperty("javax.xml.accessExternalDTD",
optionsConfiguration.getAccessExternalDTD());
}
if (optionsConfiguration.isEnableExternalEntityProcessing()) {
System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
}
options.contentForWildcard = optionsConfiguration
.isContentForWildcard();

Expand Down
11 changes: 11 additions & 0 deletions plugin-2.2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<groupId>com.sun.xml.fastinfoset</groupId>
<artifactId>FastInfoset</artifactId>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</dependency>
<!-- End of jaxb-runtime dependencies -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
Expand Down Expand Up @@ -99,6 +103,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public Options createOptions(OptionsConfiguration optionsConfiguration)
System.setProperty("javax.xml.accessExternalDTD",
optionsConfiguration.getAccessExternalDTD());
}
if (optionsConfiguration.isEnableExternalEntityProcessing()) {
System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
}
options.contentForWildcard = optionsConfiguration
.isContentForWildcard();

Expand Down
10 changes: 5 additions & 5 deletions plugin-2.3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@
</dependencies>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public Options createOptions(OptionsConfiguration optionsConfiguration)
System.setProperty("javax.xml.accessExternalDTD",
optionsConfiguration.getAccessExternalDTD());
}
if (optionsConfiguration.isEnableExternalEntityProcessing()) {
System.setProperty("enableExternalEntityProcessing", Boolean.TRUE.toString());
}
options.contentForWildcard = optionsConfiguration
.isContentForWildcard();

Expand Down
10 changes: 9 additions & 1 deletion plugin-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<version>0.14.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -56,8 +61,11 @@
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,20 @@ public String getAccessExternalDTD() {
public void setAccessExternalDTD(String accessExternalDTD) {
this.accessExternalDTD = accessExternalDTD;
}

/**
* Enables external entity processing.
*/
@Parameter(defaultValue = "true", property = "maven.xjc2.enableExternalEntityProcessing")
private boolean enableExternalEntityProcessing;

public boolean isEnableExternalEntityProcessing() {
return enableExternalEntityProcessing;
}

public void setEnableExternalEntityProcessing(boolean enableExternalEntityProcessing) {
this.enableExternalEntityProcessing = enableExternalEntityProcessing;
}

/**
* If 'true', generates content property for types with multiple xs:any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class OptionsConfiguration {
private final boolean disableXmlSecurity;
private final String accessExternalSchema;
private final String accessExternalDTD;
private final boolean enableExternalEntityProcessing;
private final boolean contentForWildcard;

private final boolean extension;
Expand All @@ -54,8 +55,8 @@ public OptionsConfiguration(String encoding, String schemaLanguage,
boolean packageLevelAnnotations, boolean noFileHeader,
boolean enableIntrospection, boolean disableXmlSecurity,
String accessExternalSchema, String accessExternalDTD,
boolean enableExternalEntityProcessing,
boolean contentForWildcard,

boolean extension, boolean strict, boolean verbose,
boolean debugMode, List<String> arguments, List<URL> plugins,
String specVersion) {
Expand All @@ -74,6 +75,7 @@ public OptionsConfiguration(String encoding, String schemaLanguage,
this.disableXmlSecurity = disableXmlSecurity;
this.accessExternalSchema = accessExternalSchema;
this.accessExternalDTD = accessExternalDTD;
this.enableExternalEntityProcessing = enableExternalEntityProcessing;
this.contentForWildcard = contentForWildcard;
this.extension = extension;
this.strict = strict;
Expand Down Expand Up @@ -139,6 +141,10 @@ public String getAccessExternalSchema() {
public String getAccessExternalDTD() {
return accessExternalDTD;
}

public boolean isEnableExternalEntityProcessing() {
return enableExternalEntityProcessing;
}

public boolean isContentForWildcard() {
return contentForWildcard;
Expand Down
69 changes: 33 additions & 36 deletions plugin-core/src/main/java/org/jvnet/jaxb2/maven2/RawXJC2Mojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ public void execute() throws MojoExecutionException {
}

/**
* *************************************************************************
* *
* ************************************************************************* *
*/

protected void injectDependencyDefaults() {
Expand Down Expand Up @@ -497,22 +496,21 @@ private void setupBindInfoPackage() {
if (xmlSchema == null) {
getLog().warn(MessageFormat.format(
"Class [{0}] is missing the [{1}] annotation. Processing bindings will probably fail.",
packageInfoClassName,
XmlSchema.class.getName()));
}
else {
packageInfoClassName, XmlSchema.class.getName()));
} else {
final String namespace = xmlSchema.namespace();
if (!JAXB_NSURI.equals(namespace)) {
getLog().warn(MessageFormat.format(
"Namespace of the [{0}] annotation is [{1}] and does not match [{2}]. Processing bindings will probably fail.",
namespace,
XmlSchema.class.getName(),
JAXB_NSURI));
namespace, XmlSchema.class.getName(), JAXB_NSURI));
}
}

} catch (ClassNotFoundException cnfex) {
getLog().warn(MessageFormat.format("Class [{0}] could not be found. Processing bindings will probably faile.", packageInfoClassName), cnfex);
getLog().warn(
MessageFormat.format("Class [{0}] could not be found. Processing bindings will probably faile.",
packageInfoClassName),
cnfex);
}

}
Expand All @@ -525,22 +523,21 @@ private void setupEpisodePackage() {
if (xmlNamespace == null) {
getLog().warn(MessageFormat.format(
"Class [{0}] is missing the [{1}] annotation. Processing bindings will probably fail.",
packageInfoClassName,
XmlNamespace.class.getName()));
}
else {
packageInfoClassName, XmlNamespace.class.getName()));
} else {
final String namespace = xmlNamespace.value();
if (!JAXB_NSURI.equals(namespace)) {
getLog().warn(MessageFormat.format(
"Namespace of the [{0}] annotation is [{1}] and does not match [{2}]. Processing bindings will probably fail.",
XmlNamespace.class.getName(),
namespace,
JAXB_NSURI));
XmlNamespace.class.getName(), namespace, JAXB_NSURI));
}
}

} catch (ClassNotFoundException cnfex) {
getLog().warn(MessageFormat.format("Class [{0}] could not be found. Processing bindings will probably faile.", packageInfoClassName), cnfex);
getLog().warn(
MessageFormat.format("Class [{0}] could not be found. Processing bindings will probably faile.",
packageInfoClassName),
cnfex);
}

}
Expand Down Expand Up @@ -604,11 +601,10 @@ private void checkCatalogsInStrictMode() {
public abstract void doExecute(O options) throws MojoExecutionException;

/**
* Initializes logging. If Maven is run in debug mode (that is, debug level
* is enabled in the log), turn on the verbose mode in Mojo. Further on, if
* vebose mode is on, set the
* <code>com.sun.tools.xjc.Options.findServices</code> system property on to
* enable debuggin of XJC plugins.
* Initializes logging. If Maven is run in debug mode (that is, debug level is
* enabled in the log), turn on the verbose mode in Mojo. Further on, if vebose
* mode is on, set the <code>com.sun.tools.xjc.Options.findServices</code>
* system property on to enable debuggin of XJC plugins.
*
*/
protected void setupLogging() {
Expand Down Expand Up @@ -773,8 +769,8 @@ protected List<URI> createProducesURIs() throws MojoExecutionException {
}

/**
* Log the configuration settings. Shown when exception thrown or when
* verbose is true.
* Log the configuration settings. Shown when exception thrown or when verbose
* is true.
*/
protected void logConfiguration() throws MojoExecutionException {
super.logConfiguration();
Expand Down Expand Up @@ -902,8 +898,9 @@ protected EntityResolver createEntityResolver(CatalogResolver catalogResolver) {
/**
* Creates an instance of catalog resolver.
*
* @return
* @return Instance of the catalog resolver.
* @throws MojoExecutionException
* If catalog resolver cannot be instantiated.
*/
protected CatalogResolver createCatalogResolver() throws MojoExecutionException {
final CatalogManager catalogManager = new CatalogManager();
Expand Down Expand Up @@ -951,10 +948,10 @@ private CatalogResolver createCatalogResolverByClassName(final String catalogRes

/**
* @return true to indicate results are up-to-date, that is, when the latest
* from input files is earlier than the younger from the output
* files (meaning no re-execution required).
* from input files is earlier than the younger from the output files
* (meaning no re-execution required).
*/
protected boolean isUpToDate() throws MojoExecutionException {
protected boolean isUpToDate() {
final List<URI> dependsURIs = getDependsURIs();
final List<URI> producesURIs = getProducesURIs();

Expand Down Expand Up @@ -1098,12 +1095,11 @@ private String createXJCProxyArgument(String host, int port, String username, St
}

/**
* Returns array of command line arguments for XJC. These arguments are
* based on the configured arguments (see {@link #getArgs()}) but also
* include episode arguments.
* Returns array of command line arguments for XJC. These arguments are based on
* the configured arguments (see {@link #getArgs()}) but also include episode
* arguments.
*
* @return String array of XJC command line options.
* @throws MojoExecutionException
*/

protected List<String> getArguments() {
Expand Down Expand Up @@ -1176,7 +1172,8 @@ public OptionsConfiguration createOptionsConfiguration() throws MojoExecutionExc
final OptionsConfiguration optionsConfiguration = new OptionsConfiguration(getEncoding(), getSchemaLanguage(),
getGrammars(), getBindFiles(), getEntityResolver(), getGeneratePackage(), getGenerateDirectory(),
getReadOnly(), getPackageLevelAnnotations(), getNoFileHeader(), getEnableIntrospection(),
getDisableXmlSecurity(), getAccessExternalSchema(), getAccessExternalDTD(), getContentForWildcard(),
getDisableXmlSecurity(), getAccessExternalSchema(), getAccessExternalDTD(), isEnableExternalEntityProcessing(),
getContentForWildcard(),
getExtension(), getStrict(), getVerbose(), getDebug(), getArguments(), getXjcPluginURLs(),
getSpecVersion());
return optionsConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public URL eval(File file) {
* Scans given directory for files satisfying given inclusion/exclusion
* patterns.
*
* @param buildContext
* Build context provided by the environment, used to scan for files.
* @param directory
* Directory to scan.
* @param includes
Expand All @@ -66,11 +68,13 @@ public URL eval(File file) {
* default exclusion flag.
* @return Files from the given directory which satisfy given patterns. The
* files are {@link File#getCanonicalFile() canonical}.
* @throws IOException
* If an I/O error occurs, which is possible because the
* construction of the canonical pathname may require filesystem
* queries.
*/
public static List<File> scanDirectoryForFiles(BuildContext buildContext,
final File directory, final String[] includes,
final String[] excludes, boolean defaultExcludes)
throws IOException {
public static List<File> scanDirectoryForFiles(BuildContext buildContext, final File directory,
final String[] includes, final String[] excludes, boolean defaultExcludes) throws IOException {
if (!directory.exists()) {
return Collections.emptyList();
}
Expand Down
Loading

0 comments on commit 3c15b7e

Please sign in to comment.