Tools
You need tools below to import ardublock source code to Eclipse.
- Git tools
- can find tools for your operating system from github: https://help.github.com/set-up-git-redirect
- Eclipse
- Maven
- We use maven to manage java packages.
- M2Eclipse
- I am very to recommend you install a maven plugin, if you develop openblocks. it will help you raising development efficiency.
Prepare The code
First, you need to clone the source code from github. Ardublock is depended on Openblocks. You can find these two repo here
https://github.com/heqichen/ardublock.git
https://github.com/heqichen/openblocks.git
you will find the git clone url on the right or page.
then you need to clone this two repos. for example ardublock clone url is https://github.com/heqichen/ardublock.git and openblocks clone url is https://github.com/heqichen/openblocks.git
now open your terminal, and go to your development directory. For example, my development directory is ~/ardublock/
1 2 3 |
$ cd ~/ardublock/ $ git clone git@github.com:heqichen/ardublock.git $ git clone git@github.com:heqichen/openblocks.git |
you will get something like this.
Cloning into ‘openblocks’…
remote: Counting objects: 2166, done.
remote: Total 2166 (delta 0), reused 0 (delta 0), pack-reused 2166
Receiving objects: 100% (2166/2166), 4.20 MiB | 6.00 KiB/s, done.
Resolving deltas: 100% (863/863), done.
Checking connectivity… done.
and same as ardublock project. Finally got two repo in your local machine.
Import to Eclispe
Now Lets import the source code.
1 2 3 4 5 |
$ cd ardublock # go into ardublock folder $ mvn validate # downlaod maven packages $ mvn clean # $ mvn eclipse:clean # clean eclipse project $ mvn eclipse:eclipse # change project to eclipse project |
After these commands, Maven will download the required packages and make eclipse project.
now we can import ardublock into elicpse
open eclipse
File -> Import -> Gernal -> Existing Projects into Workspace
you may find some error, because of missing openblocks package.
there are two method to resolve this problem.
1. install the openblocks package locally.
go to openblocks folder and run
1 2 |
$ mvn clean $ mvn install |
After these command, maven will compile and install openblocks package in your local machine.
Now, no error any more.
Another method is import openblocks in your eclipse.
run command as ardublock and import openblocks into your eclipse. Also can solve the problem.
42,321 total views, 3 views today
很详细的教程!
截图中使用的是 1.0.2,但是 ardublock 依赖的是 1.0.3,如何解决呢?
eclipse 报错:
library: ‘E:\maven_repository\edu\mit\openblocks\1.0.3-SNAPSHOT\openblocks-1.0.3-SNAPSHOT.jar’ ardublock
已解决。但是又有新的问题,就是 mvn install 出来的 jar 无法正常运行(但是 eclipse 里面可以运行 main):
C:\Users\Lee>java -jar C:\Users\Lee\Downloads\ardublock-master\target\ardublock-all.jar
Exception in thread “main” java.util.MissingResourceException: Can’t find resource for bundle java.util.PropertyResourceBundle, key bg.xxx_Button_Module
at java.util.ResourceBundle.getObject(Unknown Source)
at java.util.ResourceBundle.getString(Unknown Source)
at edu.mit.blocks.controller.WorkspaceController.ardublockLocalize(WorkspaceController.java:223)
at edu.mit.blocks.controller.WorkspaceController.setLangDefStream(WorkspaceController.java:173)
at com.ardublock.Context.resetWorksapce(Context.java:142)
at com.ardublock.Context.(Context.java:95)
at com.ardublock.Main.startOpenblocksFrame(Main.java:34)
at com.ardublock.Main.startArdublock(Main.java:28)
at com.ardublock.Main.main(Main.java:23)
终于搞定了!
我的 eclipse 默认中文,放到 arduino Tools 文件夹是英文,只需要把 ardublock_zh_CN.properties 修改为 zh_CN 即可。
因为windows mac linux的locale是不同的。。。语言要统一的话,可能要针对不同的操作系统和版本做判断工作
mvn install 只是把当前包编译出来,然后放到本地mvn repo中,
如果要编译运行版本,需要用mvn package,
这样会把所有的依赖库都打包在一起
我修改过openblocks的版本,因为openblocks里面bug太多了,我不断在修bug,但还没有把正在开发的版本放上来,如果出问题的话,自己修改一下版本,统一一下就可以了
求教如何解决
什么问题?
I’m excited about ArduBlock as it’s been helpful teaching programming to elementary-aged kids.
I also appreciate this tutorial, yet I got stuck at the same error: [Project ‘ardublock’ is missing required library: ‘C:\Users\JasonWChan\.m2\repository\edu\mit\openblocks\1.0.3-SNAPSHOT\openblocks-1.0.3-SNAPSHOT.jar’].
How was it solved? Does it matter which Java version we use also? I’m using Java 1.80_60 with Eclipse Mars.1 Release (4.5.1) with Windows 7.
Thanks so much in advance Jason
Sorry, I can only understand English, so I had to use Google-Translator to understand the Chinese.
hi Jason, you can update your local openblocks repo to version 1.0.3.
I see very limited support for Grove modules. Are there a library I can import into Ardublock to expand with additional Grove modules?
In order to prevent some commercial issues, I remove Grove modules from ardublock. sorry
如何将引用openblock1.02改成1.03?
直接更新成最新版就可以了
这个没办法,需要慢慢跟openblocks里面的代码