0

I want to include the .gitignore file in my Maven project when it is getting packaged. (My university wants the file so they can see that I used it the right way)

But the .gitignore is on the workspace directory.

I know that I can add files from directorys below with this in my src.xml

<fileSet>
    <directory>src/test/resources</directory>
    <includes>
        <include>checkstyle_swt1.xml</include>
    </includes>
</fileSet>

But as the .gitignore isnt below src/ I dont know how to include it.

So far I have tried following:

<fileSet>
    <directory>C:/Users/Samue/OneDrive/SWTest</directory>
    <includes>
        <include>.gitignore</include>
    </includes>
</fileSet>

This didnt work unfortnuately. Any other ideas?

Samuel
  • 388
  • 5
  • 15

2 Answers2

0

I find this requirement stupid because it is of no use in the final artifact. If the supervisor is interested in how you build the project, you should give him/her a zip of your artifact or workspace.

Anyway, the easiest way would be to copy the .gitignore to src/main/resources.

You can either do this manually, or you can attach the antrun plugin to an early phase of your lifecycle (https://stackoverflow.com/a/694175/927493).

For copying files with Ant see

https://ant.apache.org/manual/Tasks/copy.html

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

Simply use ../../ and you also need to set default exludes to false

Samuel
  • 388
  • 5
  • 15