score:3
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
Source: stackoverflow.com
Related Query
- Copy an existing folder into newly created project in Eclipse workspace
- Importing an existing Eclipse project into MyEclipse workspace
- How to cause Eclipse to copy a certain project folder into the respective bin directory?
- New Eclipse workspace in working copy folder does not recognize existing projects from subversion
- Import project into Eclipse but NOT into workspace folder
- How to import an existing Android Library project into Eclipse workspace
- Import existing mult-rep CVS project folder into Eclipse
- How to import an Android Library Project created on Android Studio into existing Eclipse Android App Project, as library?
- Editing existing SBT project folder in Eclipse without copying it to workspace
- How to make an existing directory into an eclipse project
- Android - copy existing project with a new name in Eclipse
- Eclipse + EGit: clone project into workspace
- Import existing Gradle Git project into Eclipse
- Import an existing Git project into Eclipse without a .project file
- Maven root pom.xml marked as red when importing existing project into eclipse
- Eclipse building workspace hangs after importing existing maven project because of JavaScript validation
- Eclipse + Turn an Existing Project into a JPA Project
- Import an existing SVN project into Eclipse
- Importing existing java dynamic web project into Eclipse
- Programmatically importing an existing project into Eclipse
- Move Android Eclipse project into workspace
- How to copy multiple projects into single folder in eclipse
- Importing Existing Android Project into Eclipse
- How to copy projects into workspace of eclipse after importing the project?
- Importing an existing maven Project into Eclipse
- Importing Existing Android Project Into Eclipse Renames Project
- Adding an Existing Folder to Eclipse project (STS)
- m2eclipse: add group id to project name when importing existing maven project into Eclipse
- Integrating WindowBuilder into an existing eclipse project
- How can i import a Eclipse launch-group configuration into another workspace along with project
More Query from same tag
- Eclipse Luna, Google Web Kit - Create GWT RemoteService
- Eclipse Proxy authorisation exception
- maven-surefire-plugin system properties and eclipse integration?
- Can I generate a file in the project explorer in Eclipse?
- Eclipse projects sharing images?
- Could I change or configure default log file location of eclipse?
- Eclipse Error Highlighting with Auto C++
- Alternatives to using a repository for Eclipse
- getting classes into the classpath with sbt
- Eclipse Oxygen causes slowdown the whole system
- Code hinting by parameters
- "method stream() is undefined for the type Set<Person>"
- phonegap/cordova filewriter and reader not working
- Null Pointer exception - Robotium Unit test
- jboss 7 java.lang.OutOfMemoryError: Java heap space
- file copy error with Maven
- Japanese num pad keyboard in AVD
- Maven Error While Processing POM: [FATAL] Non-parseable POM...PITarget with reserved xml name
- Exporting as .apk & project files location not known when using LuaEclipse (beginner)
- Not able to launch IE/Chrome from Selenium Webdriver
- How to change Gradle version in Eclipse using Buildship?
- Error : Java heap space
- Can't access php file from other domain
- I want to open acra project in eclipse
- Eclipse eGit : History view only shows local history, not remote history
- How can I import an external .js to my Java test with Selenium in Eclipse?
- Howto see both git and svn operations in Team menu in Eclipse?
- How to uninstall pip packages which are installed from a *.txt file?
- Writing to a JSON file with Java doesn't work after export
- What is the difference between Eclipse for Java and RCP?