Skip to content

Commit

Permalink
Merge pull request #618 from spacious-team/task-gh-617-no_admin_pass_…
Browse files Browse the repository at this point in the history
…promt

Не запрашивать пароль администратора при установке
  • Loading branch information
vananiev authored Nov 16, 2024
2 parents a2a5cd6 + 7997615 commit 7453979
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
10 changes: 9 additions & 1 deletion docs/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ git clone https://github.com/spacious-team/investbook.git

### Установка Wix
Для сборки пакета для установки Investbook требуется Wix 3.
Скачать Wix 3 можно по ссылке с официального сайта [Wix](https://wixtoolset.org/docs/wix3/)
Скачать Wix 3 можно по ссылке с официального сайта [Wix3](https://wixtoolset.org/docs/wix3/)
(пакет для установки расположен на [GitHub](https://github.com/wixtoolset/wix3/releases)).
Wix в свою очередь потребует установки [.NET](https://dotnet.microsoft.com/en-us/download/dotnet).

На Windows вы можете установить Wix и .NET в `%LOCALAPPDATA%\Programs\wix3` и `%LOCALAPPDATA%\Programs\dotnet`
соответственно. В этом случае добавьте следующие переменные окружения
(win+R -> `rundll32 sysdm.cpl,EditEnvironmentVariables`):
```shell
DOTNET_ROOT=%LOCALAPPDATA%\Programs\dotnet
PATH=<предыдущие значения>;%DOTNET_ROOT%;%LOCALAPPDATA%\Programs\wix3
```

### Компиляция
Компиляция запускается командой:
```
Expand Down
13 changes: 7 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,10 @@
</plugin>
<plugin>
<!-- jpackage requires Wix 3: https://wixtoolset.org/docs/wix3/ (only Wix, Toolset not required) -->
<!-- https://github.panteleyev.org/jpackage-maven-plugin/examples/executions.html-->
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.2.1</version>
<version>1.6.4</version>
<executions>
<execution>
<id>windows installer</id>
Expand All @@ -469,9 +470,8 @@
<appVersion>${win.msi.version}</appVersion>
<vendor>Spacious Team</vendor>
<description>${project.description}</description>
<copyright>InvestBook, Copyright (C) 2020 Spacious Team
(https://github.com/spacious-team)
</copyright>
<copyright>InvestBook, Copyright (C) 2020 Spacious Team</copyright>
<aboutUrl>https://github.com/spacious-team/investbook</aboutUrl>
<mainJar>${project.artifactId}-${project.version}.jar</mainJar>
<javaOptions>
<javaOption>-Dloader.path=./app/extensions</javaOption>
Expand All @@ -489,10 +489,11 @@
<arguments>
<argument>--spring.config.additional-location=file:./app/</argument>
</arguments>
<input>${project.build.directory}/jpackage/jpackage/</input>
<input>${project.build.directory}/jpackage/input</input>
<icon>${project.basedir}/src/main/assembly/jpackage/icon.ico</icon>
<destination>${project.build.directory}/jpackage</destination>
<destination>${project.build.directory}/jpackage/output</destination>
<winDirChooser>true</winDirChooser>
<winPerUserInstall>true</winPerUserInstall>
<winMenu>true</winMenu>
<winMenuGroup>Investbook</winMenuGroup>
<winShortcut>true</winShortcut>
Expand Down
7 changes: 6 additions & 1 deletion src/main/assembly/jpackage/dir.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<formats>
<format>dir</format>
</formats>
<baseDirectory>input</baseDirectory>
<fileSets>
<fileSet>
<directory>src/main/assembly/jpackage</directory>
Expand All @@ -46,13 +47,17 @@
<outputDirectory/>
</file>
<file>
<source>src/main/assembly/zip/extensions/README.md</source>
<source>src/main/assembly/jpackage/extensions/README.md</source>
<outputDirectory>extensions</outputDirectory>
</file>
<file>
<source>README.md</source>
<outputDirectory/>
</file>
<file>
<source>README-en.md</source>
<outputDirectory/>
</file>
<file>
<source>LICENSE</source>
<outputDirectory/>
Expand Down
4 changes: 4 additions & 0 deletions src/main/assembly/zip/zip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<source>README.md</source>
<outputDirectory/>
</file>
<file>
<source>README-en.md</source>
<outputDirectory/>
</file>
<file>
<source>LICENSE</source>
<outputDirectory/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ public class ApplicationFailedRunListener implements ApplicationListener<Applica
public void onApplicationEvent(ApplicationFailedEvent event) {
ConfigurableEnvironment environment = event.getApplicationContext().getEnvironment();
if (environment.getProperty("investbook.open-home-page-after-start", Boolean.class, false)) {
// App is opened by LoadingPageServer started in InvestbookApplication.class
log.info("Application run failed. May be application was run a second time, trying to open the application page...");

try (LoadingPageServer loadingPageServer = new LoadingPageServer()) {
loadingPageServer.start();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@
@UtilityClass
public class LoadingPageServerUtils {

private static final String CONF_PROPERTIES = "application-conf.properties";
private static final String CONF_PROPERTIES = "app/application-conf.properties";
private static final String RESOURCE_CONF_PROPERTIES = "application-conf.properties";

public static int getMainAppPort() {
try {
Properties properties = loadProperties();
String value = properties.getProperty("server.port", "2030");
return Integer.parseInt(value);
} catch (Exception e) {
log.warn("Can't find 'server.port' property, fallback to default value: 2030");
log.warn("Can't find 'server.port' property, fallback to default value: 2030", e);
return 2030;
}
}
Expand All @@ -55,7 +56,7 @@ public static boolean shouldOpenHomePageAfterStart() {
String value = properties.getProperty("investbook.open-home-page-after-start", "true");
return Boolean.parseBoolean(value);
} catch (Exception e) {
log.warn("Can't find 'investbook.open-home-page-after-start' fallback to default value: true");
log.warn("Can't find 'investbook.open-home-page-after-start' fallback to default value: true", e);
return true;
}
}
Expand All @@ -67,7 +68,7 @@ private static Properties loadProperties() throws IOException {
properties.load(reader);
} catch (Exception e) {
// Properties file is not found in app installation path, read default file from class path
try (InputStream in = requireNonNull(LoadingPageServerUtils.class.getResourceAsStream(CONF_PROPERTIES));
try (InputStream in = requireNonNull(LoadingPageServerUtils.class.getResourceAsStream(RESOURCE_CONF_PROPERTIES));
Reader reader = new InputStreamReader(in, UTF_8)) {
properties.load(reader);
}
Expand Down

0 comments on commit 7453979

Please sign in to comment.