Skip to content

Commit fb77695

Browse files
authored
Merge pull request #195 from pwgit-create/develop
Version 2.1
2 parents 798e36a + aaa90b4 commit fb77695

18 files changed

Lines changed: 132 additions & 37 deletions

File tree

AppWish/AppWish/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>pn.dev</groupId>
55
<artifactId>code-generator-gui-ollama</artifactId>
66
<name>CodeGenerator-GUI</name>
7-
<version>2.0.5</version>
7+
<version>2.1</version>
88
<description>The GUI interface for the pn.dev.code-generator-ollama library</description>
99
<inceptionYear>2024</inceptionYear>
1010
<developers>

AppWish/AppWish/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>pn.dev</groupId>
77
<artifactId>code-generator-gui-ollama</artifactId>
8-
<version>2.0.5</version>
8+
<version>2.1</version>
99
<name>CodeGenerator-GUI</name>
1010

1111

@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>pn.dev</groupId>
5454
<artifactId>code-generator-ollama</artifactId>
55-
<version>2.0.5</version>
55+
<version>2.1</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>org.openjfx</groupId>

AppWish/AppWish/src/main/java/pn/app_wish/constant/AboutConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
public record AboutConstants() {
55

6-
private static final String APP_WISH_VERSION = "Appwish Enterprise 2.0.5";
7-
private static final String ABOUT_APP_WISH = "AppWish (2) is a open source project that creates Java applications from text input with the help of AI models";
6+
private static final String APP_WISH_VERSION = "Appwish Enterprise 2.1";
7+
private static final String ABOUT_APP_WISH = "AppWish 2 is a open source project that creates Java applications from text input with the help of AI models";
88
private static final String DEVELOPED_BY = "Pwgit-Create / Peter Westin";
99
private static final String CONTACT = "\nEmail: snow_900@outlook.com";
1010
private static final String LINK_TO_DISCUSSION = "https://github.com/pwgit-create/APPWISH_OLLAMA/discussions";

AppWish/AppWish/src/main/java/pn/app_wish/constant/StaticAppWishConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
public record StaticAppWishConstants() {
44
public static final String BASH_PATH = "/bin/bash";
55
public static final String C_ARGUMENT = "-c";
6+
public static final String CP_ARGUMENT="-cp ";
67
public static final String JAVA_TEXT = "java ";
78

9+
public static final String CP_PATH= ".:external_libs/* " ;
10+
811

912
public static final String MAIN_TEXT="Main";
1013
public static final String MAIN_DOT_JAVA="Main.java";

AppWish/AppWish/src/main/java/pn/app_wish/controller/AppHistoryController.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import pn.app_wish.AppWish;
1818
import pn.app_wish.constant.AboutConstants;
1919
import pn.app_wish.constant.GUIConstants;
20-
import pn.app_wish.constant.StaticAppWishConstants;
20+
21+
import pn.app_wish.model.AppCmd;
2122
import pn.app_wish.util.AppWishUtil;
2223
import pn.cg.datastorage.constant.PathConstants;
2324

@@ -26,7 +27,7 @@
2627
import java.net.URL;
2728

2829
import java.nio.file.Files;
29-
import java.nio.file.Path;
30+
3031
import java.util.*;
3132
import java.util.stream.Collectors;
3233

@@ -85,7 +86,8 @@ private void handleSelectButtonAction(ActionEvent ae) {
8586
final String r2 = ".java";
8687
final String executePath = selectedFile.getAbsolutePath().replace(r1, r2);
8788

88-
processBuilder = new ProcessBuilder(BASH_PATH, C_ARGUMENT, JAVA_TEXT + executePath);
89+
90+
processBuilder = new ProcessBuilder(new AppCmd(executePath).GetCMDForRunningApp_Application());
8991
executingJavaAppProcess = processBuilder.inheritIO().start();
9092
} catch (IOException e) {
9193
System.out.println("RuntimeException while starting Java executable");
@@ -195,7 +197,7 @@ private void deleteJavaApp(File classFileOfApplication) {
195197
try {
196198

197199
// Delete the Class File of the chosen application
198-
Files.delete(classFileOfApplication.toPath());
200+
Files.deleteIfExists(classFileOfApplication.toPath());
199201
log.info("The class file of your selected application has been deleted");
200202
} catch (IOException e) {
201203

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
package pn.app_wish.model;
2+
23
import pn.app_wish.constant.StaticAppWishConstants;
4+
import pn.app_wish.util.AppWishUtil;
5+
36

47
public record AppCmd(String javaExecutablePath) {
58

69
public final String[] GetCMDForRunningApp_Application() {
710

8-
return new String[]{StaticAppWishConstants.BASH_PATH,StaticAppWishConstants.C_ARGUMENT, StaticAppWishConstants.JAVA_TEXT + javaExecutablePath};
11+
boolean isExternalLibraries = AppWishUtil.isExternalLibrariesBeingUsed();
12+
if (isExternalLibraries) {
13+
return new String[]{StaticAppWishConstants.BASH_PATH, StaticAppWishConstants.C_ARGUMENT, StaticAppWishConstants.JAVA_TEXT + StaticAppWishConstants.CP_ARGUMENT + StaticAppWishConstants.CP_PATH + javaExecutablePath};
14+
15+
} else {
16+
return new String[]{StaticAppWishConstants.BASH_PATH, StaticAppWishConstants.C_ARGUMENT, StaticAppWishConstants.JAVA_TEXT + javaExecutablePath};
17+
18+
}
919
}
1020
}

AppWish/AppWish/src/main/java/pn/app_wish/util/AppWishUtil.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package pn.app_wish.util;
22

3+
import pn.cg.datastorage.CodeGeneratorConfig;
34
import pn.cg.datastorage.DataStorage;
45
import pn.cg.datastorage.constant.PathConstants;
56

@@ -80,5 +81,20 @@ public final static void deleteTmpCodeBaseFiles(){
8081
}
8182
});
8283
}}
84+
85+
/**
86+
* See if external libraries are used or not. Will also create a new CodeGenerator config
87+
* in case no code generation has occurred in the session previously
88+
* @return boolean
89+
*/
90+
public final static boolean isExternalLibrariesBeingUsed(){
91+
92+
if(DataStorage.getInstance().getCodeGeneratorConfig() == null) {
93+
final CodeGeneratorConfig codeGeneratorConfig = new CodeGeneratorConfig();
94+
DataStorage.getInstance().setCodeGeneratorConfig(codeGeneratorConfig);}
95+
96+
return DataStorage.getInstance().getCodeGeneratorConfig().isUSE_EXTERNAL_LIBRARIES();
8397
}
8498

99+
}
100+

AppWish/AppWish/src/main/resources/config.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ NUM_CTX=2048
22
TOP_K=40
33
NUM_PREDICT=-1
44
TEMPERATURE=0.8
5+
USE_EXTERNAL_LIBRARIES=off
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
javac -cp .:external_libs/* $1 2>&1 | tee
3+

cg/CodeGenerator/CodeGenerator/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>pn.dev</groupId>
55
<artifactId>code-generator-ollama</artifactId>
6-
<version>2.0.5</version>
6+
<version>2.1</version>
77
<description>The Java Application-Generator (pn.dev.code-generator-ollama) creates applications by giving a string of your desired features for a Java application, like this: AppSystem.StartCodeGenerator(String appWish)</description>
88
<inceptionYear>2024</inceptionYear>
99
<developers>

0 commit comments

Comments
 (0)