3
$\begingroup$

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.

$\endgroup$

1 Answer 1

1
$\begingroup$

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".

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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