Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:13:08+00:00 2026-06-16T00:13:08+00:00

I need to generate some Java sources that will then be compiled by Maven.

  • 0

I need to generate some Java sources that will then be compiled by Maven. The problem is the legacy code that generates those sources is written in Java. The solution (work-around) used was to have:

  • project A with the code that generates Java sources
  • project B that depends on project A and calls antrun in Maven to execute the classes in project A

What happens when you build project B is that Maven will:

  • compile project A (code that generates sources) and do whatever else the pom.xml of project A tells it to do.
  • antrun those classes (as requested by the pom.xml of project B) – thus sources will get generated and added to project B
  • compile project B sources

This because Antrun requires the classes in project A to already be compiled when it’s executed.
This is however an ugly solution, and project A and B should actually be just one project.
I know I should use:

<phase>generate-sources</phase>

and I saw an example with Groovy (http://blog.retep.org/2009/11/07/using-groovy-to-generate-java-sources-in-maven/), but I would like to know if there’s any simpler way to do this while having everything in one project and not having to change the code-generation from Java to groovy or something else.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:13:09+00:00Added an answer on June 16, 2026 at 12:13 am

    I use Groovy for situations like that, but if you don’t want to, then having two separate projects is the correct thing to do.

    And I would not compile one project from the other, I would just leave them as separate projects. Usually the code generator project won’t change as often as the “real” project, so there’s no need to build it all the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem I have some pages that need dynamic data from website to generate output
I need to generate some token that can only take on a range of
Basically need to generate custom(some different then yes no) messeges(alert) in JS , how
I'm using StringTemplate V4 to generate some HTML code in my project. I need
I have some Java code that validates XML against an XSD. I am using
Can someone point me to some java code that can upload a file via
I'm trying to use the Java CodeModel library to generate some code. In my
I am using Java to generate the MD5 hash for some files. I need
I need to generate some 5x6 matrices in MATLAB. They need to consist of
Hi I need to generate some files on server side and return them to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.