Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have been working with Mathematica for a while and have accumulated a number of folders (not in Workbench project form), each with a few files such as a .nb file, maybe a .m file, and their products (images etc.).

I then acquired Wolfram Workbench, and am up and running, and wish to transfer my existing folders to Workbench. If I try

File -> Import -> General -> Existing Projects into Workspace -> Next

and select the directory that contains my folders, the information up the top of the dialogue box says, "No projects are found to import".

If I simply transfer my folders to the base Workbench directory, they are not visible in the Package Explorer or Navigator even after pressing F5 (Refresh).

Any ideas?


PS $\hspace{5mm}$ After experimenting a little more, I've discovered that I can go

File -> New -> Project -> Mathematica -> Basic Project

and create a project with the same name as the folder I wish to import; then paste the contents of my folder into the project folder. This is a work-around, but what I'd really like to do is import all of my existing folders into the base workspace and have Workbench recognise them as projects (and create the necessary infrastructure around them if need be), without my having to faff around creating projects manually.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Wolfram Workbench (and Eclipse in general) recognizes a directory as a project, if it contains special project description file.

I don't know any "batch project creation" functionality in Workbench, but you can easily programmatically add necessary files to your folders with Mathematica.

Description file for Mathematica projects looks like this:

template = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<projectDescription>
\t<name>`1`</name>
\t<comment></comment>
\t<projects>
\t</projects>
\t<buildSpec>
\t\t<buildCommand>
\t\t\t<name>com.wolfram.eclipse.MEET.MathematicaProjectBuilder</name>
\t\t\t<arguments>
\t\t\t</arguments>
\t\t</buildCommand>
\t</buildSpec>
\t<natures>
\t\t<nature>com.wolfram.eclipse.MEET.SimpleMathematicaNature</nature>
\t</natures>
</projectDescription>
";

where `1` is a placeholder for project name.

Take all relevant directory paths:

directories = 
    Select[
        FileNames["/path/to/root/directory/*"],
        FileType[#] === Directory &
    ]

and create description files with project names same as directory names:

Export[
    FileNameJoin[{#, ".project"}], 
    ToString[StringForm[template, FileNameTake[#]], StandardForm], 
    "String"
] & /@ directories

Now you should be able to import "Existing Projects into Workspace".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.