score:3

Accepted answer

a quick-and-dirty solution would copy the existing folder (and all its contents) to the desired location underneath the project location and refresh the project afterwards.

for example:

iproject project = ...
ipath location = project.getlocation();
files.copy( pathtoexistingfolder, location.tofile().topath() );
project.refreshlocal( iresource.depth_infinite, null );

a more appropriate solution would traverse the existing folder and create a copy of each file and folder found therein.

to create a new file,use

iproject project = ...
ifile file = project.getfile( "path/relative/to/prooject" );
file.create( inputstream, iresource.none, null );
// or, to override and existing file (file.eists() == true):
file.setcontents( inputstream, iresource.none, null );

the inputstream is assumed to be backed by the currently traversed file from the existing files folder.

to create a new folder, use

iproject project = ...
ifolder folder = project.getfolder( "path/relative/to/prooject" );
folder.create( iresource.none, true, null );

i further assume that your existing files will ultimately end up being stored in a (jared) plug-in. in this case, the latter approach is the only viable as it lets you supply the folder structure and file contents from the plug-in storage.

the plugin development environment (pde) provides extension points and api to manage and execute templates during project-creation. while you certainly wouldn't want to depend on plug-ins from the pde, you may want to have a look at the sources: https://github.com/eclipse/eclipse.pde.ui/tree/master/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/templates


Related Query

More Query from same tag