IntelliJ plugin topics:
Install or run a recent copy of IntelliJ - either the community or ultimate edition and install the StrataCode plugin:
- Download sc4idea.zip
- Go to IntelliJ's Preferences, Plugins, and under the settings menu (click the gear icon), choose "Install plugin from disk"
- Select the sc4idea.zip file you downloaded and press OK. Then restart IntelliJ.
If you have the StrataCode source (scc-src.zip or access to the private git repo), go to Option #2.
Option #1: Quickstart to run examples with no StrataCode source
- Run IntelliJ and choose 'Create New Project' from the setup wizard or ...
- Choose StrataCode from the list of available project types
- Choose your JDK (1.8) and click Next
- Enable Install layers from repository URL and use the default URL (https://github.com/stratacode/)
- Enter a comma separated list of bundle names to install. Enter a comma separated list including at least 'coreFramework, example'. Add 'siteBuilder', 'programEditor', 'doc' to add those bundles.
Enter a name for your project and click OK to build the project. It will take a minute or so to check the code out of git.
Option #2: Installation with scc source
It's best to build StrataCode projects with the source of the scc libraries. The code is generally readable, traceable, helpful toString methods, and so it's possible to debug by inspection when things go wrong.
To build and debug StrataCode itself from source, along with the apps built on it, download the 'scc' source distribution:
mkdir ~/scc cd ~/scc git clone https://github.com/stratacode/system.git .
Or with scc-src.zip:
mkdir ~/scc cd ~/scc unzip ~/Downloads/scc-src.zip
Import scc modules
There are three directories in the source github repo: fullRuntime, coreRuntime, and system, each an IntelliJ module to be imported into the project in that order.
Run IntelliJ and create a Java project, or open an existing one.
Use a recent version of JDK 1.8.
Open the Project Structure on this project, click on "Modules" and then "+", then "Import module". Select the file ~/scc/fullRuntime/fullRuntime.iml and press ok. Do the same for coreRuntime/coreRuntime.iml, then system/sc.iml.
In the project structure dialog, click on Libraries and then "+" to add a new library from Maven and enter jline, then press "search" and choose:
The dependency already exists from the 'sc' module so cancel the 'Choose modules' dialog.
Press 'Ok' to save changes in the project structure dialog. The scc command should now be ready to run.
Test the scc command
Use the goto class operator to navigate to some of the main Java classes in scc: Bind, LayeredSystem, JavaLanguage, Element, Parser, Parselet.
Add a run/debug configuration to run the 'scc' command. Select 'Add configuration' in IntelliJ. Choose 'Application' to run a Java application (Note: Don't choose StrataCode Application at this point - scc is written in Java).
1) print the scc version:
Main class: sc.layer.LayeredSystem Program arguments: -version Use classpath of module: 'sc'
2) build the scc package directory:
Main class is: sc.layer.LayeredSystem Program arguments: system -a -lp . -da /tmp/sccBuild -c -cc -v -Pbuild.tag=dev Working directory: /home/myHome/scc Use classpath of module: 'sc'
Make sure to use the absolute path of the 'Working directory' as IntelliJ does not support ~/scc. Use a path like /Users/jvroom/scc or /home/jvroom/scc.
The result builds a runnable version of scc in /tmp/sccBuild/bin/scc. See the makeSCC script in ~/scc/bin/makeSCC for the official build script.
Create StrataCode project files
Make a StrataCode project directory with one or more bundles:
mkdir ~/myProj cd ~/myProj mkdir bundles cd bundles git clone https://github.com/stratacode/coreFramework.git
Add additional layer bundles as well (inside of the 'bundles' directory):
git clone https://github.com/stratacode/example.git git clone https://github.com/stratacode/programEditor.git git clone https://github.com/stratacode/siteBuilder.git
Create a new StrataCode IntelliJ module
Choose File, New, Module..., select type StrataCode and press 'Next'. Since the layers are installed already above, don't choose 'Install layers' (that option will just perform the steps above but does not have logic to enter passwords, etc if git is not configured by default and does not have any progress indicators). Instead, press 'Next' and enter in the Content root and Module root both to the same directory ~/myProj created above, where the Module name is usually the directory name.
Bundle directories that exist when the module is setup are automatically added as source directories to the module. If you add bundles after the module is setup, use the Project Explorer to add them as source directories or right click and 'Mark directory as source' to include it or 'Exclude' to later exclude it.
(TODO: there's a bug where you currently need to invalidate caches and restart after adding a layer bundle to rebuild the indexes)
Test the StrataCode project
Open the 'Layers' side panel on the right to build the indexes and install 3rd party dependency libraries like jetty, etc.. This will take a couple of minutes the first time and is missing a progress indicator so be patient.
Once the layers view appears, check that there are three processes: Server: java, Desktop: java, and Runtime: js.
Use the IDE 'goto class' operator to goto UnitConverter - expect to see several different versions of UnitConverter in different layers.
Other interesting classes fron the web framework: PageDispatcher, SyncServlet, HtmlPage.
Create a StrataCode run/debug configuration. Choose one or more compiled layers and/or dynamic layers and name the configuration. For example, add example.unitConverter.html.clientServer as either a compiled or dynamic layer (or right click on that layer and choose 'Run layername' or 'Debug layername' that will create a temporary run configuration for that layer).
See example layers for more examples.
If you have problems, try invalidating the caches and restarting. It should take a minute or two to build the indexes the first time.
Here are the source paths and excluded folders in the project structure dialog using source:and the dependencies:
If you have problems with the editor improperly reformatting a .sc* file after you insert a close brace, go to IntelliJ's preferences. Under: Editor, General, Smart Keys, disable "Reformat block on typing '}'"
Converting from Option #1 to Option #2
If you have already created a StrataCode module and later want to add the scc source, go to the module, remove the dependency on the "SCLib" library and add module dependencies on fullRuntime, coreRuntime and sc/system (in that order). The fullRuntime has to be ahead of coreRuntime in the dependency list so we pick up the complete versions of the runtime apis.
Make the project to compile the StrataCode source (so the StrataCode plugin can find the classes for StrataCode itself).
Add a StrataCode module to a Java project
It's easy to add StrataCode to an existing Java project.
Use New->"Module..." in IntelliJ. Choose a directory with one or more layer bundles (i.e. a bundles directory containing one or more directories that are in the layer path - defining layer groups and directories). Make sure the bundle directories are marked as an intelliJ 'sources root' by right clicking on them and choosing 'Mark directory as...' then choosing Sources root.
(Note: we've only tested using one StrataCode module per project, but in general it's easy to add, include, exclude bundles of layers from the one module so it might not be a use case we need to support).