Am 18.03.2013 06:56, schrieb Kevin Krumwiede:
Are the jars produced by maven-source-plugin intended primarily as a
reference for IDEs and other automated tools, as opposed to being
something you would actually build from?

They are intended primarily as a reference thing.

I ask because I have a project in which a non-Java source is used to
generate Java sources and non-Java resources.  This happens during the
generate-sources phase.  So when maven-sources-plugin runs, the
sources and resources have already been generated and they get
included in the -sources jar.

If the -sources jar is only intended as a reference, then I want to
exclude the generated sources and resources.  I found that I can
exclude the generated sources by binding maven-sources-plugin to the
validate phase, using the jar-no-fork goal, and setting
excludeResources to true.  Binding to the validate phase seems like a
hack, and I don't understand why the generated resources still end up
in the source jar if I don't use excludeResources.

There is a <excludes> config option [1] that should do what you want:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>2.2.1</version>
    <executions>
      <execution>
        <id>attach-sources</id>
        <goals>
          <goal>jar</goal>
        </goals>
        <configuration>
          <excludes>
            <exclude>**/exclude/*.java</exclude>
            <exclude>second/exclude/*.png</exclude>
            ...
          </excludes>
        </configuration>
      </execution>
    </executions>
  </plugin>

On the other hand, if the -sources jar is meant to be something you
would build from, then I would want to exclude the generated sources
and resources but include the non-Java source from which they are
generated.  But the only way I know to do that is to add it as a
resource, which causes it to be included in the binary jar as well.

So... which is it, and how do I do it right?

You would use the assembly plugin to generate a full source distribution to build your project from.

Thanks,
K

-Tim

[1] http://maven.apache.org/plugins/maven-source-plugin/jar-no-fork-mojo.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to