0

So I tried differnt things to copy my desired, necesarry .exe file into the target folder when compiling my project. I also checked at the Q&A of Move a text file into target folder when compiling a Maven project - but it did not help.

So what I want is to copy 'chromedriver.exe' to the target folder when compiling the project (with mvn clean install). I need this .exe to launch my jar file.

Any help is appreciated!

enter image description here

gala_m
  • 37
  • 8
  • Where do you want your exe to (finally) go? Be inside the jar? – J Fabian Meier Oct 31 '18 at 19:22
  • Good Question - No, inside the Target-Folder - any advice? – gala_m Nov 01 '18 at 06:30
  • I mean you probably build the project so that the result is copied/deployed somewhere. The target folder is only a temporary folder (deleted with every clean install). – J Fabian Meier Nov 01 '18 at 09:21
  • I agree, but imagine: Somehow someone wants to clone my git repo, makes a `mvn clean install` and the person wants to execute the jar file - which is placed in the target-folder. When he starts the jar (`java- jar ...`) he gets an exception because the 'chromedriver.exe' is missing in the target folder, and thats why I want to have the .exe file always in the target folder because without it, the jar won't be successful – gala_m Nov 01 '18 at 09:26

2 Answers2

1

Any files placed in src/main/resources will be automatically included in the resulting build(target) folder if you are using the default config. However, you should only be including files that should be in the resulting jar.

Deadron
  • 5,135
  • 1
  • 16
  • 27
  • Thank you for your answer - unfortunately I tried this out as well but I could not find the .exe file in the target folder after compiling - I had to copy the .exe file by myself (manually) – gala_m Nov 01 '18 at 06:33
0

I found an own solution: in the pom.xml, include

<resources>
    <resource>
        <directory>${project.basedir}</directory>
        <targetPath>${project.build.directory}</targetPath>
        <includes>
            <include>chromedriver.exe</include>
        </includes>
    </resource> 
</resources>

under the build tag.

gala_m
  • 37
  • 8