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>
<version>31.1-jre</version>
</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>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -54,11 +64,6 @@
</dependency>
<!-- Local dependencies from lib folder -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId>
@@ -74,10 +79,5 @@
<artifactId>java-http-proxy</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>jettison-1.0.1</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
@@ -147,7 +147,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
*
* @param project
* @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);
@@ -17,12 +17,12 @@
*/
package org.diylc.lang;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
@@ -34,7 +34,7 @@ import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort;
import org.diylc.utils.ResourceLoader;
import org.diylc.utils.ResourceUtils;
public class LangUtil {
@@ -89,11 +89,10 @@ public class LangUtil {
LOG.info("Loading translation for " + language);
dict = new HashMap<String, String>();
try {
String path = ResourceLoader.getFile(LANG_DIR + File.separator + language + ".txt").getAbsolutePath();
LOG.debug("Loading language file: " + path);
try (Stream<String> stream = Files.lines(
Paths.get(path), StandardCharsets.UTF_8)) {
stream.forEach(s -> {
BufferedReader reader = new BufferedReader(new InputStreamReader(
(LangUtil.class.getResourceAsStream("/" + LANG_DIR + File.separator + language + ".txt"))));
while(reader.ready()) {
String s = reader.readLine();
if (s.contains("|")) {
String[] parts = s.split("\\|");
if (parts.length == 2)
@@ -101,9 +100,6 @@ public class LangUtil {
} else {
dict.put(s.toLowerCase(), s);
}
});
} catch (IOException e) {
LOG.error("Error loading language file", e);
}
} catch (Exception e) {
LOG.error("Error loading language file", e);
@@ -128,9 +124,8 @@ public class LangUtil {
public static List<Language> getAvailableLanguages() {
List<Language> res = new ArrayList<Language>();
File[] files = ResourceLoader.getFiles(LANG_DIR);
if (files == null)
return res;
List<File> files = ResourceUtils.getResourceFiles(LANG_DIR);
try {
for (File file : files) {
String key = file.getName().replaceFirst("[.][^.]+$", "");
@@ -80,6 +80,7 @@ import org.diylc.core.Project;
import org.diylc.core.Template;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.IAutoCreator;
import org.diylc.core.gerber.GerberExporter;
import org.diylc.core.measures.Size;
@@ -95,6 +96,11 @@ import org.diylc.test.DIYTest;
import org.diylc.test.Snapshot;
import org.diylc.utils.Constants;
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.
@@ -442,21 +448,14 @@ public class Presenter implements IPlugInPort, IConfigListener {
if (componentTypes == null) {
LOG.info("Loading component types.");
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;
try {
componentTypeClasses = Utils.getClasses("org.diylc.components");
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);
}
}
componentTypeClasses = reflections.getTypesAnnotatedWith(ComponentDescriptor.class, false);
for (Class<?> clazz : componentTypeClasses) {
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
Description
Designation
Deutsch
Diameter
Dimension Mode
Directional
@@ -206,6 +207,7 @@ Drag control point(s) of
Drag the mouse over the canvas to place a new
Draw Standard
Drop
DualPot
Duodecar B12C
Duplicate
E+
@@ -219,9 +221,11 @@ Electro-Mechanical
Electrode Labels
Enable Cache Boost
End Arrow
English
Enjoying DIYLC? Click here to buy me a coffee :)
Error
Error occurred while editing selection. Check the log for details.
Español
Exit
Expand Selection
Explicit Dimensions
@@ -250,6 +254,7 @@ Font Italic
Font Size
Font Size Override
Four
Français
Full
Fuse
G-D-S JFET
@@ -306,6 +311,7 @@ Inner 6
Inside Color
Integration
Invert Polarity
Italiano
Label
Label Color
Label Orientation
@@ -358,6 +364,7 @@ Moveable Label
NPN
Name
Nand
Nederlands
Negative
New
New version available
@@ -420,6 +427,7 @@ Pole Pieces
Pole Pieces 1
Pole Pieces 2
Poles
Português
Positions
Positive
Power Rating
@@ -513,6 +521,7 @@ Source Type
Spacing
Square
Square BR-3
Srpski
Standard
Start Arrow
Start Recording
@@ -533,6 +542,8 @@ Submit a Bug
Suppressor grid
Switched
Switches
TO-92 w/ 2 Leads
TO-92 w/ 3 Leads
Tab
Tab Border
Tabbed Toolbar
@@ -554,6 +565,7 @@ Tick Width
Ticks
Timing
Title
Title Block
Toolbox
Top
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>
<version>2.0.27</version>
</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 -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId>
<version>1.0</version>
</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>
<groupId>org.diylc.local</groupId>
<artifactId>gerber-writer-api-1.0.0</artifactId>
<version>1.0</version>
</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>
<groupId>org.diylc.local</groupId>
<artifactId>jar-loader</artifactId>
@@ -129,16 +134,6 @@
<artifactId>jep-2.4.1</artifactId>
<version>1.0</version>
</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>
<groupId>org.diylc.local</groupId>
<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();
try {
properties.load(url.openStream());
@@ -116,6 +116,7 @@ public class DIYLCStarter {
+ System.getProperty("java.vm.vendor"));
LOG.debug("Java home: " + System.getProperty("java.home"));
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
Properties props = System.getProperties();
@@ -42,7 +42,7 @@ import org.diylc.lang.Language;
import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
import org.diylc.utils.IconLoader;
import org.diylc.utils.ResourceLoader;
import org.diylc.utils.ResourceUtils;
/**
* 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 LANG_RESTART = LangUtil.translate("Language selection will be applied after the application is restarted.");
public static final String THEMES_DIR = "themes";
private ISwingUI swingUI;
@@ -170,8 +171,8 @@ public class ConfigPlugin implements IPlugIn {
ActionFactory.getInstance()
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
File[] themeFiles = ResourceLoader.getFiles("themes");
if (themeFiles != null && themeFiles.length > 0) {
List<File> themeFiles = ResourceUtils.getResourceFiles(THEMES_DIR);
if (!themeFiles.isEmpty()) {
XStream xStream = new XStream(new DomDriver());
xStream.addPermission(AnyTypePermission.ANY);
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
REM List of module lib directories to process
set MODULES=diylc-core diylc-library diylc-swing
set MODULES=diylc-swing
echo Processing dependencies...
echo.
+1 -1
View File
@@ -12,7 +12,7 @@ echo
GROUP_ID="org.diylc.local"
# List of module lib directories to process
MODULES=("diylc-core" "diylc-library" "diylc-swing")
MODULES=("diylc-swing")
echo "Processing dependencies..."
echo