beek
beek

Reputation: 3750

Maven reference folder in Build

Hi this follows on from this question Java Maven reference files in WebApp

I'm attempting to copy a folder into the build directory (this is successful) I then attempt to run the application and copy that directory into a temp directory so I can make changes and zip it up into a Scorm package.

The folder is in the build as

C:\workspace\admin\target\admin-1.0-SNAPSHOT\resources\applications\scorm

I'm trying to reference this from the running application as:

    System.out.println(new File("applications/scorm").getAbsolutePath());

    File source = new File("applications/scorm");
    File dest = new File(Constants.TEMP_DIR_PATH + '/' + guideId);
    try {
        FileUtils.copyDirectory(source, dest);
        System.out.println("copy complete");
    } catch (IOException e) {
        e.printStackTrace();
    }

It never finds the file and my absolute path check gives me

C:\workspace\admin\applications\scorm\

Which would indicate it's looking in the root directory.

How do I reference a file from the built application that is in the build directory? enter image description here

i.e. the folder is in the root of the build directory under resources, what goes in here File source = new File("What is the file URL from the build directory?"); to reference that folder?

EDIT

This works

target/admin-1.0-SNAPSHOT/resources/applications/scorm

But I doubt will work in production when it's deployed as a WAR file

Upvotes: 0

Views: 139

Answers (1)

Eranda
Eranda

Reputation: 1467

You need to specify all the artifacts from your build directory (where your pom.xml) So the solution is to have the source location as resources/applications/scorm

System.out.println(new File("resources/applications/scorm").getAbsolutePath());

File source = new File("resources/applications/scorm");
File dest = new File(Constants.TEMP_DIR_PATH + '/' + guideId);
try {
    FileUtils.copyDirectory(source, dest);
    System.out.println("copy complete");
} catch (IOException e) {
    e.printStackTrace();
}

Upvotes: 1

Related Questions