You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kevin Krumwiede <kj...@gmail.com> on 2013/03/18 06:56:26 UTC

maven-source-plugin questions

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?

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.

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?

Thanks,
K

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


Re: maven-source-plugin questions

Posted by Kevin Krumwiede <kj...@gmail.com>.
Yeah, I don't know.  It makes more sense now.

~K

On 3/18/13, Thomas Broyer <t....@gmail.com> wrote:
> On Mon, Mar 18, 2013 at 6:56 AM, Kevin Krumwiede <kj...@gmail.com> wrote:
>>
>> If the -sources jar is only intended as a reference, then I want to
>> exclude the generated sources and resources.
>
> Why would you do that?
> In addition to reading the code right from the IDE rather than
> switching to GitHub or wherever the project is hosted (when the VCS is
> publicly browsable, which is not always the case either), sources
> artifacts are really helpful when debugging, as it allows you to step
> into third-party code, set breakpoints, etc. Excluding the generated
> sources from the sources artifact would prevent doing this.
>
> --
> Thomas Broyer
> /tɔ.ma.bʁwa.je/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: maven-source-plugin questions

Posted by Thomas Broyer <t....@gmail.com>.
On Mon, Mar 18, 2013 at 6:56 AM, Kevin Krumwiede <kj...@gmail.com> wrote:
>
> If the -sources jar is only intended as a reference, then I want to
> exclude the generated sources and resources.

Why would you do that?
In addition to reading the code right from the IDE rather than
switching to GitHub or wherever the project is hosted (when the VCS is
publicly browsable, which is not always the case either), sources
artifacts are really helpful when debugging, as it allows you to step
into third-party code, set breakpoints, etc. Excluding the generated
sources from the sources artifact would prevent doing this.

--
Thomas Broyer
/tɔ.ma.bʁwa.je/

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


Re: maven-source-plugin questions

Posted by Kevin Krumwiede <kj...@gmail.com>.
> They are intended primarily as a reference thing.

That's the answer I was hoping for.  Thanks!

On 3/18/13, Tim Kettler <ti...@udo.edu> wrote:
> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: maven-source-plugin questions

Posted by Tim Kettler <ti...@udo.edu>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org