Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Не запрашивать пароль администратора при установке #618

Merged
merged 5 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

Check warning on line 48 in src/main/java/ru/investbook/loadingpage/LoadingPageServerUtils.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/ru/investbook/loadingpage/LoadingPageServerUtils.java#L48

Added line #L48 was not covered by tests
return 2030;
}
}
Expand All @@ -55,7 +56,7 @@
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);

Check warning on line 59 in src/main/java/ru/investbook/loadingpage/LoadingPageServerUtils.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/ru/investbook/loadingpage/LoadingPageServerUtils.java#L59

Added line #L59 was not covered by tests
return true;
}
}
Expand All @@ -67,7 +68,7 @@
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));

Check warning on line 71 in src/main/java/ru/investbook/loadingpage/LoadingPageServerUtils.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/ru/investbook/loadingpage/LoadingPageServerUtils.java#L71

Added line #L71 was not covered by tests
Reader reader = new InputStreamReader(in, UTF_8)) {
properties.load(reader);
}
Expand Down