using includes in maven-source-plugin induces sources are not found anymore

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

using includes in maven-source-plugin induces sources are not found anymore

Luc Maisonobe
Hi all,

I am using maven-souce-plugin in a profile, in order to generate the
sources jar. As this sources jar is in a sense a source distribution
(even if it is intended only for IDE completion use), it should
include the LICENSE.txt and NOTICE.txt files that are present at
the top level of the project.

So my pom looks as follows:

<profile>
  <id>release</id>
    <build>
    <plugins>
       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.0.1</version>
        <configuration>
          <includes>
            <include>LICENSE.txt</include>
            <include>NOTICE.txt</include>
          </includes>
        </configuration>
        <executions>
          <execution>
            <id>create-source-jar</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

When I run "mvn -Prelease package", I get the following error:

[INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit ---
[INFO] No sources in project. Archive not created.


If I remove the <configuration>...</configuration> part, the source jar
is created nominally, as the sources are in the standard src/main/java
directory.

It seems to me that adding the <includes>...</includes> somehow hides
or clears the regular list of source files. I would have expected that
includes adds to this list.

I have tried to add the path to the sources in a third <include>,
alongside the LICENSE and NOTICE ones, using either
{$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
or at least I did not find the correct include statement.

How can I put these two extra files into the source jar and still have
the sources too?

best regards,
Luc

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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Hervé BOUTEMY
Hi,

AFAIK, reading the plugin source code, there is no feature to add files that
are not in compile source root: this will require a new feature.

Did you try adding a secondary source root, using build-helper:add-source?

Regards,

Hervé

Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :

> Hi all,
>
> I am using maven-souce-plugin in a profile, in order to generate the
> sources jar. As this sources jar is in a sense a source distribution
> (even if it is intended only for IDE completion use), it should
> include the LICENSE.txt and NOTICE.txt files that are present at
> the top level of the project.
>
> So my pom looks as follows:
>
> <profile>
>   <id>release</id>
>     <build>
>     <plugins>
>        <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-source-plugin</artifactId>
>         <version>3.0.1</version>
>         <configuration>
>           <includes>
>             <include>LICENSE.txt</include>
>             <include>NOTICE.txt</include>
>           </includes>
>         </configuration>
>         <executions>
>           <execution>
>             <id>create-source-jar</id>
>             <goals>
>               <goal>jar</goal>
>             </goals>
>             <phase>package</phase>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
> </profile>
>
> When I run "mvn -Prelease package", I get the following error:
>
> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit ---
> [INFO] No sources in project. Archive not created.
>
>
> If I remove the <configuration>...</configuration> part, the source jar
> is created nominally, as the sources are in the standard src/main/java
> directory.
>
> It seems to me that adding the <includes>...</includes> somehow hides
> or clears the regular list of source files. I would have expected that
> includes adds to this list.
>
> I have tried to add the path to the sources in a third <include>,
> alongside the LICENSE and NOTICE ones, using either
> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
> or at least I did not find the correct include statement.
>
> How can I put these two extra files into the source jar and still have
> the sources too?
>
> best regards,
> Luc
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Luc Maisonobe

Hervé BOUTEMY <[hidden email]> a écrit :

> Hi,

Hi Hervé,

>
> AFAIK, reading the plugin source code, there is no feature to add files that
> are not in compile source root: this will require a new feature.
>
> Did you try adding a secondary source root, using build-helper:add-source?

I just tried it, thanks for the suggestion. It doesn't work.
The LICENSE.txt and NOTICE.txt files live in the root directory,
alongside the pom. So this implies adding the full project in the
source tree. It creates huge problems has there are java files
underneath (in src/main/java, and src/test/java).

I also tried maven-resource-plugin, but it also adds full directories,
not single files.


I did understood why my source disappeared. The default pattern **/*.java
is added only if combined includes is empty. I also understood the
pattern is eveluated with respect to the source tree, not the project
root.

So adding something like:

   <includes>
      <include>**/*.java</include>
      <include>something-else</include>
   </includes>

should probably work... as long as something else is in the sources tree.

I tried to use <include>../../../LICENSE.txt</include> to go upward, but
it doesn't work either.

best regards,
Luc

>
> Regards,
>
> Hervé
>
> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
>> Hi all,
>>
>> I am using maven-souce-plugin in a profile, in order to generate the
>> sources jar. As this sources jar is in a sense a source distribution
>> (even if it is intended only for IDE completion use), it should
>> include the LICENSE.txt and NOTICE.txt files that are present at
>> the top level of the project.
>>
>> So my pom looks as follows:
>>
>> <profile>
>>   <id>release</id>
>>     <build>
>>     <plugins>
>>        <plugin>
>>         <groupId>org.apache.maven.plugins</groupId>
>>         <artifactId>maven-source-plugin</artifactId>
>>         <version>3.0.1</version>
>>         <configuration>
>>           <includes>
>>             <include>LICENSE.txt</include>
>>             <include>NOTICE.txt</include>
>>           </includes>
>>         </configuration>
>>         <executions>
>>           <execution>
>>             <id>create-source-jar</id>
>>             <goals>
>>               <goal>jar</goal>
>>             </goals>
>>             <phase>package</phase>
>>           </execution>
>>         </executions>
>>       </plugin>
>>     </plugins>
>>   </build>
>> </profile>
>>
>> When I run "mvn -Prelease package", I get the following error:
>>
>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit ---
>> [INFO] No sources in project. Archive not created.
>>
>>
>> If I remove the <configuration>...</configuration> part, the source jar
>> is created nominally, as the sources are in the standard src/main/java
>> directory.
>>
>> It seems to me that adding the <includes>...</includes> somehow hides
>> or clears the regular list of source files. I would have expected that
>> includes adds to this list.
>>
>> I have tried to add the path to the sources in a third <include>,
>> alongside the LICENSE and NOTICE ones, using either
>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
>> or at least I did not find the correct include statement.
>>
>> How can I put these two extra files into the source jar and still have
>> the sources too?
>>
>> best regards,
>> Luc
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Luc Maisonobe
Hi,

MAISONOBE Luc <[hidden email]> a écrit :

> Hervé BOUTEMY <[hidden email]> a écrit :
>
>> Hi,
>
> Hi Hervé,
>
>>
>> AFAIK, reading the plugin source code, there is no feature to add files that
>> are not in compile source root: this will require a new feature.
>>
>> Did you try adding a secondary source root, using build-helper:add-source?
>
> I just tried it, thanks for the suggestion. It doesn't work.
> The LICENSE.txt and NOTICE.txt files live in the root directory,
> alongside the pom. So this implies adding the full project in the
> source tree. It creates huge problems has there are java files
> underneath (in src/main/java, and src/test/java).
>
> I also tried maven-resource-plugin, but it also adds full directories,
> not single files.
>
>
> I did understood why my source disappeared. The default pattern **/*.java
> is added only if combined includes is empty. I also understood the
> pattern is eveluated with respect to the source tree, not the project
> root.
>
> So adding something like:
>
>   <includes>
>      <include>**/*.java</include>
>      <include>something-else</include>
>   </includes>
>
> should probably work... as long as something else is in the sources tree.
>
> I tried to use <include>../../../LICENSE.txt</include> to go upward, but
> it doesn't work either.

I finally managed to do what I wanted. The solution involved:

   - using maven-antrun-plugin to:
        + create a directory  
${project.build.outputDirectory}/license-and-notice-placeholder
        + copy LICENSE.txt from top directory to the created directory
        + copy NOTICE.txt from top directory to the created directory
   - using build-helper-maven-plugin to add this directory to the  
sources directories
   - use maven-source-plugin with includes set to:
        + **/*.java
        + LICENSE.txt
        + NOTICE.txt

All three plugins are run only in a profile and they are bound to  
package phase.

This works, but it is really ugly.

best regards,
Luc

>
> best regards,
> Luc
>
>>
>> Regards,
>>
>> Hervé
>>
>> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
>>> Hi all,
>>>
>>> I am using maven-souce-plugin in a profile, in order to generate the
>>> sources jar. As this sources jar is in a sense a source distribution
>>> (even if it is intended only for IDE completion use), it should
>>> include the LICENSE.txt and NOTICE.txt files that are present at
>>> the top level of the project.
>>>
>>> So my pom looks as follows:
>>>
>>> <profile>
>>>  <id>release</id>
>>>    <build>
>>>    <plugins>
>>>       <plugin>
>>>        <groupId>org.apache.maven.plugins</groupId>
>>>        <artifactId>maven-source-plugin</artifactId>
>>>        <version>3.0.1</version>
>>>        <configuration>
>>>          <includes>
>>>            <include>LICENSE.txt</include>
>>>            <include>NOTICE.txt</include>
>>>          </includes>
>>>        </configuration>
>>>        <executions>
>>>          <execution>
>>>            <id>create-source-jar</id>
>>>            <goals>
>>>              <goal>jar</goal>
>>>            </goals>
>>>            <phase>package</phase>
>>>          </execution>
>>>        </executions>
>>>      </plugin>
>>>    </plugins>
>>>  </build>
>>> </profile>
>>>
>>> When I run "mvn -Prelease package", I get the following error:
>>>
>>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit ---
>>> [INFO] No sources in project. Archive not created.
>>>
>>>
>>> If I remove the <configuration>...</configuration> part, the source jar
>>> is created nominally, as the sources are in the standard src/main/java
>>> directory.
>>>
>>> It seems to me that adding the <includes>...</includes> somehow hides
>>> or clears the regular list of source files. I would have expected that
>>> includes adds to this list.
>>>
>>> I have tried to add the path to the sources in a third <include>,
>>> alongside the LICENSE and NOTICE ones, using either
>>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
>>> or at least I did not find the correct include statement.
>>>
>>> How can I put these two extra files into the source jar and still have
>>> the sources too?
>>>
>>> best regards,
>>> Luc
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Thomas Broyer-2
maven-assembly-plugin would likely be less ugly. Have you tried that?

Le jeu. 2 nov. 2017 22:26, MAISONOBE Luc <[hidden email]> a écrit :

> Hi,
>
> MAISONOBE Luc <[hidden email]> a écrit :
>
> > Hervé BOUTEMY <[hidden email]> a écrit :
> >
> >> Hi,
> >
> > Hi Hervé,
> >
> >>
> >> AFAIK, reading the plugin source code, there is no feature to add files
> that
> >> are not in compile source root: this will require a new feature.
> >>
> >> Did you try adding a secondary source root, using
> build-helper:add-source?
> >
> > I just tried it, thanks for the suggestion. It doesn't work.
> > The LICENSE.txt and NOTICE.txt files live in the root directory,
> > alongside the pom. So this implies adding the full project in the
> > source tree. It creates huge problems has there are java files
> > underneath (in src/main/java, and src/test/java).
> >
> > I also tried maven-resource-plugin, but it also adds full directories,
> > not single files.
> >
> >
> > I did understood why my source disappeared. The default pattern **/*.java
> > is added only if combined includes is empty. I also understood the
> > pattern is eveluated with respect to the source tree, not the project
> > root.
> >
> > So adding something like:
> >
> >   <includes>
> >      <include>**/*.java</include>
> >      <include>something-else</include>
> >   </includes>
> >
> > should probably work... as long as something else is in the sources tree.
> >
> > I tried to use <include>../../../LICENSE.txt</include> to go upward, but
> > it doesn't work either.
>
> I finally managed to do what I wanted. The solution involved:
>
>    - using maven-antrun-plugin to:
>         + create a directory
> ${project.build.outputDirectory}/license-and-notice-placeholder
>         + copy LICENSE.txt from top directory to the created directory
>         + copy NOTICE.txt from top directory to the created directory
>    - using build-helper-maven-plugin to add this directory to the
> sources directories
>    - use maven-source-plugin with includes set to:
>         + **/*.java
>         + LICENSE.txt
>         + NOTICE.txt
>
> All three plugins are run only in a profile and they are bound to
> package phase.
>
> This works, but it is really ugly.
>
> best regards,
> Luc
>
> >
> > best regards,
> > Luc
> >
> >>
> >> Regards,
> >>
> >> Hervé
> >>
> >> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
> >>> Hi all,
> >>>
> >>> I am using maven-souce-plugin in a profile, in order to generate the
> >>> sources jar. As this sources jar is in a sense a source distribution
> >>> (even if it is intended only for IDE completion use), it should
> >>> include the LICENSE.txt and NOTICE.txt files that are present at
> >>> the top level of the project.
> >>>
> >>> So my pom looks as follows:
> >>>
> >>> <profile>
> >>>  <id>release</id>
> >>>    <build>
> >>>    <plugins>
> >>>       <plugin>
> >>>        <groupId>org.apache.maven.plugins</groupId>
> >>>        <artifactId>maven-source-plugin</artifactId>
> >>>        <version>3.0.1</version>
> >>>        <configuration>
> >>>          <includes>
> >>>            <include>LICENSE.txt</include>
> >>>            <include>NOTICE.txt</include>
> >>>          </includes>
> >>>        </configuration>
> >>>        <executions>
> >>>          <execution>
> >>>            <id>create-source-jar</id>
> >>>            <goals>
> >>>              <goal>jar</goal>
> >>>            </goals>
> >>>            <phase>package</phase>
> >>>          </execution>
> >>>        </executions>
> >>>      </plugin>
> >>>    </plugins>
> >>>  </build>
> >>> </profile>
> >>>
> >>> When I run "mvn -Prelease package", I get the following error:
> >>>
> >>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit
> ---
> >>> [INFO] No sources in project. Archive not created.
> >>>
> >>>
> >>> If I remove the <configuration>...</configuration> part, the source jar
> >>> is created nominally, as the sources are in the standard src/main/java
> >>> directory.
> >>>
> >>> It seems to me that adding the <includes>...</includes> somehow hides
> >>> or clears the regular list of source files. I would have expected that
> >>> includes adds to this list.
> >>>
> >>> I have tried to add the path to the sources in a third <include>,
> >>> alongside the LICENSE and NOTICE ones, using either
> >>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
> >>> or at least I did not find the correct include statement.
> >>>
> >>> How can I put these two extra files into the source jar and still have
> >>> the sources too?
> >>>
> >>> best regards,
> >>> Luc
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Hervé BOUTEMY
In reply to this post by Luc Maisonobe
yes, really ugly :)

usual with Maven when you're trying to do by configuration something that would
best be served with a supported feature, that defines the associated convention

that's why I told at the beginning that perhaps it deserved a new feature in
maven-source-plugin

something like "additionnalFiles" list that would add some files at root of the
generated jar (like NOTICE and LICENSE)

I'm open to PRs :)

Regards,

Hervé

Le jeudi 2 novembre 2017, 22:25:49 CET MAISONOBE Luc a écrit :

> Hi,
>
> MAISONOBE Luc <[hidden email]> a écrit :
> > Hervé BOUTEMY <[hidden email]> a écrit :
> >> Hi,
> >
> > Hi Hervé,
> >
> >> AFAIK, reading the plugin source code, there is no feature to add files
> >> that are not in compile source root: this will require a new feature.
> >>
> >> Did you try adding a secondary source root, using
> >> build-helper:add-source?
> >
> > I just tried it, thanks for the suggestion. It doesn't work.
> > The LICENSE.txt and NOTICE.txt files live in the root directory,
> > alongside the pom. So this implies adding the full project in the
> > source tree. It creates huge problems has there are java files
> > underneath (in src/main/java, and src/test/java).
> >
> > I also tried maven-resource-plugin, but it also adds full directories,
> > not single files.
> >
> >
> > I did understood why my source disappeared. The default pattern **/*.java
> > is added only if combined includes is empty. I also understood the
> > pattern is eveluated with respect to the source tree, not the project
> > root.
> >
> > So adding something like:
> >   <includes>
> >  
> >      <include>**/*.java</include>
> >      <include>something-else</include>
> >  
> >   </includes>
> >
> > should probably work... as long as something else is in the sources tree.
> >
> > I tried to use <include>../../../LICENSE.txt</include> to go upward, but
> > it doesn't work either.
>
> I finally managed to do what I wanted. The solution involved:
>
>    - using maven-antrun-plugin to:
>         + create a directory
> ${project.build.outputDirectory}/license-and-notice-placeholder
>         + copy LICENSE.txt from top directory to the created directory
>         + copy NOTICE.txt from top directory to the created directory
>    - using build-helper-maven-plugin to add this directory to the
> sources directories
>    - use maven-source-plugin with includes set to:
>         + **/*.java
>         + LICENSE.txt
>         + NOTICE.txt
>
> All three plugins are run only in a profile and they are bound to
> package phase.
>
> This works, but it is really ugly.
>
> best regards,
> Luc
>
> > best regards,
> > Luc
> >
> >> Regards,
> >>
> >> Hervé
> >>
> >> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
> >>> Hi all,
> >>>
> >>> I am using maven-souce-plugin in a profile, in order to generate the
> >>> sources jar. As this sources jar is in a sense a source distribution
> >>> (even if it is intended only for IDE completion use), it should
> >>> include the LICENSE.txt and NOTICE.txt files that are present at
> >>> the top level of the project.
> >>>
> >>> So my pom looks as follows:
> >>>
> >>> <profile>
> >>>
> >>>  <id>release</id>
> >>>  
> >>>    <build>
> >>>    <plugins>
> >>>    
> >>>       <plugin>
> >>>      
> >>>        <groupId>org.apache.maven.plugins</groupId>
> >>>        <artifactId>maven-source-plugin</artifactId>
> >>>        <version>3.0.1</version>
> >>>        <configuration>
> >>>        
> >>>          <includes>
> >>>          
> >>>            <include>LICENSE.txt</include>
> >>>            <include>NOTICE.txt</include>
> >>>          
> >>>          </includes>
> >>>        
> >>>        </configuration>
> >>>        <executions>
> >>>        
> >>>          <execution>
> >>>          
> >>>            <id>create-source-jar</id>
> >>>            <goals>
> >>>            
> >>>              <goal>jar</goal>
> >>>            
> >>>            </goals>
> >>>            <phase>package</phase>
> >>>          
> >>>          </execution>
> >>>        
> >>>        </executions>
> >>>      
> >>>      </plugin>
> >>>    
> >>>    </plugins>
> >>>  
> >>>  </build>
> >>>
> >>> </profile>
> >>>
> >>> When I run "mvn -Prelease package", I get the following error:
> >>>
> >>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit
> >>> ---
> >>> [INFO] No sources in project. Archive not created.
> >>>
> >>>
> >>> If I remove the <configuration>...</configuration> part, the source jar
> >>> is created nominally, as the sources are in the standard src/main/java
> >>> directory.
> >>>
> >>> It seems to me that adding the <includes>...</includes> somehow hides
> >>> or clears the regular list of source files. I would have expected that
> >>> includes adds to this list.
> >>>
> >>> I have tried to add the path to the sources in a third <include>,
> >>> alongside the LICENSE and NOTICE ones, using either
> >>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
> >>> or at least I did not find the correct include statement.
> >>>
> >>> How can I put these two extra files into the source jar and still have
> >>> the sources too?
> >>>
> >>> best regards,
> >>> Luc
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Luc Maisonobe
In reply to this post by Thomas Broyer-2

Thomas Broyer <[hidden email]> a écrit :

> maven-assembly-plugin would likely be less ugly. Have you tried that?

Great idea!

I tried that and it worked. I still had to do some tricky customisation:

  - use build-helper plugin to declare the assembly as an artifact
    of type source-jar
  - set up the assembly descriptor as follows:

<assembly>
   <id>sources</id>
   <formats>
     <format>jar</format>
   </formats>
   <includeBaseDirectory>false</includeBaseDirectory>
   <fileSets>
     <fileSet>
       <includes>
        <include>LICENSE.txt</include>
        <include>NOTICE.txt</include>
       </includes>
     </fileSet>
     <fileSet>
       <directory>src/main/java</directory>
       <outputDirectory>.</outputDirectory>
       <includes>
         <include>**/*.java</include>
       </includes>
       <useDefaultExcludes>true</useDefaultExcludes>
     </fileSet>
   </fileSets>
</assembly>

Thanks for the tip!

Luc

>
> Le jeu. 2 nov. 2017 22:26, MAISONOBE Luc <[hidden email]> a écrit :
>
>> Hi,
>>
>> MAISONOBE Luc <[hidden email]> a écrit :
>>
>> > Hervé BOUTEMY <[hidden email]> a écrit :
>> >
>> >> Hi,
>> >
>> > Hi Hervé,
>> >
>> >>
>> >> AFAIK, reading the plugin source code, there is no feature to add files
>> that
>> >> are not in compile source root: this will require a new feature.
>> >>
>> >> Did you try adding a secondary source root, using
>> build-helper:add-source?
>> >
>> > I just tried it, thanks for the suggestion. It doesn't work.
>> > The LICENSE.txt and NOTICE.txt files live in the root directory,
>> > alongside the pom. So this implies adding the full project in the
>> > source tree. It creates huge problems has there are java files
>> > underneath (in src/main/java, and src/test/java).
>> >
>> > I also tried maven-resource-plugin, but it also adds full directories,
>> > not single files.
>> >
>> >
>> > I did understood why my source disappeared. The default pattern **/*.java
>> > is added only if combined includes is empty. I also understood the
>> > pattern is eveluated with respect to the source tree, not the project
>> > root.
>> >
>> > So adding something like:
>> >
>> >   <includes>
>> >      <include>**/*.java</include>
>> >      <include>something-else</include>
>> >   </includes>
>> >
>> > should probably work... as long as something else is in the sources tree.
>> >
>> > I tried to use <include>../../../LICENSE.txt</include> to go upward, but
>> > it doesn't work either.
>>
>> I finally managed to do what I wanted. The solution involved:
>>
>>    - using maven-antrun-plugin to:
>>         + create a directory
>> ${project.build.outputDirectory}/license-and-notice-placeholder
>>         + copy LICENSE.txt from top directory to the created directory
>>         + copy NOTICE.txt from top directory to the created directory
>>    - using build-helper-maven-plugin to add this directory to the
>> sources directories
>>    - use maven-source-plugin with includes set to:
>>         + **/*.java
>>         + LICENSE.txt
>>         + NOTICE.txt
>>
>> All three plugins are run only in a profile and they are bound to
>> package phase.
>>
>> This works, but it is really ugly.
>>
>> best regards,
>> Luc
>>
>> >
>> > best regards,
>> > Luc
>> >
>> >>
>> >> Regards,
>> >>
>> >> Hervé
>> >>
>> >> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
>> >>> Hi all,
>> >>>
>> >>> I am using maven-souce-plugin in a profile, in order to generate the
>> >>> sources jar. As this sources jar is in a sense a source distribution
>> >>> (even if it is intended only for IDE completion use), it should
>> >>> include the LICENSE.txt and NOTICE.txt files that are present at
>> >>> the top level of the project.
>> >>>
>> >>> So my pom looks as follows:
>> >>>
>> >>> <profile>
>> >>>  <id>release</id>
>> >>>    <build>
>> >>>    <plugins>
>> >>>       <plugin>
>> >>>        <groupId>org.apache.maven.plugins</groupId>
>> >>>        <artifactId>maven-source-plugin</artifactId>
>> >>>        <version>3.0.1</version>
>> >>>        <configuration>
>> >>>          <includes>
>> >>>            <include>LICENSE.txt</include>
>> >>>            <include>NOTICE.txt</include>
>> >>>          </includes>
>> >>>        </configuration>
>> >>>        <executions>
>> >>>          <execution>
>> >>>            <id>create-source-jar</id>
>> >>>            <goals>
>> >>>              <goal>jar</goal>
>> >>>            </goals>
>> >>>            <phase>package</phase>
>> >>>          </execution>
>> >>>        </executions>
>> >>>      </plugin>
>> >>>    </plugins>
>> >>>  </build>
>> >>> </profile>
>> >>>
>> >>> When I run "mvn -Prelease package", I get the following error:
>> >>>
>> >>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit
>> ---
>> >>> [INFO] No sources in project. Archive not created.
>> >>>
>> >>>
>> >>> If I remove the <configuration>...</configuration> part, the source jar
>> >>> is created nominally, as the sources are in the standard src/main/java
>> >>> directory.
>> >>>
>> >>> It seems to me that adding the <includes>...</includes> somehow hides
>> >>> or clears the regular list of source files. I would have expected that
>> >>> includes adds to this list.
>> >>>
>> >>> I have tried to add the path to the sources in a third <include>,
>> >>> alongside the LICENSE and NOTICE ones, using either
>> >>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
>> >>> or at least I did not find the correct include statement.
>> >>>
>> >>> How can I put these two extra files into the source jar and still have
>> >>> the sources too?
>> >>>
>> >>> best regards,
>> >>> Luc
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: [hidden email]
>> >>> For additional commands, e-mail: [hidden email]
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [hidden email]
>> >> For additional commands, e-mail: [hidden email]
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>



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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

Luc Maisonobe
In reply to this post by Hervé BOUTEMY

Hervé BOUTEMY <[hidden email]> a écrit :

> yes, really ugly :)
>
> usual with Maven when you're trying to do by configuration something  
> that would
> best be served with a supported feature, that defines the associated  
> convention
>
> that's why I told at the beginning that perhaps it deserved a new feature in
> maven-source-plugin
>
> something like "additionnalFiles" list that would add some files at  
> root of the
> generated jar (like NOTICE and LICENSE)
>
> I'm open to PRs :)

I don't have time for this right now, but I definitely will consider it.
I don't know the internals of maven, so it would probably be a good exercise
to learn them.

best regards,
Luc

>
> Regards,
>
> Hervé
>
> Le jeudi 2 novembre 2017, 22:25:49 CET MAISONOBE Luc a écrit :
>> Hi,
>>
>> MAISONOBE Luc <[hidden email]> a écrit :
>> > Hervé BOUTEMY <[hidden email]> a écrit :
>> >> Hi,
>> >
>> > Hi Hervé,
>> >
>> >> AFAIK, reading the plugin source code, there is no feature to add files
>> >> that are not in compile source root: this will require a new feature.
>> >>
>> >> Did you try adding a secondary source root, using
>> >> build-helper:add-source?
>> >
>> > I just tried it, thanks for the suggestion. It doesn't work.
>> > The LICENSE.txt and NOTICE.txt files live in the root directory,
>> > alongside the pom. So this implies adding the full project in the
>> > source tree. It creates huge problems has there are java files
>> > underneath (in src/main/java, and src/test/java).
>> >
>> > I also tried maven-resource-plugin, but it also adds full directories,
>> > not single files.
>> >
>> >
>> > I did understood why my source disappeared. The default pattern **/*.java
>> > is added only if combined includes is empty. I also understood the
>> > pattern is eveluated with respect to the source tree, not the project
>> > root.
>> >
>> > So adding something like:
>> >   <includes>
>> >
>> >      <include>**/*.java</include>
>> >      <include>something-else</include>
>> >
>> >   </includes>
>> >
>> > should probably work... as long as something else is in the sources tree.
>> >
>> > I tried to use <include>../../../LICENSE.txt</include> to go upward, but
>> > it doesn't work either.
>>
>> I finally managed to do what I wanted. The solution involved:
>>
>>    - using maven-antrun-plugin to:
>>         + create a directory
>> ${project.build.outputDirectory}/license-and-notice-placeholder
>>         + copy LICENSE.txt from top directory to the created directory
>>         + copy NOTICE.txt from top directory to the created directory
>>    - using build-helper-maven-plugin to add this directory to the
>> sources directories
>>    - use maven-source-plugin with includes set to:
>>         + **/*.java
>>         + LICENSE.txt
>>         + NOTICE.txt
>>
>> All three plugins are run only in a profile and they are bound to
>> package phase.
>>
>> This works, but it is really ugly.
>>
>> best regards,
>> Luc
>>
>> > best regards,
>> > Luc
>> >
>> >> Regards,
>> >>
>> >> Hervé
>> >>
>> >> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
>> >>> Hi all,
>> >>>
>> >>> I am using maven-souce-plugin in a profile, in order to generate the
>> >>> sources jar. As this sources jar is in a sense a source distribution
>> >>> (even if it is intended only for IDE completion use), it should
>> >>> include the LICENSE.txt and NOTICE.txt files that are present at
>> >>> the top level of the project.
>> >>>
>> >>> So my pom looks as follows:
>> >>>
>> >>> <profile>
>> >>>
>> >>>  <id>release</id>
>> >>>
>> >>>    <build>
>> >>>    <plugins>
>> >>>
>> >>>       <plugin>
>> >>>
>> >>>        <groupId>org.apache.maven.plugins</groupId>
>> >>>        <artifactId>maven-source-plugin</artifactId>
>> >>>        <version>3.0.1</version>
>> >>>        <configuration>
>> >>>
>> >>>          <includes>
>> >>>
>> >>>            <include>LICENSE.txt</include>
>> >>>            <include>NOTICE.txt</include>
>> >>>
>> >>>          </includes>
>> >>>
>> >>>        </configuration>
>> >>>        <executions>
>> >>>
>> >>>          <execution>
>> >>>
>> >>>            <id>create-source-jar</id>
>> >>>            <goals>
>> >>>
>> >>>              <goal>jar</goal>
>> >>>
>> >>>            </goals>
>> >>>            <phase>package</phase>
>> >>>
>> >>>          </execution>
>> >>>
>> >>>        </executions>
>> >>>
>> >>>      </plugin>
>> >>>
>> >>>    </plugins>
>> >>>
>> >>>  </build>
>> >>>
>> >>> </profile>
>> >>>
>> >>> When I run "mvn -Prelease package", I get the following error:
>> >>>
>> >>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @ orekit
>> >>> ---
>> >>> [INFO] No sources in project. Archive not created.
>> >>>
>> >>>
>> >>> If I remove the <configuration>...</configuration> part, the source jar
>> >>> is created nominally, as the sources are in the standard src/main/java
>> >>> directory.
>> >>>
>> >>> It seems to me that adding the <includes>...</includes> somehow hides
>> >>> or clears the regular list of source files. I would have expected that
>> >>> includes adds to this list.
>> >>>
>> >>> I have tried to add the path to the sources in a third <include>,
>> >>> alongside the LICENSE and NOTICE ones, using either
>> >>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing works,
>> >>> or at least I did not find the correct include statement.
>> >>>
>> >>> How can I put these two extra files into the source jar and still have
>> >>> the sources too?
>> >>>
>> >>> best regards,
>> >>> Luc
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: [hidden email]
>> >>> For additional commands, e-mail: [hidden email]
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [hidden email]
>> >> For additional commands, e-mail: [hidden email]
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



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

Reply | Threaded
Open this post in threaded view
|

Re: using includes in maven-source-plugin induces sources are not found anymore

stephenconnolly
On Fri 3 Nov 2017 at 16:18, MAISONOBE Luc <[hidden email]> wrote:

>
> Hervé BOUTEMY <[hidden email]> a écrit :
>
> > yes, really ugly :)
> >
> > usual with Maven when you're trying to do by configuration something
> > that would
> > best be served with a supported feature, that defines the associated
> > convention
> >
> > that's why I told at the beginning that perhaps it deserved a new
> feature in
> > maven-source-plugin
> >
> > something like "additionnalFiles" list that would add some files at
> > root of the
> > generated jar (like NOTICE and LICENSE)
> >
> > I'm open to PRs :)
>
> I don't have time for this right now, but I definitely will consider it.
> I don't know the internals of maven, so it would probably be a good
> exercise
> to learn them.
>

At least file a JIRA


> best regards,
> Luc
>
> >
> > Regards,
> >
> > Hervé
> >
> > Le jeudi 2 novembre 2017, 22:25:49 CET MAISONOBE Luc a écrit :
> >> Hi,
> >>
> >> MAISONOBE Luc <[hidden email]> a écrit :
> >> > Hervé BOUTEMY <[hidden email]> a écrit :
> >> >> Hi,
> >> >
> >> > Hi Hervé,
> >> >
> >> >> AFAIK, reading the plugin source code, there is no feature to add
> files
> >> >> that are not in compile source root: this will require a new feature.
> >> >>
> >> >> Did you try adding a secondary source root, using
> >> >> build-helper:add-source?
> >> >
> >> > I just tried it, thanks for the suggestion. It doesn't work.
> >> > The LICENSE.txt and NOTICE.txt files live in the root directory,
> >> > alongside the pom. So this implies adding the full project in the
> >> > source tree. It creates huge problems has there are java files
> >> > underneath (in src/main/java, and src/test/java).
> >> >
> >> > I also tried maven-resource-plugin, but it also adds full directories,
> >> > not single files.
> >> >
> >> >
> >> > I did understood why my source disappeared. The default pattern
> **/*.java
> >> > is added only if combined includes is empty. I also understood the
> >> > pattern is eveluated with respect to the source tree, not the project
> >> > root.
> >> >
> >> > So adding something like:
> >> >   <includes>
> >> >
> >> >      <include>**/*.java</include>
> >> >      <include>something-else</include>
> >> >
> >> >   </includes>
> >> >
> >> > should probably work... as long as something else is in the sources
> tree.
> >> >
> >> > I tried to use <include>../../../LICENSE.txt</include> to go upward,
> but
> >> > it doesn't work either.
> >>
> >> I finally managed to do what I wanted. The solution involved:
> >>
> >>    - using maven-antrun-plugin to:
> >>         + create a directory
> >> ${project.build.outputDirectory}/license-and-notice-placeholder
> >>         + copy LICENSE.txt from top directory to the created directory
> >>         + copy NOTICE.txt from top directory to the created directory
> >>    - using build-helper-maven-plugin to add this directory to the
> >> sources directories
> >>    - use maven-source-plugin with includes set to:
> >>         + **/*.java
> >>         + LICENSE.txt
> >>         + NOTICE.txt
> >>
> >> All three plugins are run only in a profile and they are bound to
> >> package phase.
> >>
> >> This works, but it is really ugly.
> >>
> >> best regards,
> >> Luc
> >>
> >> > best regards,
> >> > Luc
> >> >
> >> >> Regards,
> >> >>
> >> >> Hervé
> >> >>
> >> >> Le jeudi 2 novembre 2017, 11:54:58 CET Luc Maisonobe a écrit :
> >> >>> Hi all,
> >> >>>
> >> >>> I am using maven-souce-plugin in a profile, in order to generate the
> >> >>> sources jar. As this sources jar is in a sense a source distribution
> >> >>> (even if it is intended only for IDE completion use), it should
> >> >>> include the LICENSE.txt and NOTICE.txt files that are present at
> >> >>> the top level of the project.
> >> >>>
> >> >>> So my pom looks as follows:
> >> >>>
> >> >>> <profile>
> >> >>>
> >> >>>  <id>release</id>
> >> >>>
> >> >>>    <build>
> >> >>>    <plugins>
> >> >>>
> >> >>>       <plugin>
> >> >>>
> >> >>>        <groupId>org.apache.maven.plugins</groupId>
> >> >>>        <artifactId>maven-source-plugin</artifactId>
> >> >>>        <version>3.0.1</version>
> >> >>>        <configuration>
> >> >>>
> >> >>>          <includes>
> >> >>>
> >> >>>            <include>LICENSE.txt</include>
> >> >>>            <include>NOTICE.txt</include>
> >> >>>
> >> >>>          </includes>
> >> >>>
> >> >>>        </configuration>
> >> >>>        <executions>
> >> >>>
> >> >>>          <execution>
> >> >>>
> >> >>>            <id>create-source-jar</id>
> >> >>>            <goals>
> >> >>>
> >> >>>              <goal>jar</goal>
> >> >>>
> >> >>>            </goals>
> >> >>>            <phase>package</phase>
> >> >>>
> >> >>>          </execution>
> >> >>>
> >> >>>        </executions>
> >> >>>
> >> >>>      </plugin>
> >> >>>
> >> >>>    </plugins>
> >> >>>
> >> >>>  </build>
> >> >>>
> >> >>> </profile>
> >> >>>
> >> >>> When I run "mvn -Prelease package", I get the following error:
> >> >>>
> >> >>> [INFO] --- maven-source-plugin:3.0.1:jar (create-source-jar) @
> orekit
> >> >>> ---
> >> >>> [INFO] No sources in project. Archive not created.
> >> >>>
> >> >>>
> >> >>> If I remove the <configuration>...</configuration> part, the source
> jar
> >> >>> is created nominally, as the sources are in the standard
> src/main/java
> >> >>> directory.
> >> >>>
> >> >>> It seems to me that adding the <includes>...</includes> somehow
> hides
> >> >>> or clears the regular list of source files. I would have expected
> that
> >> >>> includes adds to this list.
> >> >>>
> >> >>> I have tried to add the path to the sources in a third <include>,
> >> >>> alongside the LICENSE and NOTICE ones, using either
> >> >>> {$project.buid.sourceDirectory} or hard-coded paths, but nothing
> works,
> >> >>> or at least I did not find the correct include statement.
> >> >>>
> >> >>> How can I put these two extra files into the source jar and still
> have
> >> >>> the sources too?
> >> >>>
> >> >>> best regards,
> >> >>> Luc
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: [hidden email]
> >> >>> For additional commands, e-mail: [hidden email]
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: [hidden email]
> >> >> For additional commands, e-mail: [hidden email]
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [hidden email]
> >> > For additional commands, e-mail: [hidden email]
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
> --
Sent from my phone