You have a chicken-and-egg problem: resources:copy is run before
compile:compile, and jar:jar takes what was copied/written to
target/classes. So if you generate resources after the process-resources
phase, then you either have to write them directly to target/classes or run
the maven-resources-plugin afterwards to copy them.

Le dim. 22 janv. 2017 05:13, Gary Aitken <[email protected]> a écrit :

> On 01/20/17 00:38, Anders Hammar wrote:
> > The best option to handle this is to use the add-resource goal of the
> > build-helper-maven-plugin. Just bind that to the build lifecycle as
> > outlined in the usage example [1]
> >
> > [1] http://www.mojohaus.org/build-helper-maven-plugin/usage.html
>
> Can you explain why this is needed, when there is already a <resource>
> specification in the normal <build> part of the pom?
>
> In any case I tried that, but the plugin appears to have a bug:
>
>       <plugin>
>         <groupId>org.codehaus.mojo</groupId>
>         <artifactId>build-helper-maven-plugin</artifactId>
>         <version>1.12</version>
>         <executions>
>           <execution>
>             <id>package-generated-xml</id>
>             <phase>prepare-package</phase>  <!--
> <phase>generate-resources</phase> -->
>             <goals>
>               <goal>add-resource</goal>
>             </goals>
>             <configuration>
>               <resources>
>                 <resource>${generated-xml.dir}</resource>
>               </resources>
>             </configuration>
>           </execution>
>         </executions>
>       </plugin>
>
> [ERROR] Failed to execute goal
> org.codehaus.mojo:build-helper-maven-plugin:1.12:add-resource
> (package-generated-xml) on project patientrecords-xml: Unable to parse
> configuration of mojo
> org.codehaus.mojo:build-helper-maven-plugin:1.12:add-resource for parameter
> resource: Cannot find default setter in class
> org.apache.maven.model.Resource -> [Help 1]
>
> Note that the above pom fragment specifies the prepare-package phase, for
> the reason cited below:
>
> On 01/20/17 08:52, Karl Heinz Marbaise wrote:
>
> > Why are you running in the process-class phase instead of
> generate-resources phase?
>
> The resources are generated via execution of a program compiled during the
> compile phase.  I presume the classes would not be built yet in the
> generate-resources phase.  It probably makes more sense to be in the
> prepare-package phase, however.  If there's something I'm missing, I'd
> appreciate a pointer or explanation as to how it works -- how something
> needed in generate-resources gets compiled before running the compile
> phase.
>
> > On Fri, Jan 20, 2017 at 5:49 AM, Gary Aitken <[email protected]>
> wrote:
> >
> >> I'm having trouble getting resources generated post-compile into the
> final
> >> jar package (packaging type jar).
> >>
> >> During the process-classes phase, I run a task which reads some xml
> files
> >> and produces other xml files.  I can't figure out how to get the output
> >> xml files into the jar.
> >>
> >> Issues:
> >>
> >> 1. The output is written into target/xmldata,
> >>    but the xmldata subtree is not written into the jar.
> >>    I also tried generating into target/resources/xmldata
> >>
> >> 2. I tried the following in the <build> section of pom.xml:
> >>     <resources>
> >>       <resource>
> >>         <directory>${generated-xml.dir}</directory>
> >>         <excludes>
> >>           <exclude>${generated-src-xml.dir}</exclude>
> >>         </excludes>
> >>       </resource>
> >>     </resources>
> >>
> >> 3. I also tried adding an
> >>         <includes>
> >>           <include>**_consolidated.xml</include>
> >>         </includes>
> >>    to the above <resource> section; no luck.
> >>
> >> Hints?
> >> Thanks,
> >> Gary
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to