Skip to main content

Project structure

In IntelliJ, File | New | Project… has two Nylon kinds: Nylon Isolate for a program, and Nylon Library for code other projects use. It asks for a group, such as org.example, and a name. For the group org.example and the name robot, it makes this:

robot/
build.markup.code
src/main/code/org/example/robot/program.code
.gitignore
  • build.markup.code is the build file: what the project builds, its name and version, and the libraries it uses.
  • src/main/code/ holds the code of the project's main module. Every .code file under it is part of the build.
  • program.code is where you start. For a program, it holds an entry point you can run straight away.
  • .gitignore keeps out/, where builds go, out of version control.

Code files and namespaces​

Every code file starts with its namespace. New Project names it after the group and the project, and puts the file in folders that match:

namespace org.example.robot

entrypoint program() {
println("Hello World!")
}

The folders are a habit, not a rule: a file's namespace line is what places its declarations, wherever under src/main/code/ the file sits.

Resources​

Files a program ships with it, such as text or data, go in src/main/resource/. New Project doesn't make that folder until you need it. Resource files says how a program reads them.

Modules​

main is a module: a part of the project that compiles on its own, from src/<module>/code. A project gets the one main module unless its build file names others.