diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml
index cf45c77..1facb58 100644
--- a/META-INF/plugin.xml
+++ b/META-INF/plugin.xml
@@ -1,15 +1,21 @@
com.atsebak.raspberrypi
Embedded Linux JVM Debugger (Raspberry Pi, Intel x86, ARM processors)
- 0.40
+ 0.41
At Sebak
Java Debugger for Embedded Systems that run on Embedded Linux
+ Java Debugger for Embedded Systems that run on Embedded Linux or on the Yocto Project Kernel
]]>
Version 0.40
+ Version 0.41
+
+ -
+ Fixed Raspberry PI Project Templates Generation
+
+
+ Version 0.40
-
Fixed the way java process gets terminated on remote target.
@@ -70,14 +76,4 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/Resources/pi4j.zip b/Resources/pi4j.zip
new file mode 100644
index 0000000..7ebd3dc
Binary files /dev/null and b/Resources/pi4j.zip differ
diff --git a/src/com/atsebak/embeddedlinuxjvm/project/RPiJavaModuleBuilder.java b/src/com/atsebak/embeddedlinuxjvm/project/RPiJavaModuleBuilder.java
index 4e5a30a..152c276 100644
--- a/src/com/atsebak/embeddedlinuxjvm/project/RPiJavaModuleBuilder.java
+++ b/src/com/atsebak/embeddedlinuxjvm/project/RPiJavaModuleBuilder.java
@@ -31,6 +31,8 @@
import com.intellij.testFramework.PsiTestUtil;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import lombok.SneakyThrows;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -45,10 +47,8 @@
public class RPiJavaModuleBuilder extends JavaModuleBuilder {
public static final ProjectType PI_PROJECT_TYPE = new ProjectType("PI_JAVA");
private static final String PROJECT_NAME = "Raspberry PI";
- private static final String PI4J_DOWNLOAD = "http://get.pi4j.com/download/";
- private static final String PI4J_FILENAME = "pi4j-1.1-SNAPSHOT.zip";
- private static final String PI4J_INSTALLPATH = "/opt/pi4j/lib";
private String packageName;
+ @Nullable
private File[] jarsToAdd;
/**
@@ -82,30 +82,26 @@ public void setupRootModel(final ModifiableRootModel rootModel) throws Configura
* @param rootModel
* @param project
*/
- private void createProjectFiles(final ModifiableRootModel rootModel, final Project project) {
+ private void createProjectFiles(@NotNull final ModifiableRootModel rootModel,@NotNull final Project project) {
ProjectUtils.runWhenInitialized(project, new DumbAwareRunnable() {
public void run() {
- String srcPath = project.getBasePath() + "/src";
- String libPath = project.getBasePath() + "/lib";
- try {
- //todo fix
-// VfsUtil.createDirectories(libPath);
- addJarFiles(libPath, rootModel.getModule());
- String[] directorysToMake = packageName.split(Pattern.quote("."));
- for (String directory : directorysToMake) {
+ String srcPath = project.getBasePath() + File.separator + "src";
+ addJarFiles(rootModel.getModule());
+ String[] directoriesToMake = packageName.split(Pattern.quote("."));
+ for (String directory : directoriesToMake) {
+ try {
VfsUtil.createDirectories(srcPath + FileUtilities.separator + directory);
- srcPath += FileUtilities.separator + directory;
- }
- } catch (IOException e) {
+ } catch (IOException e) {
+ }
+ srcPath += FileUtilities.separator + directory;
}
Template.builder().name("main.ftl")
.classContext(this.getClass())
.outputFile(srcPath + FileUtilities.separator + "Main.java")
.data(new HashMap() {{
put("packagename", packageName);
- }})
- .build()
+ }}).build()
.toFile();
ProjectUtils.addProjectConfiguration(rootModel.getModule(), project, packageName + ".Main");
}
@@ -200,31 +196,15 @@ public String getDescription() {
* @param module
* @throws ConfigurationException
*/
+ @SneakyThrows(IOException.class)
@Override
protected void setupModule(Module module) throws ConfigurationException {
super.setupModule(module);
- File pi4j = new File(PI4J_INSTALLPATH);
-
- //user installed library already
- if (pi4j.exists()) {
- jarsToAdd = pi4j.listFiles();
- } else {
- try {
- //download library
- File pi4jZip = new File(System.getProperty("java.io.tmpdir") + FileUtilities.separator + PI4J_FILENAME);
- if (!pi4jZip.exists()) {
- UrlDownloader.saveUrl(System.getProperty("java.io.tmpdir") + FileUtilities.separator + PI4J_FILENAME, PI4J_DOWNLOAD + PI4J_FILENAME);
- }
- //unzip to temp
- String output = System.getProperty("java.io.tmpdir") + FileUtilities.separator + "pi4j";
- File pi4jUnziped = new File(output);
- if (!pi4jUnziped.exists()) {
- FileUtilities.unzip(pi4jZip.getPath(), output);
- }
- jarsToAdd = pi4jUnziped.listFiles();
- } catch (IOException e) {
- }
- }
+ final String libPath = module.getProject().getBasePath() + File.separator + "lib";
+ VfsUtil.createDirectories(libPath);
+ File outputFiles = new File(libPath);
+ FileUtilities.unzip(getClass().getResourceAsStream("/pi4j.zip"), outputFiles.getAbsolutePath());
+ jarsToAdd = outputFiles.listFiles();
}
/**
@@ -236,23 +216,16 @@ protected ProjectType getProjectType() {
return PI_PROJECT_TYPE;
}
- private void addJarFiles(String outputPath, Module module) {
+ private void addJarFiles(Module module) {
if (jarsToAdd == null) {
return;
}
- //todo fix
-// for (final File fileEntry : jarsToAdd) {
-// if (!fileEntry.isDirectory() && Files.getFileExtension(fileEntry.getName()).contains("jar")) {
-// String jarLocation = outputPath + FileUtilities.separator;
-// FileUtils.copyFile(fileEntry, new File(jarLocation + fileEntry.getName()));
-// }
-// }
+
for (final File fileEntry : jarsToAdd) {
if (!fileEntry.isDirectory() && Files.getFileExtension(fileEntry.getName()).contains("jar")) {
- PsiTestUtil.addLibrary(module, "pi4j", fileEntry.getParentFile().getPath(), fileEntry.getName());
+ PsiTestUtil.addLibrary(module, fileEntry.getName(), fileEntry.getParentFile().getPath(), fileEntry.getName());
}
}
- PsiTestUtil.addLibrary(module, outputPath);
}
/**
diff --git a/src/com/atsebak/embeddedlinuxjvm/utils/FileUtilities.java b/src/com/atsebak/embeddedlinuxjvm/utils/FileUtilities.java
index 6e0682b..5fdd176 100644
--- a/src/com/atsebak/embeddedlinuxjvm/utils/FileUtilities.java
+++ b/src/com/atsebak/embeddedlinuxjvm/utils/FileUtilities.java
@@ -20,17 +20,17 @@ public class FileUtilities {
/**
* Unzips a file all into one directory
*
- * @param zipFile
+ * @param inputStream
* @param outputFolder
*/
- public static void unzip(String zipFile, String outputFolder) {
+ public static void unzip(InputStream inputStream, String outputFolder) {
byte[] buffer = new byte[1024];
try {
File folder = new File(outputFolder);
if (!folder.exists()) {
folder.mkdir();
}
- ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));
+ ZipInputStream zis = new ZipInputStream(inputStream);
ZipEntry ze = zis.getNextEntry();
while (ze != null) {