2

I'm new to eclipse plugin development.

I've been able to create a new project type and add folders to it.

What is the best way to add a starting set of files into this project? Should I have my JAVA class create these files? Or can I package them with the plug-in and copy them into new project instances?

majestiq
  • 545
  • 8
  • 25

2 Answers2

1

Is your plugin's goal to create new projects? Not quite sure what do you mean by

starting set of files

Ok maybe have a look at sourceforge, see how this guys are doing it.

TomaC
  • 89
  • 6
  • yeah.. its basically a new Type of project. It should setup all the base files that will be required for that project. – majestiq Apr 20 '11 at 14:54
  • I'd personally just store the paths to the template files in an .xml or something. This should give you more flexibility if you'd like to change the templates in the future. Once you get the paths you can try something like : ' URL url = new URL(path); URLConnection connection = url.openConnection(); IFile file = project.getFile(fileName); file.create(connection.getInputStream(), true, null); ' – TomaC Apr 20 '11 at 18:02
  • so basically.. just put the code / template into the plugin somewhere.. and then use java to copy it into the users workspace? – majestiq Apr 20 '11 at 18:02
  • yeah, I edited the post above to include some code, can't get the code to format nicely sorry about that. Just keep in mind that you also need to manually create the folder structure. Hope this helps. – TomaC Apr 20 '11 at 18:12
1

Just to clarify the 2 common patterns. You can do it like Java, where you include the template files with your source files, and use YourClass.class.getResourceAsStream("filename") to get the input stream to the files. If you are working on an eclipse plugin, you can use Bundle.getEntry("/path/in/plugin") which returns a URL you can use to get the InputStream.

PW

Paul Webster
  • 10,614
  • 1
  • 25
  • 32
  • Hmm, if I prefer the first way, what is the correct way to enclose the resource file in the bundle.properties? Lets fix an xsd file as an example located in at/test/ like the Sample.java class. Using Sample.class.getResourceAsStream("Sample.xsd") would have to be included in the bundle, but how? It is really located underneath src/ and including src/at/test does not provide the correct location as required by Sample.java?! – col.panic Sep 11 '13 at 11:28