Skip to content

A better Project Layout

Patrick Scheibe edited this page Nov 26, 2016 · 1 revision

Currently, the template for Basic Package and Mathematica Application in the New Project dialog is not optimal, especially regarding a later automatic deployment of code. The Basic Package has the problem that source code is not separated from Idea project and module files. In the current implementation, the whole root folder is marked as source code which can be seen in the project and module settings. An improvement of the present situation should target this and provide a way to incorporate Mathematica packages in Idea.

In my opinion, we have at least three different code layout possibilities for Mathematica packages:

Basic package

The basic package usually consists of one package file and maybe some test notebooks. A sample layout looks like

BasicPackage/
├── BasicPackage.iml
├── BasicPackage.m
├── BasicPackage.nb
└── .idea

The mixture of Idea files and Mathematica source files in one folder is not optimal, but I cannot think how to prevent this for such a simple layout.

Normal Package

Consists only of Mathematica files and it uses the Kernel/init.m approach to load several packages on the Get command. The current implementation of the plugin does not create this layout! I would highly prefer to have a subfolder with the same name as the root directory. With this, we can mark the package subfolder as source code and we know what we need to deploy. This layout can be combined with a PacletInfo.m in the root directory.

NormalPackage/
├── .idea
├── NormalPackage
│   ├── Kernel
│   │   └── init.m
│   ├── NormalPackage.m
│   └── NormalPackage.nb
└── NormalPackage.iml

Full Package

A full package should contain the package code, documentation sources, Mathematica Tests, and probably a JLink Java module

FullPackage/
├── FullPackage
│   ├── Documentation
│   │   └── English
│   │       ├── Guides
│   │       ├── ReferencePages
│   │       └── Tutorials
│   ├── FullPackage.m
│   ├── FullPackage.nb
│   └── Kernel
│       └── init.m
├── FullPackage.iml
├── .idea
├── Java
│   ├── Java.iml
│   ├── Resources
│   ├── src
│   └── Tests
├── PacletInfo.m
└── Tests

I am not sure whether the package documentation needs to inside the package source. If it was an outside directory like Tests it could be marked as Resources and a deploy mechanism could build it and place the output in the correct location. Additionally, the Java module needs to build a .jar and on deploy, it should put it into the correct subfolder so that it is automatically found by Mathematica. The Java part can, of course, be set up manually.