How to use Codenameone Source into Eclipse project? - codenameone

I have an eclipse codenameone project. I would like to execute this project on Eclipse using my own codenameone modified sources (codenameone sources project is in netbeans). How could I do that ?
As it is mentioned in this video, we should linked the project in the build path but it works only if we have a netbean project.
Better solution is to edit Codenameone source in Eclipse (but sources in github has structure of a Netbeans project).
Thanks!

Right now debugging with the Codename One sources is only supported on NetBeans because that is the platforms we use for our coding. It's harder to work with other IDE's and might not be worth your effort.
Someone posted a while back in the discussion forum about running this in Eclipse but I couldn't find the reference.
Generally if you want to build the native sources and debug from there just work based on the logic we have and adapt it to Eclipse (or any other IDE). Running a Codename One project has 2 major dependencies:
Codename One project - that's a regular Java project you can work with
JavaSEPort another regular project, this is the implementation of the Codename One code and includes the simulator.
Make sure to add the source trees of both these projects to the compile but not packaging phases and set the Simulator class as your main class.
If you are successful in doing this it would be really nice if you write about it for the developer guide wiki next to the NetBeans build and explain how this is done for future developers.

Related

Integrating a Today Extension into a Codename One iOS App

I'm new to this topic and couldn't find any guides concerning this. I'm wondering how the Today Extension files from a xcode project (originated from the CN1 iOS debug build sources) needs to be added to the actual CN1 project in order to get integrated properly.
We don't have builtin support for that and didn't really study it. We never had official support for Android widgets either.
Both can be used through native code though. E.g. in this case you can use ios.plistInject to add the necessary plist changes. The actual UI/code that implements them should be done in a native interface anyway.

Still no Codename One Library project option when using Eclipse?

I recently read FIRST CLASS ECLIPSE SUPPORT which made me expect a cn1lib-wizard. But there still is none, right?
The gist of the article is that we will update the Eclipse plugin with the NetBeans & IntelliJ versions. With the trend of migrating towards common code across IDE's within our plugin (the new settings UI) this should be much easier and Eclipse should no longer be out of date with the other IDE's.
I'm not sure when we'll get around to do the library template, unlike the other features it requires some work since the Ant implementation on Eclipse is rather different. So it's hard to give a specific date.

How to setup fragment projects

I'm using Eclipse with the Codename One Plugin.
Now I am starting a second project.
I would like to setup one or more "fragment" projects to avoid code duplication between projects. For example if I'm having a utility class for string concatenation I'd like to have this in a Utilities fragment project which then would be referenced by my projects.
What is the recommended way of doing this with Codename One?
For Codename One that's a cn1lib unfortunately at this time the Eclipse plugin is the only one that doesn't support the creation of a cn1lib (although it allows using them just fine).
Since a cn1lib is just an Ant project you can just download an existing project and put in your own code instead of what's there.

How to set up a unit-tested C project in Eclipse

I'm sure this is documented somewhere but I'm struggling to find what I'm after. I am developing a project in C (and explicitly not C++), and having had good experiences developing Java projects with JUnit for TDD, I'd like to take a similar approach for this new project.
Can anyone provide a walkthrough for creating and running a simple C project, and running a couple of unit tests on them within Eclipse CDT? I have Eclipse CDT (Luna) and the unit-testing plugin as described in the frequently referenced blog. Most of the guidance appears to be for C++.
FWIW I'm running on Windows 7 and compiling with MinGW GCC.
Have you given google test a try? Its technically a c++ library, but has very little overhead to test your functions. A c++ test project would easily be able to consume the library generated from your c code, so should be pretty easy.
For example, this is what a test would look like
#include "gtest/gtest.h"
#include "MyProject/myFunc.h
TEST (myFuncTest, calculate) {
EXPECT_EQ (18.0, myFunc_calculate (324.0));
}
You can find more details at IBM Developerworks on YouTube etc.
After a lot of research, I tried most of the libraries for C and C++ testing and the one that was the right one for me was the Acutest.
I have created a public repository with an example that also uses Github Actions and a makefile in order to accomplish Continuous Integration (CI) by compiling the code and the tests and running them on every push automaticly.
Repository Link : CPP_Unit_Testing

Run native C++ code on codename one

I have an android app where I am running native C++ code using JNI (Java Native Interface). I want to port it to codename one so that it can run on iOS as well. What is the alternative to JNI on codename one that will allow me to run my native C++ code?
You can call C++ from Objective-C we did just that in the ZXing demo for the iOS port see: http://github.com/codenameone/codenameone-demos
For Android you will need to wrap the C++ code using the NDK in order to use it. Chen discussed this a while back in a blog post here: http://www.codenameone.com/blog/integrating-android-3rd-party-libraries-jni.html
The relevant section is this:
We recently added a 3rd option :aar files. The aar file is a binary format from Google that represents an Android Library project.
One of the problem with the Android Library projects was the fact that
it required the project sources which made it difficult for 3rd party
vendors to publish libraries, so android introduced the aar file which
is a binary format that represents a Library project.
To learn more about arr you can read this.
You can link an aar file by placing it under the native/android and
the build server will link it to the project.
Notice that for Android you might want to use the new gradle build system which would also make this simpler: http://www.codenameone.com/blog/material-icons-background-music-geofencing-gradle.html
Codenameone has it's native interface that allows adding native codes.
Each platform has it's native code and as far as I know C++ is not in any of them.
I would suggest you translate your code from C++ to Java and Objective-C manually and you can use those code in implementing CN1 native interface.
Read about Native Interface here and also have a look at native demo

Resources