2. Anatomy of a Codename One App
✦We’ll look at the files & directories that make up an
Codename One project
✦Identify the pieces at play and understand how
they fit in together
✦This helps later on when trying to customize,
debug or automate
✦There are some IDE differences, I’ll try to cover
them individually
3. Before we Begin
✦I assume you already installed and created a hello
world app
✦If not please follow the instructional videos here:
https://www.codenameone.com/download.html
7. Build & Dist
✦Build houses temporary build files from the build.xml
process
✦Dist hosts the resulting files from the build before they
are sent to the build server
✦Important: Running the app doesn’t always update
these directories, however sending a build to the
cloud does
✦These are important in case of a build failure or issue,
unzipping the jar in the dist directory can provide
insight (e.g. size issues etc.)
8. CodeNameOneBuildClient.jar
✦This file is responsible for sending the builds to
the cloud. It includes the ant task definitions that
handle that logic
✦It also includes unit test instrumentation code
✦This jar also handles source code generation for
the new GUI builder
9. JavaSE.jar
✦The port of Codename One to Swing + a couple
of features from JavaFX
✦Includes the simulator and everything within it
✦You can run any Codename One app in the
simulator by doing this (I used colon which is a
Unix convention replace with semicolon for
Windows):
java -classpath JavaSE.jar:dist/MyApplication.jar
com.codename1.impl.javase.Simulator
10. JavaSE.jar
✦The port of Codename One to Swing + a couple
of features from JavaFX
✦Includes the simulator and everything within it
✦You can run any Codename One app in the
simulator by doing this (I used colon which is a
Unix convention replace with semicolon for
Windows):
java -classpath JavaSE.jar:dist/MyApplication.jar
com.codename1.impl.javase.Simulator
Tip
The name of the main class is
read from the
codenameone_settings file
15. build.xml
✦Updated by Codename One Settings or Preferences
✦Might require an update to provide new features/fixes
e.g. support for UWP required a new target
✦Implementation on Eclipse is different from NetBeans
& IntelliJ/IDEA
✦The IntelliJ/IDEA plugin uses the NetBeans build.xml
which is why the nbproject folder is required there too
✦nbproject includes various internal settings for the
build.xml
16. lib directory
✦Identical on all IDE’s Includes the builtin JAR’s
✦CLDC11.jar - historical name. Includes the
Java API subset supported by Codename
One. These are just stubs for compilation (no
implementation)
✦CodenameOne.jar includes the Codename
One API to compile against (when running in
the simulator the JavaSE.jar is used.
✦CodenameOne_SRC.zip includes the main
Codename One source for code completion
17. lib directory cn1lib
✦cn1libs can be placed here (manually or via
extensions UI in Codename One Settings)
✦The impl folder is where cn1libs are extracted
so the IDE can compile against them
✦Normally you don’t need to touch this but if
you install a cn1lib (Codename One
extension) it will unzip into the impl hierarchy
when you use “refresh libs” (which invokes a
task in the build.xml)
18. native directory
✦ Identical on all IDE’s Includes native
interface implementations
✦ We’ll discuss it more when talking
about native interfaces
19. Update Process
✦ When we update something in Codename One
how does it get to the project you created a while
back?
✦ There are 3 distinct update pieces in Codename
One: Plugin update, build.xml update & libs
update
20. Plugin Update
✦ You need to update the IDE plugin manually via
the vendor settings. This impacts our tooling (e.g.
GUI builder etc.)
✦ However, only new projects will be impacted by
updates in the plugin with one major exception
✦ CodeNameOneBuildClient.jar is updated from the
plugin dynamically without a user prompt
21. build.xml Update
✦build.xml - is updated manually by saving settings
in Codename One Settings and accepting the
update
✦We discussed the implications before
22. libs Update
✦A libs update brings JavaSE.jar, CodenameOne.jar,
CLDC11.jar & CodenameOne_SRC.jar up to date
✦It can be triggered manually by pressing “Update Client
Libs” in Codename One Settings (under basic)
✦It happens implicitly when you send a build with an
older version of the libs
✦It can happen when you send a versioned build
23. What did we learn?
✦Identify the pieces that make Codename One tick
✦Which files to look into when figuring out a build
issue
✦How update works
✦How to get the latest version & what does that
mean