Skip to content
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

Lots of little updates and a few features. #47

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

wdschei
Copy link

@wdschei wdschei commented Feb 2, 2016

I would have normally split this into multiple PR's, but they were to interleaved and I wanted to get this back out.

  • Changed the required relativity to the project.dir to instead use the standard Gradle naming.
  • Added the ability to specify the specific XSD's that are actually compiled.
  • Set a default bindings value to all: **/*.xjb
  • Added support for setting the new accessExternalSchema system property in JSE 8.
  • Added support for automatically creating the output directory as is standard in Gradle.
  • Added support for setting the classpath argument of the XJC Ant task so that XJC plugins can be used.
  • Added support for Gradle's new parallel project execution.

There are two unit tests that are failing using Gradle v1.12 and I can't get the integration tests to run at all.

I have also started trying to compile this under Gradle v2.10 and that is going fairly well. We forked it over here, https://github.com/rackerlabs/gradle-jaxb-plugin, and just brought in the source from the gradle-xsd-wsdl-slurping library. Same thing over there with not being able to run the integration tests~~, but there is only one test failing over there out of all the combined unit tests~~. It is also a different test than what is failing under Gradle v1.12. So I don't know.

Thanks for the great start on this, updating it was definitely better than starting from scratch.

EDIT: The last failing unit test was fixed with wdschei/gradle-jaxb-plugin@227e2d5.
EDIT: There is also a simple parallel build test that uses the the Rackspace published artifacts here: https://github.com/wdschei/gradle-jaxb-plugin-test

wdschei added 14 commits January 29, 2016 14:29
…only if not absolute through using the recomended project.projectDir and project.rootDir references in the variable definitions.
…e compiled within a directory, with the default being all '**/*.xsd'.
…em property that causes the plugin to not work as expected under JSE8.
…o calling XJC in order to prevent a FileNotFoundException from being thrown.
…ypos, and other misc. that hadn't been previously commited.
…0 since it was being confused with the method of the same name.
@ktsunoda
Copy link

I like these changes :) Thanks!

@asarkar
Copy link

asarkar commented May 16, 2016

Hi, wondering what's the plan to merge this pull request and release a new version of the plugin? @wdschei do you've a sample build.gradle showing your changes?

@wdschei
Copy link
Author

wdschei commented May 16, 2016

@abhijitsarkar,

I don't know if he is going to officially release a new version of this, but if you take a look at this you can use the forked version we published.

@asarkar
Copy link

asarkar commented May 16, 2016

Thanks @wdschei. Did you publish to jcenter or maven central? And do you any examples for me to get started? I've an existing Maven config that uses a plugin to put annotation on generated classes.

<execution>
   <phase>generate-sources</phase>
   <id>common-codegen</id>
   <goals>
      <goal>run</goal>
   </goals>
   <configuration>
      <target>
         <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="maven.plugin.classpath" />
         <xjc extension="true" destdir="${project.build.sourceDirectory}" removeOldOutput="no" binding="${schema.dir}/common-binding.xml">
            <arg line="-Xannotate" />
            <arg line="-episode ${basedir}/src/main/resources/META-INF/sun-jaxb.episode" />
            <schema dir="${schema.dir}" includes="common.xsd" />
            <produces dir="${project.build.sourceDirectory}" includes="**/*" />
            <classpath>
               <fileset dir="${settings.localRepository}">
                  <include name="org/jvnet/annox/annox/${annox.version}/*.jar" />
                  <include name="org/jvnet/jaxb2_commons/jaxb2-basics-annotate/${jaxb2-basics-annotate.version}/*.jar" />
                  <include name="org/jvnet/jaxb2_commons/jaxb2-basics-ant/${jaxb2-basics-ant.version}/*.jar" />
                  <include name="org/jvnet/jaxb2_commons/jaxb2-basics-tools/${jaxb2-basics-tools.version}/*.jar" />
               </fileset>
            </classpath>
         </xjc>
      </target>
   </configuration>
</execution>

@wdschei
Copy link
Author

wdschei commented May 16, 2016

@abhijitsarkar We haven't publish to jcenter or maven central yet, in hopes that this pull request would be accepted and then it would be published as merely a new release. Since it wasn't in a timely manner, we did publish to the public Rackspace repository. My little hello-world'ish project is located at:

The project I work on and what prompted this pull request can be found here:

Both are good examples, it just depends on how well versed in Gradle as to which one would be better for you.

That said, it is on our backlog to publish our changes to a more standard repository at some point if this pull request is not accepted by then.

@asarkar
Copy link

asarkar commented May 16, 2016

@wdschei thanks again. I'll look. I think I know gradle enough to understand build scripts, however, as you can see in the code snippet above, I'm using a JAXB plugin, so I'll have to find a way to feed that to the gradle plugin.

@wdschei
Copy link
Author

wdschei commented May 16, 2016

EDIT: The Repose master branch has been migrated to Gradle and the links have been updated.

@abhijitsarkar I forgot to mention that the Repose master branch is still on Maven for a couple more weeks, but the branch below has been migrated to Gradle:

Specifically, the build.gradle below uses a JAXB plugin to automatically provide default values and a Fluent API:

Notice the xjc dependencies and the args

@asarkar
Copy link

asarkar commented May 16, 2016

I'm looking here for indication of what you said "support for setting the classpath argument of the XJC Ant task" and don't see any. I'll now start digging through source code, but if you may provide a helpful pointer, I'll appreciate that.

@wdschei
Copy link
Author

wdschei commented May 16, 2016

It is not in that documentation yet, we just added the same capabilities to the XJC module as were already present for the JAXB module.

@shljad
Copy link

shljad commented Jun 6, 2016

Putting in another plug to get this PR accepted. I'm new to Gradle from the maven world, and would like to be able to use this plugin. Tracking down the error in the JaxbPlugin (the improperly calculated xjc.conventionMapping.generatedFilesDirectory) was highly instructional :-)

Thx.

@esetnik
Copy link

esetnik commented Jul 7, 2016

+1 I need support for accessExternalSchema

@wdschei
Copy link
Author

wdschei commented Jul 8, 2016

EDIT: Since this PR was not accepted/merged, the Repose team did publish this to the Gradle Plugins repository:

@esetnik As mentioned previously, it is on my team's backlog to get this published to a more common repository. In the mean time though, you can always use the version we have published to our public repository:

  • https://maven.research.rackspacecloud.com/content/repositories/public/
  • org.openrepose:gradle-jaxb-plugin:2.0.2

Example projects are linked above too.

@iocampomx
Copy link

I'm still not able to run xjc task with an XSD that contains external references with: <xs:import namespace=. Do you have a workaround? Thanks

@wdschei
Copy link
Author

wdschei commented Feb 5, 2017

@Nafiux Are you using the plugin from this repository or the one from the fork referenced in this PR?
Since this PR was not accepted/merged, the Repose team did publish this to the Gradle Plugins repository:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants