Just to give further details, here's what I've worked out as a (mostly)
general solution to this issue:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <phase>compile</phase>
            <configuration>
                <tasks>
                    <property name="rsrc.dir"
value="${project.resources[0].directory}"/>
                    <property name="excludes"
value="${project.resources[0].excludes}"/>
                    <property name="rsrc.list.out"
value="${project.build.directory}/classes/${project.groupId}:${project.artifactId}:resourcelist.txt"/>
                    
                    <fileset id="resources.list" dir="${rsrc.dir}"
excludes="${excludes}"/>
                    <pathconvert pathsep="${line.separator}"
property="resources.str" refid="resources.list">
                        <filtermapper>
                            <replacestring from="${rsrc.dir}" to=""/>
                        </filtermapper>
                    </pathconvert>
                    <echo file="${rsrc.list.out}" append="false"
message="${resources.str}"/>
                    <echo>Including resources found in ${rsrc.dir} in list
written to ${rsrc.list.out}</echo>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The failings here being (a) it won't include resources in supplemental
resource directories in the outputted list (b) it writes files to
target/classes instead of a proper generated-sources directory
(<http://jira.codehaus.org/browse/MANTRUN-54> would make that possible, I
believe), and (c) it's ant ;-)

Better options welcome.

- Chas


cemerick wrote:
> 
> I have a project that has a number of resources under src/main/resources. 
> The associated codebase needs to know what resources are available in
> order to load them at runtime (new resources are added all the time, so
> the list cannot be static).  I've got an ant target (from an older
> project) that scans the resources dir, and emits a list of the files under
> that directory as a new file.  The code can then always load that directly
> listing at runtime, and do what it needs to.
> 
> This works fine, but I'm wondering if there's a native maven solution to
> the problem.  I see noticed a ${project.resources} property mentioned
> elsewhere; I figured I'd drop that into the jar's manifest, and load it
> back at runtime from there, but project.resources appears to be an
> ArrayList, so can't be added as a manifest entry's value (or, at least,
> not in a way obvious to me).
> 
> Thoughts?
> 
> Thanks,
> 
> - Chas
> 

-- 
View this message in context: 
http://old.nabble.com/Generate-%2B-include-list-of-resources-included-in-jar-tp26718010p26729085.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to