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

  • SEARCH
  • Home
  • 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 8745849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:06:05+00:00 2026-06-13T12:06:05+00:00

I have pom.xml with the structure like: <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5</version> <configuration> <includes>

  • 0

I have pom.xml with the structure like:

<plugins>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <includes>
                 ... some directories with .java files to compile.

…

<plugin>  --- some my plugin that generates one more dir with .java files.

At this point I want to compile the newly generated files, so I repeat here step 1 with different content of “includes” element. Second compilation does not happen at all. Please advice.

  • 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-13T12:06:06+00:00Added an answer on June 13, 2026 at 12:06 pm

    Your plugin should run in generate-sources phase. Then you have to make sure that the generated source is available during the normal compile phase.

    Your plugin should be configured something like this:

    <build>
        <plugins>
            <plugin>
                <groupId>your.group</groupId>
                <artifactId>your-generator-plugin</artifactId>
                <version>your-generator-version</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>your-generator-goal</goal>
                        </goals>
                        <configuration>
                            <!-- Here goes all the plugin configuration -->
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    You can directly from your plugin (mojo) add the compilation source path to use.

    Here is an example of what you must add to your mojo:

    /**
     * The current project representation.
     * @parameter expression="${project}"
     * @required
     * @readonly
     */
    private MavenProject project;
    
    /**
     * Directory wherein generated source will be put; main, test, site, ... will be added implictly.
     * @parameter expression="${outputDir}" default-value="${project.build.directory}/src-generated"
     * @required
     */
    private File outputDir;
    

    And something like this must be added to your execute() method:

    if (!settings.isInteractiveMode()) {
        LOG.info("Adding " + outputDir.getAbsolutePath() + " to compile source root");
    }
    project.addCompileSourceRoot(outputDir.getAbsolutePath());
    

    This will output the generated java source files into target/src-generated/ but that can either be changed to some other default value in your mojo OR by adding this to the configuration part of the plugin:

    <outputDir>path/to/my/generated/source/</outputDir>
    

    The generated java source files will automatically be included in the compile phase.

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

Sidebar

Related Questions

I have a maven dependency in my pom.xml as such: <dependency> <groupId>com.foo</groupId> <artifactId>Bar</artifactId> <version>1.2.3</version>
I have following as dependencies in pom.xml file, <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> </dependency> <dependency>
I have a pom.xml, which has following stuff declared Plugins - maven-surefire-plugin, groovy-maven-plugin and
I have a typical pom.xml, and want to print the groupId, artifactId and version,
We are using Maven 2.2.1 version . I have an existing POM.xml file ,
I have a maven pom.xml file with multiple instances of a same goal defined
I have a Grails project with pom.xml that is treated as Maven project by
I have Maven multi-module project with such structure: parent-pom-project -- module1 -- module2 At
Currently, I have the following structure for my project Foo : foo-parent +- pom.xml
I'm at the beginning to move to Maven so I have no pom.xml at

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.