<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ardublock &#187; 文档</title>
	<atom:link href="http://ardublock.heqichen.cn/blog/zh/category/documentation/feed/" rel="self" type="application/rss+xml" />
	<link>http://ardublock.heqichen.cn/blog/zh</link>
	<description>简单实用的Arduino图形化编程工具</description>
	<lastBuildDate>Fri, 11 Dec 2015 09:18:11 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>导入ArduBlock到Eclipse中</title>
		<link>http://ardublock.heqichen.cn/blog/zh/import-ardublock-to-eclipse/</link>
		<comments>http://ardublock.heqichen.cn/blog/zh/import-ardublock-to-eclipse/#comments</comments>
		<pubDate>Thu, 02 Jul 2015 18:45:23 +0000</pubDate>
		<dc:creator><![CDATA[heqichen]]></dc:creator>
				<category><![CDATA[文档]]></category>

		<guid isPermaLink="false">http://ardublock.heqichen.cn/blog/?p=37</guid>
		<description><![CDATA[工具准备 如果需要将ArduBlock导入到Eclipse中，需要一下工具 Git ArduBlock的源代码 [&#8230;]<br/><a href="http://ardublock.heqichen.cn/blog/zh/import-ardublock-to-eclipse/" class="more-link" >Continue reading...</a>]]></description>
				<content:encoded><![CDATA[<h2>工具准备</h2>
<p>如果需要将ArduBlock导入到Eclipse中，需要一下工具</p>
<ol>
<li>Git
<ul>
<li>ArduBlock的源代码托管在GitHub上，可以在GitHub上找到在不同操作系统上安装Git工具的教程: <a href="https://help.github.com/set-up-git-redirect" target="_blank">https://help.github.com/set-up-git-redirect</a></li>
</ul>
</li>
<li>Eclipse
<ul>
<li>当然，要导入Eclipse，那么Eclipse是必需的。可以到Eclipse官网下载：<a href="http://www.eclipse.org/" target="_blank">http://www.eclipse.org/</a></li>
</ul>
</li>
<li>Maven
<ul>
<li>ArduBlock是一个Java开发的工具，我们使用Maven来管理ArduBlock的依赖库。</li>
</ul>
</li>
<li>M2Eclipse
<ul>
<li>这是个可选项。如果需要开发Openblocks的话，可以在Eclipse中安装Maven的插件，可以提高开发的效率。</li>
<li><img class="alignnone  wp-image-26" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/instll-m2e.png" alt="instll-m2e" width="307" height="281" /></li>
</ul>
</li>
</ol>
<h2>准备代码</h2>
<p>ArduBlock依赖于Openblocks。所以需要下载两个项目的源代码。首先到代码管理页面下载源代码，两个项目的地址如下:</p>
<p><a href="https://github.com/heqichen/ardublock.git" target="_blank">https://github.com/heqichen/ardublock.git</a><br />
<a href="https://github.com/heqichen/openblocks.git" target="_blank">https://github.com/heqichen/openblocks.git</a></p>
<p>可以在页面的右侧找到代码克隆的地址。比如，两个项目的地址是 <a href="https://github.com/heqichen/ardublock.git">https://github.com/heqichen/ardublock.git</a>  Openblocks项目的代码克隆地址是 <a href="https://github.com/heqichen/openblocks.git">https://github.com/heqichen/openblocks.git</a></p>
<p>找到两个源代码克隆之地之后，需要在本机圈定一个开发目录，比如，我的开发目录是~/ardublock/。那么现在，可以打开终端/bash/命令行执行命令来下载源代码。</p><pre class="crayon-plain-tag">$ cd ~/ardublock/
$ git clone git@github.com:heqichen/ardublock.git
$ git clone git@github.com:heqichen/openblocks.git</pre><p><span id="more-37"></span></p>
<p>执行这两行命令后，可以看到类似下面的内容</p>
<blockquote><p>Cloning into &#8216;openblocks&#8217;&#8230;<br />
remote: Counting objects: 2166, done.<br />
remote: Total 2166 (delta 0), reused 0 (delta 0), pack-reused 2166<br />
Receiving objects: 100% (2166/2166), 4.20 MiB | 6.00 KiB/s, done.<br />
Resolving deltas: 100% (863/863), done.<br />
Checking connectivity&#8230; done.</p></blockquote>
<p><img class="alignnone size-full wp-image-28" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/git-clone.png" alt="git-clone" width="692" height="127" /></p>
<p>说明已经成功下载了源代码。本机的目录中也出现了两个新的项目文件夹。</p>
<p><img class=" size-full wp-image-27 alignnone" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/git-folder.png" alt="git-folder" width="157" height="67" /></p>
<h2>导入ArduBlock项目到Eclipse</h2>
<p>现在有了源代码，就可以准备将代码导入到Eclipse中。</p>
<p>以下以ArduBlock项目为例，执行下面的命令。</p><pre class="crayon-plain-tag">$ 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</pre><p>执行这些命令，Maven会自动下载ArduBlock所需要的依赖包，并会编译测试。</p>
<p>Maven 的eclipse命令会将目录转换成Eclipse项目，这样就可以直接将项目导入到Eclipse中。如果需要导入Openblocks项目的话，同样的命令也可以在openblocks目录下执行。</p>
<p>打开Eclispe,依次选择<br />
File -&gt; Import -&gt; Gernal -&gt; Existing Projects into Workspace</p>
<p><img class="alignnone  wp-image-29" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/eclipse-inport.png" alt="eclipse-inport" width="351" height="516" /></p>
<p>这样ArduBlock就成功导入到Eclipse中了。但是，导入后可能Eclipse会提示以下的问题。</p>
<p><img class="alignnone size-full wp-image-36" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/06-ardublock-error1.png" alt="06-ardublock-error1" width="342" height="288" /></p>
<p><a href="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/07-ardublock-error2.png"><img class="alignnone size-large wp-image-35" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/07-ardublock-error2-1024x271.png" alt="07-ardublock-error2" width="615" height="163" /></a></p>
<p>Eclipse会提示ArduBlock找不到Openblocks库，原因是arduBlock依赖于Openblocks，但是openblocks并没有在本地库中。所以需要在本地库中安装openblocks。</p>
<p>有两种方法解决这个问题</p>
<p>一种方法是直接使用Maven来安装Openblocks</p>
<p>在终端/命令行下，进入openblocks目录，并执行以下命令</p><pre class="crayon-plain-tag">$ mvn clean
$ mvn install</pre><p>这些命令后，Maven会编译并在本机安装openblocks.</p>
<p><img class="  wp-image-38 alignnone" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/08.png" alt="08" width="489" height="310" /></p>
<p>看到编译成功后再进入eclipse刷新ardublock项目，就可以看到错误已经消失了。</p>
<p><a href="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/09-ok.png"><img class="alignnone  wp-image-33" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/09-ok.png" alt="09-ok" width="547" height="398" /></a></p>
<p>另一种方法就是也将Openblocks项目导入到Eclipse，并使用Eclipse的Maven插件来管理ArduBlock和Openblocks之间的依赖关系。</p>
<p>只要在openblocks下也同样执行相关maven命令，将openblocks目录转换成eclipse项目，然后导入到eclipse中。</p>
<p>如果eclipse有maven插件，当openblocks代码修改后，会自动更新ardublock的依赖，如果开发openblocks，这样会很方便。</p>
<p><a href="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/10-ok2.png"><img class="alignnone size-large wp-image-32" src="http://ardublock.heqichen.cn/blog/wp-content/uploads/2015/07/10-ok2-1024x576.png" alt="10-ok2" width="615" height="346" /></a>
<div class="pvc_clear"></div>
<p class="pvc_stats" element-id="37">45,625&nbsp;total views, no views today</p>
<div class="pvc_clear"></div>
]]></content:encoded>
			<wfw:commentRss>http://ardublock.heqichen.cn/blog/zh/import-ardublock-to-eclipse/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
