fix mavenized

This commit is contained in:
Branislav Stojkovic
2025-03-11 10:37:21 +01:00
parent fcfecd33cd
commit 0417947289
35 changed files with 131 additions and 162 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10 -10
View File
@@ -47,6 +47,16 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>31.1-jre</version> <version>31.1-jre</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@@ -54,11 +64,6 @@
</dependency> </dependency>
<!-- Local dependencies from lib folder --> <!-- Local dependencies from lib folder -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.diylc.local</groupId> <groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId> <artifactId>app-framework</artifactId>
@@ -74,10 +79,5 @@
<artifactId>java-http-proxy</artifactId> <artifactId>java-http-proxy</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>jettison-1.0.1</artifactId>
<version>1.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
@@ -147,7 +147,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* *
* @param project * @param project
* @param freshStart * @param freshStart
* @param optional file name when loading from a file * @param filename file name when loading from a file
*/ */
void loadProject(Project project, boolean freshStart, String filename); void loadProject(Project project, boolean freshStart, String filename);
@@ -17,12 +17,12 @@
*/ */
package org.diylc.lang; package org.diylc.lang;
import java.io.File; import java.io.*;
import java.io.FileNotFoundException; import java.net.URISyntaxException;
import java.io.IOException; import java.net.URL;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -34,7 +34,7 @@ import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.utils.ResourceLoader; import org.diylc.utils.ResourceUtils;
public class LangUtil { public class LangUtil {
@@ -89,21 +89,17 @@ public class LangUtil {
LOG.info("Loading translation for " + language); LOG.info("Loading translation for " + language);
dict = new HashMap<String, String>(); dict = new HashMap<String, String>();
try { try {
String path = ResourceLoader.getFile(LANG_DIR + File.separator + language + ".txt").getAbsolutePath(); BufferedReader reader = new BufferedReader(new InputStreamReader(
LOG.debug("Loading language file: " + path); (LangUtil.class.getResourceAsStream("/" + LANG_DIR + File.separator + language + ".txt"))));
try (Stream<String> stream = Files.lines( while(reader.ready()) {
Paths.get(path), StandardCharsets.UTF_8)) { String s = reader.readLine();
stream.forEach(s -> { if (s.contains("|")) {
if (s.contains("|")) { String[] parts = s.split("\\|");
String[] parts = s.split("\\|"); if (parts.length == 2)
if (parts.length == 2) dict.put(parts[0].toLowerCase().trim(), parts[1].trim());
dict.put(parts[0].toLowerCase().trim(), parts[1].trim()); } else {
} else { dict.put(s.toLowerCase(), s);
dict.put(s.toLowerCase(), s); }
}
});
} catch (IOException e) {
LOG.error("Error loading language file", e);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error loading language file", e); LOG.error("Error loading language file", e);
@@ -128,9 +124,8 @@ public class LangUtil {
public static List<Language> getAvailableLanguages() { public static List<Language> getAvailableLanguages() {
List<Language> res = new ArrayList<Language>(); List<Language> res = new ArrayList<Language>();
File[] files = ResourceLoader.getFiles(LANG_DIR);
if (files == null) List<File> files = ResourceUtils.getResourceFiles(LANG_DIR);
return res;
try { try {
for (File file : files) { for (File file : files) {
String key = file.getName().replaceFirst("[.][^.]+$", ""); String key = file.getName().replaceFirst("[.][^.]+$", "");
@@ -80,6 +80,7 @@ import org.diylc.core.Project;
import org.diylc.core.Template; import org.diylc.core.Template;
import org.diylc.core.Theme; import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy; import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.IAutoCreator; import org.diylc.core.annotations.IAutoCreator;
import org.diylc.core.gerber.GerberExporter; import org.diylc.core.gerber.GerberExporter;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
@@ -95,6 +96,11 @@ import org.diylc.test.DIYTest;
import org.diylc.test.Snapshot; import org.diylc.test.Snapshot;
import org.diylc.utils.Constants; import org.diylc.utils.Constants;
import org.diylc.utils.ReflectionUtils; import org.diylc.utils.ReflectionUtils;
import org.reflections.Reflections;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import static org.reflections.scanners.Scanners.TypesAnnotated;
/** /**
* The main presenter class, contains core app logic and drawing routines. * The main presenter class, contains core app logic and drawing routines.
@@ -442,21 +448,14 @@ public class Presenter implements IPlugInPort, IConfigListener {
if (componentTypes == null) { if (componentTypes == null) {
LOG.info("Loading component types."); LOG.info("Loading component types.");
componentTypes = new HashMap<String, List<ComponentType>>(); componentTypes = new HashMap<String, List<ComponentType>>();
Reflections reflections = new Reflections(
new ConfigurationBuilder()
.forPackage("org.diylc")
.filterInputsBy(new FilterBuilder().includePackage("org.diylc.components"))
.setScanners(TypesAnnotated));
Set<Class<?>> componentTypeClasses = null; Set<Class<?>> componentTypeClasses = null;
try { try {
componentTypeClasses = Utils.getClasses("org.diylc.components"); componentTypeClasses = reflections.getTypesAnnotatedWith(ComponentDescriptor.class, false);
File libraryFile = new File("library");
if (libraryFile.exists() && libraryFile.isDirectory() && !Utils.isMac()) {
LOG.info("Loading additional library JARs");
try {
List<Class<?>> additionalComponentTypeClasses =
JarScanner.getInstance().scanFolder("library", IDIYComponent.class);
if (additionalComponentTypeClasses != null)
componentTypeClasses.addAll(additionalComponentTypeClasses);
} catch (Exception e) {
LOG.warn("Could not find additional type classes", e);
}
}
for (Class<?> clazz : componentTypeClasses) { for (Class<?> clazz : componentTypeClasses) {
if (!Modifier.isAbstract(clazz.getModifiers()) && IDIYComponent.class.isAssignableFrom(clazz)) { if (!Modifier.isAbstract(clazz.getModifiers()) && IDIYComponent.class.isAssignableFrom(clazz)) {
@@ -1,72 +0,0 @@
/*
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
*
* This file is part of DIYLC.
*
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
package org.diylc.utils;
import java.io.File;
import org.apache.log4j.Logger;
public class ResourceLoader {
private static final Logger LOG = Logger.getLogger(ResourceLoader.class);
public static File[] getFiles(String relativePath) {
String bundlePath;
try {
bundlePath = com.apple.eio.FileManager.getPathToApplicationBundle();
//LOG.debug("Detected OSX bundle path: " + bundlePath);
} catch (Exception e) {
bundlePath = null; // on non-OSX platforms
}
try {
String absolutePath;
if (bundlePath == null)
absolutePath = relativePath;
else
absolutePath = bundlePath + File.separator + "Contents" + File.separator + "Resources" + File.separator + relativePath;
LOG.debug("Looking for files in: " + absolutePath);
File absoluteFile = new File(absolutePath);
return absoluteFile.listFiles();
} catch (Exception e) {
LOG.error("Error while looking for files in: " + relativePath, e);
return null;
}
}
public static File getFile(String relativePath) {
String bundlePath;
try {
bundlePath = com.apple.eio.FileManager.getPathToApplicationBundle();
//LOG.debug("Detected OSX bundle path: " + bundlePath);
} catch (Exception e) {
bundlePath = null; // on non-OSX platforms
}
try {
String absolutePath;
if (bundlePath == null)
absolutePath = relativePath;
else
absolutePath = bundlePath + File.separator + "Contents" + File.separator + "Resources" + File.separator + relativePath;
File absoluteFile = new File(absolutePath);
return absoluteFile;
} catch (Exception e) {
LOG.error("Error while finding file: " + relativePath, e);
return null;
}
}
}
@@ -0,0 +1,38 @@
package org.diylc.utils;
import org.apache.log4j.Logger;
import org.diylc.lang.LangUtil;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class ResourceUtils {
private static final Logger LOG = Logger.getLogger(LangUtil.class);
public static List<File> getResourceFiles(String dir) {
List<File> files = new ArrayList<>();
URL url = LangUtil.class.getResource("/" + dir);
Path path = null;
try {
path = Paths.get(url.toURI());
Files.walk(path, 5).forEach(p -> {
if (!p.toFile().isDirectory()) {
files.add(p.toFile());
}
});
} catch (URISyntaxException e) {
LOG.error("Error loading language file", e);
} catch (IOException e) {
LOG.error("Error loading language file", e);
}
return files;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -188,6 +188,7 @@ Default Font Size
Delete Selection Delete Selection
Description Description
Designation Designation
Deutsch
Diameter Diameter
Dimension Mode Dimension Mode
Directional Directional
@@ -206,6 +207,7 @@ Drag control point(s) of
Drag the mouse over the canvas to place a new Drag the mouse over the canvas to place a new
Draw Standard Draw Standard
Drop Drop
DualPot
Duodecar B12C Duodecar B12C
Duplicate Duplicate
E+ E+
@@ -219,9 +221,11 @@ Electro-Mechanical
Electrode Labels Electrode Labels
Enable Cache Boost Enable Cache Boost
End Arrow End Arrow
English
Enjoying DIYLC? Click here to buy me a coffee :) Enjoying DIYLC? Click here to buy me a coffee :)
Error Error
Error occurred while editing selection. Check the log for details. Error occurred while editing selection. Check the log for details.
Español
Exit Exit
Expand Selection Expand Selection
Explicit Dimensions Explicit Dimensions
@@ -250,6 +254,7 @@ Font Italic
Font Size Font Size
Font Size Override Font Size Override
Four Four
Français
Full Full
Fuse Fuse
G-D-S JFET G-D-S JFET
@@ -306,6 +311,7 @@ Inner 6
Inside Color Inside Color
Integration Integration
Invert Polarity Invert Polarity
Italiano
Label Label
Label Color Label Color
Label Orientation Label Orientation
@@ -358,6 +364,7 @@ Moveable Label
NPN NPN
Name Name
Nand Nand
Nederlands
Negative Negative
New New
New version available New version available
@@ -420,6 +427,7 @@ Pole Pieces
Pole Pieces 1 Pole Pieces 1
Pole Pieces 2 Pole Pieces 2
Poles Poles
Português
Positions Positions
Positive Positive
Power Rating Power Rating
@@ -513,6 +521,7 @@ Source Type
Spacing Spacing
Square Square
Square BR-3 Square BR-3
Srpski
Standard Standard
Start Arrow Start Arrow
Start Recording Start Recording
@@ -533,6 +542,8 @@ Submit a Bug
Suppressor grid Suppressor grid
Switched Switched
Switches Switches
TO-92 w/ 2 Leads
TO-92 w/ 3 Leads
Tab Tab
Tab Border Tab Border
Tabbed Toolbar Tabbed Toolbar
@@ -554,6 +565,7 @@ Tick Width
Ticks Ticks
Timing Timing
Title Title
Title Block
Toolbox Toolbox
Top Top
Top Lead Top Lead
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+30 -35
View File
@@ -77,43 +77,48 @@
<artifactId>pdfbox</artifactId> <artifactId>pdfbox</artifactId>
<version>2.0.27</version> <version>2.0.27</version>
</dependency> </dependency>
<dependency>
<groupId>com.orsonpdf</groupId>
<artifactId>orsonpdf</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>commons-compiler</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>net.java.balloontip</groupId>
<artifactId>balloontip</artifactId>
<version>1.2.4.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>com.guigarage</groupId>
<artifactId>gestures-wrapper</artifactId>
<version>0.2</version>
</dependency>
<!-- Local dependencies from lib folder --> <!-- Local dependencies from lib folder -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.diylc.local</groupId> <groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId> <artifactId>app-framework</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>balloontip-1.2.4.1</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>commons-compiler-3.0.6</artifactId>
<version>1.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.diylc.local</groupId> <groupId>org.diylc.local</groupId>
<artifactId>gerber-writer-api-1.0.0</artifactId> <artifactId>gerber-writer-api-1.0.0</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>gestures-wrapper-0.2</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>janino-3.0.6</artifactId>
<version>1.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.diylc.local</groupId> <groupId>org.diylc.local</groupId>
<artifactId>jar-loader</artifactId> <artifactId>jar-loader</artifactId>
@@ -129,16 +134,6 @@
<artifactId>jep-2.4.1</artifactId> <artifactId>jep-2.4.1</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>jettison-1.0.1</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>orsonpdf-1.8</artifactId>
<version>1.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.diylc.local</groupId> <groupId>org.diylc.local</groupId>
<artifactId>svgSalamander-1.1.2.4</artifactId> <artifactId>svgSalamander-1.1.2.4</artifactId>
@@ -88,7 +88,7 @@ public class DIYLCStarter {
} }
} }
URL url = DIYLCStarter.class.getResource("log4j.properties"); URL url = DIYLCStarter.class.getResource("/log4j.properties");
Properties properties = new Properties(); Properties properties = new Properties();
try { try {
properties.load(url.openStream()); properties.load(url.openStream());
@@ -116,6 +116,7 @@ public class DIYLCStarter {
+ System.getProperty("java.vm.vendor")); + System.getProperty("java.vm.vendor"));
LOG.debug("Java home: " + System.getProperty("java.home")); LOG.debug("Java home: " + System.getProperty("java.home"));
LOG.debug("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version")); LOG.debug("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
// LOG.debug("Classpath: " + System.getProperty("java.class.path"));
// set OS name as HTTP agent, java will append java version // set OS name as HTTP agent, java will append java version
Properties props = System.getProperties(); Properties props = System.getProperties();
@@ -42,7 +42,7 @@ import org.diylc.lang.Language;
import org.diylc.swing.ActionFactory; import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI; import org.diylc.swing.ISwingUI;
import org.diylc.utils.IconLoader; import org.diylc.utils.IconLoader;
import org.diylc.utils.ResourceLoader; import org.diylc.utils.ResourceUtils;
/** /**
* Controls configuration menu. * Controls configuration menu.
@@ -65,6 +65,7 @@ public class ConfigPlugin implements IPlugIn {
private static final String LANGUAGE_MENU = LangUtil.translate("Language"); private static final String LANGUAGE_MENU = LangUtil.translate("Language");
private static final String LANG_RESTART = LangUtil.translate("Language selection will be applied after the application is restarted."); private static final String LANG_RESTART = LangUtil.translate("Language selection will be applied after the application is restarted.");
public static final String THEMES_DIR = "themes";
private ISwingUI swingUI; private ISwingUI swingUI;
@@ -170,8 +171,8 @@ public class ConfigPlugin implements IPlugIn {
ActionFactory.getInstance() ActionFactory.getInstance()
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU); .createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
File[] themeFiles = ResourceLoader.getFiles("themes"); List<File> themeFiles = ResourceUtils.getResourceFiles(THEMES_DIR);
if (themeFiles != null && themeFiles.length > 0) { if (!themeFiles.isEmpty()) {
XStream xStream = new XStream(new DomDriver()); XStream xStream = new XStream(new DomDriver());
xStream.addPermission(AnyTypePermission.ANY); xStream.addPermission(AnyTypePermission.ANY);
swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU); swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU);
+1 -1
View File
@@ -13,7 +13,7 @@ REM Define the group ID for all local dependencies
set GROUP_ID=org.diylc.local set GROUP_ID=org.diylc.local
REM List of module lib directories to process REM List of module lib directories to process
set MODULES=diylc-core diylc-library diylc-swing set MODULES=diylc-swing
echo Processing dependencies... echo Processing dependencies...
echo. echo.
+1 -1
View File
@@ -12,7 +12,7 @@ echo
GROUP_ID="org.diylc.local" GROUP_ID="org.diylc.local"
# List of module lib directories to process # List of module lib directories to process
MODULES=("diylc-core" "diylc-library" "diylc-swing") MODULES=("diylc-swing")
echo "Processing dependencies..." echo "Processing dependencies..."
echo echo