@Test public void collectsBindingUrisFromArtifact() throws Exception { List<URI> bindings = new ArrayList<>(); final RawXJC2Mojo<Void> mojo = new RawXJC2Mojo<Void>() { @Override protected OptionsFactory<Void> getOptionsFactory() { throw new UnsupportedOperationException(); } @Override public void doExecute(Void options) throws MojoExecutionException { throw new UnsupportedOperationException(); } }; mojo.collectBindingUrisFromArtifact(testJarFile, bindings); assertEquals(2, bindings.size()); assertEquals(URI.create("jar:" + testJarFile.toURI() + "!/dir/nested.xjb"), bindings.get(0)); assertEquals(URI.create("jar:" + testJarFile.toURI() + "!/root.xjb"), bindings.get(1)); assertEquals("nested binding", readContent(bindings.get(0))); assertEquals("root binding", readContent(bindings.get(1))); }
void collectBindingUrisFromArtifact(File file, List<URI> bindingUris) throws MojoExecutionException { try (JarFile jarFile = new JarFile(file)) { final Enumeration<JarEntry> jarFileEntries = jarFile.entries(); while (jarFileEntries.hasMoreElements()) { JarEntry entry = jarFileEntries.nextElement(); if (entry.getName().endsWith(".xjb")) { try { bindingUris.add(new URI("jar:" + file.toURI() + "!/" + entry.getName())); } catch (URISyntaxException urisex) { throw new MojoExecutionException(MessageFormat.format( "Could not create the URI of the binding file from [{0}]", entry.getName()), urisex); } } } } catch (IOException ioex) { throw new MojoExecutionException( "Unable to read the artifact JAR file [" + file.getAbsolutePath() + "].", ioex); } }
RawXJC2Mojo extends AbstractXJC2Mojo<O> { void collectBindingUrisFromArtifact(File file, List<URI> bindingUris) throws MojoExecutionException { try (JarFile jarFile = new JarFile(file)) { final Enumeration<JarEntry> jarFileEntries = jarFile.entries(); while (jarFileEntries.hasMoreElements()) { JarEntry entry = jarFileEntries.nextElement(); if (entry.getName().endsWith(".xjb")) { try { bindingUris.add(new URI("jar:" + file.toURI() + "!/" + entry.getName())); } catch (URISyntaxException urisex) { throw new MojoExecutionException(MessageFormat.format( "Could not create the URI of the binding file from [{0}]", entry.getName()), urisex); } } } } catch (IOException ioex) { throw new MojoExecutionException( "Unable to read the artifact JAR file [" + file.getAbsolutePath() + "].", ioex); } } }
RawXJC2Mojo extends AbstractXJC2Mojo<O> { void collectBindingUrisFromArtifact(File file, List<URI> bindingUris) throws MojoExecutionException { try (JarFile jarFile = new JarFile(file)) { final Enumeration<JarEntry> jarFileEntries = jarFile.entries(); while (jarFileEntries.hasMoreElements()) { JarEntry entry = jarFileEntries.nextElement(); if (entry.getName().endsWith(".xjb")) { try { bindingUris.add(new URI("jar:" + file.toURI() + "!/" + entry.getName())); } catch (URISyntaxException urisex) { throw new MojoExecutionException(MessageFormat.format( "Could not create the URI of the binding file from [{0}]", entry.getName()), urisex); } } } } catch (IOException ioex) { throw new MojoExecutionException( "Unable to read the artifact JAR file [" + file.getAbsolutePath() + "].", ioex); } }  }
RawXJC2Mojo extends AbstractXJC2Mojo<O> { void collectBindingUrisFromArtifact(File file, List<URI> bindingUris) throws MojoExecutionException { try (JarFile jarFile = new JarFile(file)) { final Enumeration<JarEntry> jarFileEntries = jarFile.entries(); while (jarFileEntries.hasMoreElements()) { JarEntry entry = jarFileEntries.nextElement(); if (entry.getName().endsWith(".xjb")) { try { bindingUris.add(new URI("jar:" + file.toURI() + "!/" + entry.getName())); } catch (URISyntaxException urisex) { throw new MojoExecutionException(MessageFormat.format( "Could not create the URI of the binding file from [{0}]", entry.getName()), urisex); } } } } catch (IOException ioex) { throw new MojoExecutionException( "Unable to read the artifact JAR file [" + file.getAbsolutePath() + "].", ioex); } }  Collection<Artifact> getXjcPluginArtifacts(); Collection<File> getXjcPluginFiles(); List<URL> getXjcPluginURLs(); Collection<Artifact> getEpisodeArtifacts(); Collection<File> getEpisodeFiles(); List<File> getSchemaFiles(); List<File> getBindingFiles(); List<URI> getDependsURIs(); List<URI> getProducesURIs(); void execute(); abstract void doExecute(O options); OptionsConfiguration createOptionsConfiguration(); }
RawXJC2Mojo extends AbstractXJC2Mojo<O> { void collectBindingUrisFromArtifact(File file, List<URI> bindingUris) throws MojoExecutionException { try (JarFile jarFile = new JarFile(file)) { final Enumeration<JarEntry> jarFileEntries = jarFile.entries(); while (jarFileEntries.hasMoreElements()) { JarEntry entry = jarFileEntries.nextElement(); if (entry.getName().endsWith(".xjb")) { try { bindingUris.add(new URI("jar:" + file.toURI() + "!/" + entry.getName())); } catch (URISyntaxException urisex) { throw new MojoExecutionException(MessageFormat.format( "Could not create the URI of the binding file from [{0}]", entry.getName()), urisex); } } } } catch (IOException ioex) { throw new MojoExecutionException( "Unable to read the artifact JAR file [" + file.getAbsolutePath() + "].", ioex); } }  Collection<Artifact> getXjcPluginArtifacts(); Collection<File> getXjcPluginFiles(); List<URL> getXjcPluginURLs(); Collection<Artifact> getEpisodeArtifacts(); Collection<File> getEpisodeFiles(); List<File> getSchemaFiles(); List<File> getBindingFiles(); List<URI> getDependsURIs(); List<URI> getProducesURIs(); void execute(); abstract void doExecute(O options); OptionsConfiguration createOptionsConfiguration(); static final String ADD_IF_EXISTS_TO_EPISODE_SCHEMA_BINDINGS_TRANSFORMATION_RESOURCE_NAME; }