")
17 | File dllFileInApp = new File(appDir, dllname)
18 | dllFileInApp.exists()
19 |
20 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
21 | }
22 |
23 | public String testProjectDir() {
24 | return "23-invocation-dynamic-library"
25 | }
26 |
27 | @Override
28 | protected String projectName() {
29 | return "HelloDll"
30 | }
31 |
32 | @Override
33 | protected String projectVersion() {
34 | return "1.0-SNAPSHOT"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/WindowsVersionInfoFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | @IgnoreIf({!windowsVersionInfoSupported})
7 | class WindowsVersionInfoFunTest extends BaseFunTest implements HelloWorldProject {
8 |
9 | def "jetBuild task builds simple application with windows version info"() {
10 | when:
11 | def versionRes = new File(basedir, "build/jet/build/HelloWorld_jetpdb/version.rc");
12 | def result = runGradle('jetBuild')
13 |
14 | then:
15 | versionRes.exists()
16 | String versionResText = versionRes.text;
17 | versionResText.contains("MyCompany")
18 | versionResText.contains("MyProduct")
19 | versionResText.contains("4.3.2.1")
20 | versionResText.contains("MyCopyright")
21 | versionResText.contains("My description")
22 |
23 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
24 | }
25 |
26 | String testProjectDir() {
27 | return "28-windows-version-info"
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/HelloSwingFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class HelloSwingFunTest extends BaseFunTest {
6 |
7 | def "jetBuild task builds simple swing application"() {
8 | when:
9 | def result = runGradle('jetBuild')
10 |
11 | then:
12 | buildExeFile.exists()
13 | appExeFile.exists()
14 | zipFile.exists()
15 |
16 | !isWindows || new File(basedir, "build/jet/build/HelloSwing_jetpdb/HelloSwing.rsp").text.contains("icon.ico")
17 | !isWindows || new File(basedir, "build/jet/build/HelloSwing_jetpdb/HelloSwing.rsp").text.contains("-sys=W")
18 |
19 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
20 | }
21 |
22 |
23 | @Override
24 | protected String testProjectDir() {
25 | return "03-helloswing"
26 | }
27 |
28 | @Override
29 | protected String projectName() {
30 | return "HelloSwing"
31 | }
32 |
33 | @Override
34 | protected String projectVersion() {
35 | return "1.0-SNAPSHOT"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/resources/44-spring-boot/src/main/java/sample/tomcat/service/HelloWorldService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2013 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package sample.tomcat.service;
18 |
19 | import org.springframework.beans.factory.annotation.Value;
20 | import org.springframework.stereotype.Component;
21 |
22 | @Component
23 | public class HelloWorldService {
24 |
25 | @Value("${name:World}")
26 | private String name;
27 |
28 | public String getHelloMessage() {
29 | return "Hello " + this.name;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/resources/34-tomcat-port/src/main/java/HelloServlet.java:
--------------------------------------------------------------------------------
1 | import java.io.IOException;
2 | import java.io.StringReader;
3 | import java.lang.System;
4 |
5 | import javax.servlet.http.HttpServlet;
6 | import javax.servlet.ServletException;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 |
10 | import java.io.IOException;
11 | import java.io.PrintWriter;
12 |
13 | public class HelloServlet extends HttpServlet {
14 |
15 | protected void doGet(HttpServletRequest request,
16 | HttpServletResponse response) throws ServletException, IOException {
17 | // Very simple - just return some plain text
18 | response.setContentType("text/html");
19 | PrintWriter writer = response.getWriter();
20 | writer.println("\n" +
22 | "\n" +
23 | "Hello World\n" +
24 | "\n" +
25 | "Hello World!
\n" +
26 | "");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/resources/40-regression-excelsior-installer-no-shortcut-icon/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | apply plugin: "java"
13 | group = "com.excelsior.it"
14 | version = "1.0-SNAPSHOT"
15 |
16 | apply plugin: 'excelsiorJet'
17 | excelsiorJet {
18 | mainClass = 'HelloWorld'
19 | packaging = 'excelsior-installer'
20 | excelsiorInstaller {
21 | shortcuts {
22 | shortcut {
23 | location = "program-folder"
24 | target = "README.txt"
25 | name = "Read me first"
26 | }
27 | }
28 | fileAssociations {
29 | fileAssociation {
30 | extension = "abc"
31 | target = "HelloWorld.exe"
32 | description = "ABC Files"
33 | targetDescription = "Super Duper Program"
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/TomcatPortFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import spock.lang.IgnoreIf
4 |
5 | class TomcatPortFunTest extends BaseFunTest {
6 |
7 | @IgnoreIf({!tomcatSupported || !excelsiorInstallerSupported || !since11_3})
8 | def "test tomcat port"() {
9 | given:
10 | File installer = new File(basedir, "build/jet/${projectName()}-" + projectVersion() + ext)
11 | File xpackArgsFile = new File(basedir, "build/jet/build/HelloTomcat.EI.xpack")
12 |
13 | when:
14 | runGradle("clean", "war", "jetBuild")
15 |
16 | then:
17 | new File(appDir, "bin/HelloTomcat$ext").exists()
18 | installer.exists()
19 | xpackArgsFile.text.contains("-allow-user-to-change-tomcat-port")
20 | }
21 |
22 | @Override
23 | protected String testProjectDir() {
24 | return "34-tomcat-port"
25 | }
26 |
27 | @Override
28 | protected String projectName() {
29 | return "HelloTomcat"
30 | }
31 |
32 | @Override
33 | protected String projectVersion() {
34 | return "1.0-SNAPSHOT"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/ExcelsiorInstallerFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class ExcelsiorInstallerFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!excelsiorInstallerSupported})
9 | def "jetBuild task builds simple swing application and packs it with excelsior installer"() {
10 | setup:
11 | File installer = new File(basedir, "build/jet/HelloSwing-1.2.3-SNAPSHOT" + ext)
12 |
13 | when:
14 | def result = runGradle('jetBuild')
15 |
16 | then:
17 | buildExeFile.exists()
18 | appExeFile.exists()
19 | installer.exists();
20 |
21 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
22 | }
23 |
24 | @Override
25 | protected String testProjectDir() {
26 | return "04-excelsior-installer"
27 | }
28 |
29 | @Override
30 | protected String projectName() {
31 | return "HelloSwing"
32 | }
33 |
34 | @Override
35 | protected String projectVersion() {
36 | return "1.2.3-SNAPSHOT"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/MultiAppRunArgsFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class MultiAppRunArgsFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | @IgnoreIf({crossCompilation || !multiAppSupported})
9 | def "multiAppRunArgs is passed to startup accelerator and run"() {
10 | when:
11 | def result = runGradle('jetBuild', 'jetRun')
12 |
13 | then:
14 | buildExeFile.exists()
15 | appExeFile.exists()
16 |
17 | !result.output.contains("No arguments specified")
18 | !result.output.contains("The application has terminated with exit code: 3")
19 | result.output.contains("The application has terminated with exit code: 0")
20 | result.output.contains("0: arg1")
21 | result.output.contains("1: arg2.1, arg2.2")
22 |
23 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
24 | result.task(":jetRun").outcome == TaskOutcome.SUCCESS
25 | }
26 |
27 | public String testProjectDir() {
28 | return "38-multiapp-run-arguments"
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/resources/25-windows-service-multiapp-with-excelsior-installer/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | apply plugin: "java"
13 | group = "com.excelsior.it"
14 | version = "1.0-SNAPSHOT"
15 |
16 | apply plugin: 'excelsiorJet'
17 | excelsiorJet {
18 | appType = "windows-service"
19 | mainClass = "SampleService"
20 | multiApp = true
21 | hideConsole = true
22 | windowsService {
23 | displayName = "Sample Service"
24 | description = "Sample Service created with Excelsior JET"
25 | arguments = ["-args", "arg", "arg with space", "arg3 with space"]
26 | logOnType = "user-account"
27 | startupType = "manual"
28 | dependencies = ["Dhcp", "Dnscache"]
29 | }
30 | packaging = "excelsior-installer"
31 | }
32 |
33 | repositories {
34 | mavenCentral()
35 | }
36 |
37 | dependencies {
38 | compileOnly "com.excelsiorjet:excelsior-jet-winservice-api:1.0.0"
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/resources/45-spring-boot-war/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | plugins {
13 | id 'org.springframework.boot' version '2.0.4.RELEASE'
14 | }
15 | group = "com.excelsior.it"
16 | version = "1.0-SNAPSHOT"
17 |
18 | apply plugin: "war"
19 | apply plugin: "org.springframework.boot"
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | compile "org.springframework.boot:spring-boot-starter:2.0.4.RELEASE"
27 | compile "org.springframework.boot:spring-boot-starter-web:2.0.4.RELEASE"
28 | }
29 |
30 |
31 | apply plugin: 'excelsiorJet'
32 | excelsiorJet {
33 | appType = "spring-boot"
34 | compilerOptions = ["+baselineall"]
35 | dependencies {
36 | dependency {
37 | artifactId = 'spring-boot-sample-war'
38 | pack = 'all'
39 | }
40 | dependency {
41 | artifactId = "spring-webmvc"
42 | protect = "not-required"
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/OptRtFilesFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class OptRtFilesFunTest extends BaseFunTest implements HelloWorldProject {
6 |
7 | def "test additional RT-files"() {
8 | setup:
9 | File optRtJar = new File(basedir, "build/jet/app/rt/lib/ext/nashorn.jar")
10 |
11 | when:
12 | def result = runGradle('jetBuild')
13 | // should be in when, because requires directory created while run
14 |
15 | then:
16 | buildExeFile.exists()
17 | appExeFile.exists()
18 | zipFile.exists()
19 |
20 | ["build/jet/app/rt/bin/jfxwebkit.dll",
21 | "build/jet/app/rt/lib/libjfxwebkit.dylib",
22 | "build/jet/app/rt/lib/amd64/libjfxwebkit.so",
23 | "build/jet/app/rt/lib/i386/libjfxwebkit.so",
24 | "build/jet/app/rt/lib/arm/libjfxwebkit.so"].any { new File(basedir, it).exists()}
25 |
26 | optRtJar.exists()
27 |
28 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
29 | }
30 |
31 | @Override
32 | protected String testProjectDir() {
33 | return "08-optrtfiles"
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/PGOFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class PGOFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | @IgnoreIf({!PGOSupported || crossCompilation})
9 | def "pgo test"() {
10 | when:
11 | def zipFile = new File(basedir, "build/jet/${projectName()}" + ".zip")
12 | def appToProfileExeFile = new File(basedir, "build/jet/appToProfile/${projectName()}$ext")
13 | def execProfile = new File( basedir, "src/main/jetresources/Test.jprof");
14 | def result = runGradle('jetProfile', 'jetBuild')
15 |
16 | then:
17 | buildExeFile.exists()
18 | appToProfileExeFile.exists()
19 | execProfile.exists()
20 | appExeFile.exists()
21 | zipFile.exists()
22 |
23 | result.task(":jetProfile").outcome == TaskOutcome.SUCCESS
24 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
25 | }
26 |
27 | @Override
28 | String projectName() {
29 | return "Test"
30 | }
31 |
32 | public String testProjectDir() {
33 | return "36-pgo"
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/ExcelsiorInstallerAdvancedFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class ExcelsiorInstallerAdvancedFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!excelsiorInstallerSupported})
9 | def boolean "jetBuild task builds simple swing application and packs it with excelsior installer with cyrillic eula and splash in custom location"() {
10 | setup:
11 | File installer = new File(basedir, "build/jet/HelloSwing-1.2.3-SNAPSHOT" + ext)
12 |
13 | when:
14 | def result = runGradle('jetBuild')
15 |
16 | then:
17 | buildExeFile.exists()
18 | appExeFile.exists()
19 | installer.exists();
20 |
21 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
22 | }
23 |
24 | @Override
25 | protected String testProjectDir() {
26 | return "05-excelsior-installer-advanced"
27 | }
28 |
29 | @Override
30 | protected String projectName() {
31 | return "HelloSwing"
32 | }
33 |
34 | @Override
35 | protected String projectVersion() {
36 | return "1.2.3-SNAPSHOT"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/JvmArgsFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import spock.lang.IgnoreIf
4 |
5 | class JvmArgsFunTest extends BaseFunTest implements HelloWorldProject {
6 |
7 | @IgnoreIf({crossCompilation})
8 | def "test jvm args configuration"() {
9 | setup:
10 | def runOutBuildFile = new File(basedir, "build/jet/build/run.out")
11 | def rtPathBuild = new File(basedir, "build/jet/build/rt").getAbsolutePath()
12 |
13 | def runOutAppFile = new File(appDir, "run.out")
14 | def rtPathApp = new File(appDir, "rt").getAbsolutePath()
15 |
16 | when:
17 | runGradle("clean", "jetTestRun", "jetBuild")
18 | appExeFile.getAbsolutePath().execute([], appDir).waitForOrKill(2000)
19 |
20 | then:
21 | runOutBuildFile.text.replace("/",File.separator).trim().equals(rtPathBuild)
22 | runOutAppFile.text.replace("/",File.separator).trim().equals(rtPathApp)
23 |
24 | appExeFile.exists()
25 | }
26 |
27 | @Override
28 | protected String testProjectDir() {
29 | return "12-jvmargs"
30 | }
31 |
32 | @Override
33 | String projectName() {
34 | return "JVMArgs"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/PackageFilesFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class PackageFilesFunTest extends BaseFunTest implements HelloWorldProject {
6 |
7 | def "test package files"() {
8 | when:
9 | def result = (!crossCompilation) ? runGradle('jetTestRun', 'jetBuild') : runGradle('jetBuild')
10 |
11 | then:
12 | buildExeFile.exists()
13 | appExeFile.exists()
14 | zipFile.exists()
15 |
16 | if (!crossCompilation) {
17 | new File(basedir, "build/jet/build/customfiles/custom.file").exists()
18 | new File(basedir, "build/jet/build/subdir/subdir.file").exists()
19 | }
20 | new File(basedir, "build/jet/app/customfiles/custom.file").exists()
21 | new File(basedir, "build/jet/app/subdir/subdir.file").exists()
22 |
23 | if (!crossCompilation) {
24 | result.task(":jetTestRun").outcome == TaskOutcome.SUCCESS
25 | }
26 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | @Override
30 | protected String testProjectDir() {
31 | return "31-package-files"
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/TestRunFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class TestRunFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | @IgnoreIf({crossCompilation})
9 | def "executes test run for project"() {
10 | setup:
11 | File startupProfile = new File( basedir, "src/main/jetresources/HelloWorld.startup");
12 | File reorderFile = new File(basedir, "build/jet/build/HelloWorld_jetpdb/reorder.li")
13 |
14 | when:
15 | def result = runGradle('jetTestRun', 'jetBuild')
16 |
17 | then:
18 | if (startupProfileGenerationSupported) {
19 | startupProfile.exists()
20 | reorderFile.exists();
21 | new File(basedir, "build/jet/build/custom.file").exists()
22 | new File(basedir, "build/jet/build/subdir/subdir.file").exists()
23 | }
24 |
25 | result.task(":jetTestRun").outcome == TaskOutcome.SUCCESS
26 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | @Override
30 | protected String testProjectDir() {
31 | return "07-testrun"
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/CustomResourcesFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class CustomResourcesFunTest extends BaseFunTest implements HelloWorldProject {
6 |
7 | def "test custom resources"() {
8 | when:
9 | def result = (!crossCompilation) ? runGradle('jetTestRun', 'jetBuild') : runGradle('jetBuild')
10 |
11 | then:
12 | buildExeFile.exists()
13 | appExeFile.exists()
14 | zipFile.exists()
15 |
16 | if (!crossCompilation) {
17 | new File(basedir, "build/jet/build/customfiles/custom.file").exists()
18 | new File(basedir, "build/jet/build/customfiles/subdir/subdir.file").exists()
19 | }
20 | new File(basedir, "build/jet/app/custom.file").exists()
21 | new File(basedir, "build/jet/app/subdir/subdir.file").exists()
22 |
23 | if (!crossCompilation) {
24 | result.task(":jetTestRun").outcome == TaskOutcome.SUCCESS
25 | }
26 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | @Override
30 | protected String testProjectDir() {
31 | return "10-customresources"
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/RunArgsFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class RunArgsFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | @IgnoreIf({crossCompilation})
9 | def "runArgs is passed to startup accelerator and test runs"() {
10 | when:
11 | def result = runGradle('jetTestRun', 'jetBuild', 'jetRun')
12 |
13 | then:
14 | buildExeFile.exists()
15 | appExeFile.exists()
16 | zipFile.exists()
17 |
18 | !result.output.contains("No arguments specified")
19 | !result.output.contains("The application has terminated with exit code: 3")
20 | result.output.contains("The application has terminated with exit code: 0")
21 | result.output.contains("0: arg1")
22 | result.output.contains("1: arg2.1, arg2.2")
23 |
24 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
25 | result.task(":jetTestRun").outcome == TaskOutcome.SUCCESS
26 | result.task(":jetRun").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | public String testProjectDir() {
30 | return "19-run-arguments"
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/StopTaskFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class StopTaskFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | protected static final String gradleExec = System.getProperty("gradle.exec")
9 |
10 | @IgnoreIf({crossCompilation || (gradleExec == null) || !PGOSupported})
11 | def "stops test run, profile, run tasks "() {
12 | setup:
13 |
14 | when:
15 | def result = runGradle("jetTestRun", "jetProfile", "jetBuild", "jetRun", "-Dgradle.exec=" + gradleExec)
16 |
17 | then:
18 | result.task(":jetTestRun").outcome == TaskOutcome.SUCCESS
19 | result.task(":jetProfile").outcome == TaskOutcome.SUCCESS
20 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
21 | result.task(":jetRun").outcome == TaskOutcome.SUCCESS
22 | !(new File(basedir, "build/jet/build/failed").exists())
23 | !(new File(basedir, "build/jet/app/failed").exists())
24 | !(new File(basedir, "build/jet/appToPofile/failed").exists())
25 | }
26 |
27 | @Override
28 | protected String testProjectDir() {
29 | return "46-stop-task"
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/funTests.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Configuration required to execute functional tests from gradle and IDE
3 | */
4 |
5 | test {
6 | systemProperty 'excelsiorJetPluginVersion', version
7 | systemProperty 'jet.home', System.properties['jet.home']
8 | systemProperty 'tomcat.home', System.properties['tomcat.home']
9 | systemProperty 'gradle.exec', System.properties['gradle.exec']
10 | testLogging {
11 | events "started", "passed", "skipped", "failed"//, "standardOut", "standardError"
12 | info {
13 | showStandardStreams = true
14 | }
15 | }
16 | }
17 |
18 | // put plugin into maven local before tests, so it's become available for tests
19 | test.dependsOn(install)
20 |
21 | // Need to debug plugin from IDE
22 | // Write the plugin's classpath to a file to share with the tests
23 | task createClasspathManifest {
24 | def outputDir = file("$buildDir/$name")
25 |
26 | inputs.files sourceSets.main.runtimeClasspath
27 | outputs.dir outputDir
28 |
29 | doLast {
30 | outputDir.mkdirs()
31 | file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
32 | }
33 | }
34 | // Add the classpath file to the test runtime classpath
35 | dependencies {
36 | testRuntime files(createClasspathManifest)
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/resources/44-spring-boot/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | plugins {
13 | id 'org.springframework.boot' version '2.0.4.RELEASE'
14 | }
15 | group = "com.excelsior.it"
16 | version = "1.0-SNAPSHOT"
17 |
18 | apply plugin: "java"
19 | apply plugin: "org.springframework.boot"
20 |
21 | repositories {
22 | mavenCentral()
23 | }
24 |
25 | dependencies {
26 | compile "org.springframework.boot:spring-boot-starter:2.0.4.RELEASE"
27 | compile "org.springframework.boot:spring-boot-starter-tomcat:2.0.4.RELEASE"
28 | compile "org.springframework:spring-webmvc:5.0.8.RELEASE"
29 | }
30 |
31 |
32 | apply plugin: 'excelsiorJet'
33 | excelsiorJet {
34 | appType = "spring-boot"
35 | compilerOptions = ["+baselineall"]
36 | dependencies {
37 | dependency {
38 | artifactId = 'spring-boot-sample-tomcat'
39 | pack = 'none'
40 | }
41 | dependency {
42 | artifactId = "spring-webmvc"
43 | protect = "not-required"
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/RunArgsViaSysPropsFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class RunArgsViaSysPropsFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | @IgnoreIf({crossCompilation})
9 | def "runArgs is passed to startup accelerator and test runs via sys props"() {
10 | when:
11 | System.properties["jet.runArgs"] = "arg1,arg2.1\\, arg2.2"
12 | def result = runGradle('jetTestRun', 'jetBuild')
13 |
14 | then:
15 | buildExeFile.exists()
16 | appExeFile.exists()
17 | zipFile.exists()
18 |
19 | !result.output.contains("No arguments specified")
20 | !result.output.contains("The application has terminated with exit code: 3")
21 | result.output.contains("The application has terminated with exit code: 0")
22 | result.output.contains("0: arg1")
23 | result.output.contains("1: arg2.1, arg2.2")
24 |
25 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
26 | result.task(":jetTestRun").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | public String testProjectDir() {
30 | return "20-run-arguments-via-system-props"
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/AppWithTransDepFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class AppWithTransDepFunTest extends BaseFunTest {
6 |
7 | def "jetBuild task builds simple application with transitive dependency"() {
8 | setup:
9 | File dep = new File(basedir, "build/jet/build/AppWithDep_jetpdb/tmpres/jackson-databind-2.8.0__1.jar")
10 | File transDep = new File(basedir, "build/jet/build/AppWithDep_jetpdb/tmpres/jackson-core-2.8.0__3.jar")
11 |
12 | when:
13 | def result = runGradle('jetBuild')
14 |
15 | then:
16 | buildExeFile.exists()
17 | appExeFile.exists()
18 | zipFile.exists()
19 | dep.exists()
20 | transDep.exists()
21 |
22 | checkStdOutContains("field1", appExeFile)
23 |
24 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
25 | }
26 |
27 |
28 | @Override
29 | protected String testProjectDir() {
30 | return "16-with-transitive-dependency"
31 | }
32 |
33 | @Override
34 | protected String projectName() {
35 | return "AppWithDep"
36 | }
37 |
38 | @Override
39 | protected String projectVersion() {
40 | return "1.0-SNAPSHOT"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/resources/15-hellotomcat/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | apply plugin: "war"
13 | group = "com.excelsior.it"
14 | version = "1.0-SNAPSHOT"
15 |
16 | apply plugin: 'excelsiorJet'
17 | excelsiorJet {
18 | tomcat {
19 | warDeployName = "ROOT"
20 | hideConfig = false
21 | genScripts = false
22 | }
23 | windowsService {
24 | description = "Jet Compiled Tomcat"
25 | }
26 | optimizationPreset = "smart"
27 | dependencies {
28 | dependency {
29 | artifactId = 'commons-io'
30 | pack = 'all'
31 | }
32 | dependency {
33 | artifactId = "HelloTomcat"
34 | protect = "not-required"
35 | }
36 | }
37 | packaging = "excelsior-installer"
38 | pdb {
39 | keepInBuildDir = true
40 | }
41 | }
42 |
43 | repositories {
44 | mavenCentral()
45 | }
46 |
47 | dependencies {
48 | compileOnly "javax.servlet:javax.servlet-api:3.0.1"
49 | compile "org.apache.commons:commons-io:1.3.2"
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/ProfileNotLocallyFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class ProfileNotLocallyFunTest extends BaseFunTest implements HelloWorldProject {
7 |
8 | @IgnoreIf({!PGOSupported})
9 | def "profile not locally test"() {
10 | when:
11 | def appToProfileZipFile = new File(basedir, "build/jet/appToProfile.zip")
12 | def appToProfileDir = new File(basedir, "build/jet/appToProfile")
13 | def appToProfileExeFile = new File(appToProfileDir, "${projectName()}$ext")
14 | def execProfile = new File( appToProfileDir, "Test.jprof");
15 | def result = runGradle('jetProfile')
16 |
17 | then:
18 | appToProfileZipFile.exists()
19 | appToProfileExeFile.exists()
20 |
21 | if (!crossCompilation) {
22 | appToProfileExeFile.getAbsolutePath().execute(null, appToProfileDir).text.contains("Time:")
23 | execProfile.exists()
24 | }
25 |
26 | result.task(":jetProfile").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | @Override
30 | String projectName() {
31 | return "Test"
32 | }
33 |
34 | public String testProjectDir() {
35 | return "37-profile-not-locally"
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/resources/44-spring-boot/src/main/java/sample/tomcat/web/SampleController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2016 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package sample.tomcat.web;
18 |
19 | import sample.tomcat.service.HelloWorldService;
20 |
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Controller;
23 | import org.springframework.web.bind.annotation.GetMapping;
24 | import org.springframework.web.bind.annotation.ResponseBody;
25 |
26 | @Controller
27 | public class SampleController {
28 |
29 | @Autowired
30 | private HelloWorldService helloWorldService;
31 |
32 | @GetMapping("/")
33 | @ResponseBody
34 | public String helloWorld() {
35 | return this.helloWorldService.getHelloMessage();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/AppWithDepFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class AppWithDepFunTest extends BaseFunTest {
6 |
7 | def "jetBuild task builds simple application with dependency"() {
8 | setup:
9 | File prj = new File(basedir, "build/jet/build/AppWithDep.prj")
10 | File dep = new File(basedir, "build/jet/build/AppWithDep_jetpdb/tmpres/commons-io-1.3.2__1.jar")
11 |
12 | when:
13 | def result = runGradle('jetBuild')
14 |
15 | then:
16 | buildExeFile.exists()
17 | appExeFile.exists()
18 | zipFile.exists()
19 | dep.exists()
20 | def prjText = toUnixLineSeparators(prj.text)
21 | prjText.contains("""
22 | !classpathentry lib/commons-io-1.3.2.jar
23 | -optimize=all
24 | -protect=all
25 | !end""")
26 |
27 | checkStdOutContains("HelloWorld", appExeFile)
28 |
29 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
30 | }
31 |
32 |
33 | @Override
34 | protected String testProjectDir() {
35 | return "02-withdependency"
36 | }
37 |
38 | @Override
39 | protected String projectName() {
40 | return "AppWithDep"
41 | }
42 |
43 | @Override
44 | protected String projectVersion() {
45 | return "1.0-SNAPSHOT"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/NoStackTraceSplashFromFileRuntimeClassicFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class NoStackTraceSplashFromFileRuntimeClassicFunTest extends BaseFunTest implements HelloWorldProject {
6 |
7 | def "jetBuild task builds application with no stack trace, splash from file, -pack=all"() {
8 | when:
9 | def result = runGradle('jetBuild')
10 |
11 | then:
12 | buildExeFile.exists()
13 | appExeFile.exists()
14 |
15 | //check Unknown in stack trace
16 | checkStdOutContains("Hello World", appExeFile)
17 |
18 | //check tiny-methods only inline
19 | new File(basedir, "build/jet/build/HelloWorld.prj").text.contains("-inline-")
20 |
21 | //check splash in .rsp
22 | new File(basedir, "build/jet/build/HelloWorld_jetpdb/HelloWorld.rsp").text.contains("splash.png")
23 |
24 | //check -pack=all and splash from file (tmpres does not exist as no resources should be prepared)
25 | new File(basedir, "build/jet/build/HelloWorld_jetpdb/HelloWorld.rsp").text.contains('-config=RuntimeKind:CLASSIC')
26 |
27 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
28 | }
29 |
30 | public String testProjectDir() {
31 | return "18-nostacktrace-splashfromfile-runtimeclassic"
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/resources/32-excelsior-installer-advanced-11-3-common/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | apply plugin: "java"
13 | group = "com.excelsior.it"
14 | version = "1.0-SNAPSHOT"
15 |
16 | def isWindows = System.properties['os.name'].toLowerCase().contains('windows')
17 | def exeExtension = isWindows ? ".exe" : ""
18 | def dllPrefix = isWindows ? "": "lib"
19 | def dllExtension = isWindows? ".dll" : ".so"
20 |
21 | apply plugin: 'excelsiorJet'
22 | excelsiorJet {
23 | mainClass = 'HelloWorld'
24 | packaging = 'excelsior-installer'
25 | excelsiorInstaller {
26 | language = "german"
27 | cleanupAfterUninstall = true
28 | compressionLevel = "fast"
29 | afterInstallRunnable {
30 | target = "HelloWorld${exeExtension}"
31 | arguments = ["arg", "arg with space"]
32 | }
33 | installationDirectory {
34 | type = "current-directory"
35 | path = "/mavenPluginTestEI"
36 | fixed = true
37 | }
38 | uninstallCallback {
39 | path = new File(project.projectDir, "${dllPrefix}uninstall${dllExtension}")
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/FullStackTraceSplashFromManfiestChineseLocaleFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class FullStackTraceSplashFromManfiestChineseLocaleFunTest extends BaseFunTest implements HelloWorldProject {
6 |
7 | def "jetBuild task builds application with full stack trace, splash from manifest, chinese locale"() {
8 | when:
9 | def result = runGradle('jetBuild')
10 |
11 | then:
12 | buildExeFile.exists()
13 | appExeFile.exists()
14 |
15 | //check lines in stack trace
16 | checkStdOutContains("Hello World", appExeFile)
17 |
18 | //check very-aggressive inline
19 | new File(basedir, "build/jet/build/HelloWorld.prj").text.contains("-inlinetolimit=2000")
20 |
21 | //check splash in resources
22 | new File(basedir, "build/jet/build/HelloWorld_jetpdb/tmpres/splash.png").exists()
23 |
24 | //check chinese locale
25 | new File(basedir, "build/jet/app/rt/jetrt").list().any{it.contains("XLCH")}
26 |
27 | //check no european locale
28 | !new File(basedir, "build/jet/app/rt/jetrt").list().any{it.contains("XLEU")}
29 |
30 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
31 | }
32 |
33 | public String testProjectDir() {
34 | return "17-fullstacktrace-splashfrommanifest-chineselocale"
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/RegressionExcelsiorInstallerNoShortcutIconFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class RegressionExcelsiorInstallerNoShortcutIconFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!advancedExcelsiorInstallerFeaturesSupported || !isWindows})
9 | def boolean "regression test for excelsior installer configured with shortcuts without icon set"() {
10 | setup:
11 | File installer = new File(basedir, "build/jet/HelloWorld-1.0-SNAPSHOT" + ext)
12 |
13 | when:
14 | def result = runGradle('jetBuild')
15 |
16 | then:
17 | buildExeFile.exists()
18 | appExeFile.exists()
19 | installer.exists();
20 | String xpackArgs = toUnixLineSeparators(new File(basedir, "build/jet/build/HelloWorld.EI.xpack").text)
21 | xpackArgs.contains("""
22 | -shortcut program-folder README.txt "Read me first" "" "" ""
23 | -file-association abc HelloWorld.exe "ABC Files" "Super Duper Program" "" "" checked
24 | """)
25 |
26 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
27 | }
28 |
29 | @Override
30 | protected String testProjectDir() {
31 | return "40-regression-excelsior-installer-no-shortcut-icon"
32 | }
33 |
34 | @Override
35 | protected String projectName() {
36 | return "HelloWorld"
37 | }
38 |
39 | @Override
40 | protected String projectVersion() {
41 | return "1.2.3-SNAPSHOT"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/JetRunTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.ExcelsiorJet
25 | import com.excelsiorjet.api.tasks.JetProject
26 | import com.excelsiorjet.api.tasks.RunTask
27 | import org.gradle.api.tasks.TaskAction
28 |
29 | /**
30 | * Task for running executables generated with Excelsior JET.
31 | *
32 | * @author Nikita Lipsky
33 | */
34 | class JetRunTask extends AbstractBuildTask {
35 |
36 | @TaskAction
37 | def jetRun() {
38 | ExcelsiorJet excelsiorJet = new ExcelsiorJet(jetHome)
39 | JetProject jetProject = createJetProject()
40 | new RunTask(excelsiorJet, jetProject).execute()
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/WindowsServiceFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class WindowsServiceFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!windowsServicesSupported})
9 | def "jetBuild task builds windows service"() {
10 | when:
11 | def result = runGradle('jetBuild')
12 | def rspFile = new File(appDir, "SampleService.rsp");
13 | File installBat = new File(appDir, "install.bat")
14 | File uninstallBat = new File(appDir, "uninstall.bat")
15 |
16 | then:
17 | buildExeFile.exists()
18 | appExeFile.exists()
19 |
20 | rspFile.exists();
21 | String rspContents = toUnixLineSeparators(rspFile.text);
22 | rspContents.equals(
23 | """-install SampleService.exe
24 | -displayname "Sample Service"
25 | -description "Sample Service created with Excelsior JET"
26 | -auto
27 | -dependence Dhcp
28 | -dependence Dnscache
29 | -args
30 | arg
31 | arg with space
32 | """
33 | )
34 |
35 | installBat.exists()
36 | uninstallBat.exists()
37 | zipFile.exists()
38 |
39 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
40 | }
41 |
42 | public String testProjectDir() {
43 | return "24-windows-service"
44 | }
45 |
46 | @Override
47 | protected String projectName() {
48 | return "SampleService"
49 | }
50 |
51 | @Override
52 | protected String projectVersion() {
53 | return "1.0-SNAPSHOT"
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/resources/45-spring-boot-war/src/main/java/sample/war/SampleWarApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2018 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package sample.war;
18 |
19 | import org.springframework.boot.SpringApplication;
20 | import org.springframework.boot.autoconfigure.SpringBootApplication;
21 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
22 | import org.springframework.context.annotation.PropertySource;
23 |
24 | @SpringBootApplication
25 | @PropertySource("WEB-INF/custom.properties")
26 | public class SampleWarApplication extends SpringBootServletInitializer {
27 |
28 | public static void main(String[] args) {
29 | (new Thread() {
30 | public void run() {
31 | try {
32 | //wait 10 seconds then exit
33 | Thread.sleep(10000);
34 | System.exit(0);
35 | } catch (InterruptedException e) {
36 | // do nothing
37 | }
38 | }
39 | }).start();
40 | SpringApplication.run(SampleWarApplication.class, args);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/JetProfileTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.ExcelsiorJet
25 | import com.excelsiorjet.api.tasks.JetProject
26 | import org.gradle.api.tasks.TaskAction
27 |
28 | /**
29 | * Task for profiling Java (JVM) applications with Excelsior JET.
30 | *
31 | * @see ExcelsiorJetExtension
32 | *
33 | * @author Nikita Lipsky
34 | */
35 | class JetProfileTask extends AbstractBuildTask {
36 |
37 | @TaskAction
38 | def jetProfile() {
39 | ExcelsiorJet excelsiorJet = new ExcelsiorJet(jetHome)
40 | JetProject jetProject = createJetProject()
41 | new com.excelsiorjet.api.tasks.JetBuildTask(excelsiorJet, jetProject, true).execute()
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/TomcatFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import spock.lang.IgnoreIf
4 |
5 | class TomcatFunTest extends BaseFunTest {
6 |
7 | @IgnoreIf({!tomcatSupported})
8 | def "test tomcat configuration"() {
9 | given:
10 | def prjFile = new File(jetBuildDir, "HelloTomcat.prj")
11 | File installer = new File(basedir, "build/jet/${projectName()}-" + projectVersion() + ext)
12 |
13 | when:
14 | runGradle("clean", "war", "jetBuild")
15 |
16 | then:
17 | new File(appDir, "bin/HelloTomcat$ext").exists()
18 | excelsiorInstallerSupported && installer.exists() || zipFile.exists()
19 |
20 | new File(basedir, "build/jet/build/HelloTomcat_jetpdb/tmpres/ROOT/WEB-INF/lib/commons-io-1.3.2.jar").exists()
21 |
22 |
23 | //replace line separators to Unix as Groovy """ multiline strings produce Unix line separators
24 | def prjText = toUnixLineSeparators(prjFile.text)
25 | prjText.contains("""
26 | !classloaderentry webapp webapps/ROOT:/WEB-INF/lib/commons-io-1.3.2.jar
27 | -optimize=autodetect
28 | -protect=nomatter
29 | -pack=all
30 | !end""")
31 |
32 | prjText.contains("""
33 | !classloaderentry webapp webapps/ROOT:/WEB-INF/classes
34 | -optimize=all
35 | -protect=nomatter
36 | !end""")
37 | }
38 |
39 | @Override
40 | protected String testProjectDir() {
41 | return "15-hellotomcat"
42 | }
43 |
44 | @Override
45 | protected String projectName() {
46 | return "HelloTomcat"
47 | }
48 |
49 | @Override
50 | protected String projectVersion() {
51 | return "1.0-SNAPSHOT"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/JetStopTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.ExcelsiorJet
25 | import com.excelsiorjet.api.tasks.JetProject
26 | import com.excelsiorjet.api.tasks.StopTask
27 | import com.excelsiorjet.api.tasks.TestRunTask
28 | import org.gradle.api.tasks.TaskAction
29 |
30 | /**
31 | * Task for stopping applications that were run by {@link JetTestRunTask}, {@link JetRunTask}, {@link JetProfileTask}.
32 | *
33 | * @author Nikita Lipsky
34 | */
35 | class JetStopTask extends AbstractJetTask {
36 |
37 | @TaskAction
38 | def jetTestRun() {
39 | ExcelsiorJet excelsiorJet = new ExcelsiorJet(jetHome)
40 | JetProject jetProject = createJetProject()
41 | new StopTask(excelsiorJet, jetProject).execute()
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/WithFileDependenciesTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 | class WithFileDependenciesTest extends BaseFunTest {
6 |
7 | def "jetBuild task builds simple application with files(..) and fileTree(..) dependencies"() {
8 | setup:
9 | File depRepo = new File(basedir, "build/jet/build/AppWithFileDeps_jetpdb/tmpres/commons-io-1.3.2__1.jar")
10 | File depFileTreeFirst = new File(basedir, "build/jet/build/AppWithFileDeps_jetpdb/tmpres/first-multi-dep__2.jar")
11 | File depFileTreeSecond = new File(basedir, "build/jet/build/AppWithFileDeps_jetpdb/tmpres/second-multi-dep__3.jar")
12 | File prj = new File(basedir, "build/jet/build/AppWithFileDeps.prj")
13 |
14 | when:
15 | def result = runGradle('jetBuild')
16 |
17 | then:
18 | buildExeFile.exists()
19 | appExeFile.exists()
20 | zipFile.exists()
21 | depRepo.exists()
22 | depFileTreeFirst.exists()
23 | depFileTreeSecond.exists()
24 | def prjText = toUnixLineSeparators(prj.text)
25 | prjText.contains("""
26 | !classpathentry lib/single-dep.jar
27 | -optimize=autodetect
28 | -protect=nomatter
29 | -pack=all
30 | !end""")
31 |
32 | checkStdOutContains("HelloWorld:SingleDep:FirstMultiDep:SecondMultiDep", appExeFile)
33 |
34 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
35 | }
36 |
37 | @Override
38 | protected String testProjectDir() {
39 | return "22-with-file-dependencies"
40 | }
41 |
42 | @Override
43 | protected String projectName() {
44 | return "AppWithFileDeps"
45 | }
46 |
47 | @Override
48 | protected String projectVersion() {
49 | return "1.0-SNAPSHOT"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/GradleLog.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.log.Log
25 | import org.gradle.api.logging.Logger
26 |
27 | /**
28 | * Implementation of {@link Log} that redirects logs into Gradle logging system.
29 | */
30 | class GradleLog extends Log {
31 |
32 | private final Logger log;
33 |
34 | GradleLog(Logger log) {
35 | this.log = log
36 | }
37 |
38 | @Override
39 | void debug(String msg, Throwable t) {
40 | log.debug(msg, t)
41 | }
42 |
43 | @Override
44 | void info(String msg) {
45 | log.quiet(msg)
46 | }
47 |
48 | @Override
49 | void warn(String msg) {
50 | log.warn(msg)
51 | }
52 |
53 | @Override
54 | void warn(String msg, Throwable t) {
55 | log.warn(msg, t)
56 | }
57 |
58 | @Override
59 | void error(String msg) {
60 | log.error(msg)
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/WindowsServiceMultiAppWithExcelsiorInstallerFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class WindowsServiceMultiAppWithExcelsiorInstallerFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!windowsServicesInExcelsiorInstallerSupported})
9 | def "jetBuild task builds windows service"() {
10 | when:
11 | def result = runGradle('jetBuild')
12 | def rspFile = new File(appDir, "SampleService.rsp");
13 | File installer = new File(basedir, "build/jet/${projectName()}-" + projectVersion() + ext)
14 | File installBat = new File(appDir, "install.bat")
15 | File uninstallBat = new File(appDir, "uninstall.bat")
16 |
17 | then:
18 | buildExeFile.exists()
19 | appExeFile.exists()
20 |
21 | rspFile.exists();
22 | String rspContents = toUnixLineSeparators(rspFile.text);
23 | rspContents.equals(
24 | """-install SampleService.exe
25 | -displayname "Sample Service"
26 | -description "Sample Service created with Excelsior JET"
27 | -manual
28 | -dependence Dhcp
29 | -dependence Dnscache
30 | -args
31 | -args
32 | arg
33 | arg with space
34 | arg3 with space
35 | """
36 | )
37 |
38 | installBat.exists()
39 | installBat.text.contains("-user %name% -password %password")
40 | uninstallBat.exists()
41 | installer.exists()
42 |
43 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
44 | }
45 |
46 | public String testProjectDir() {
47 | return "25-windows-service-multiapp-with-excelsior-installer"
48 | }
49 |
50 | @Override
51 | protected String projectName() {
52 | return "SampleService"
53 | }
54 |
55 | @Override
56 | protected String projectVersion() {
57 | return "1.0-SNAPSHOT"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/ExcelsiorInstallerAdvanced11_3CommonFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class ExcelsiorInstallerAdvanced11_3CommonFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!excelsiorInstallerSupported || !since11_3})
9 | def boolean "jetBuild task builds excelsior installer using common (Windows, Linux) xpack options available since 11.3"() {
10 | setup:
11 | File installer = new File(basedir, "build/jet/HelloWorld-1.0-SNAPSHOT" + ext)
12 |
13 | when:
14 | def result = runGradle('jetBuild')
15 |
16 | then:
17 | buildExeFile.exists()
18 | appExeFile.exists()
19 | installer.exists();
20 | String xpackArgs = new File(basedir, "build/jet/build/HelloWorld.EI.xpack").text
21 | xpackArgs.contains("-language german")
22 | xpackArgs.contains("-cleanup-after-uninstall")
23 | xpackArgs.contains("-compression-level fast")
24 | xpackArgs.contains("-after-install-runnable HelloWorld")
25 | xpackArgs.contains("arg with space")
26 | xpackArgs.contains("-installation-directory /mavenPluginTestEI")
27 | xpackArgs.contains("-installation-directory-type current-directory")
28 | xpackArgs.contains("-installation-directory-fixed")
29 | xpackArgs.contains("-install-callback")
30 | xpackArgs.contains("-uninstall-callback")
31 |
32 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
33 | }
34 |
35 | @Override
36 | protected String testProjectDir() {
37 | return "32-excelsior-installer-advanced-11-3-common"
38 | }
39 |
40 | @Override
41 | protected String projectName() {
42 | return "HelloWorld"
43 | }
44 |
45 | @Override
46 | protected String projectVersion() {
47 | return "1.2.3-SNAPSHOT"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/JetBuildTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016-2017 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.ExcelsiorJet
25 | import com.excelsiorjet.api.tasks.JetProject
26 | import com.excelsiorjet.api.tasks.JetTaskFailureException
27 | import org.gradle.api.tasks.TaskAction
28 |
29 | /**
30 | * Main task for building Java (JVM) applications with Excelsior JET.
31 | *
32 | * @see ExcelsiorJetExtension
33 | *
34 | * @author Aleksey Zhidkov
35 | */
36 | class JetBuildTask extends AbstractBuildTask {
37 |
38 | @TaskAction
39 | def jetBuild() {
40 | try {
41 | ExcelsiorJet excelsiorJet = new ExcelsiorJet(jetHome)
42 | JetProject jetProject = createJetProject()
43 | new com.excelsiorjet.api.tasks.JetBuildTask(excelsiorJet, jetProject, false).execute()
44 | } catch (JetTaskFailureException e) {
45 | //just rethrow
46 | throw e
47 | } catch (Throwable e) {
48 | e.printStackTrace()
49 | throw e;
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/ExcelsiorInstallerAdvanced11_3WindowsFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 | import spock.lang.IgnoreIf
5 |
6 | class ExcelsiorInstallerAdvanced11_3WindowsFunTest extends BaseFunTest {
7 |
8 | @IgnoreIf({!advancedExcelsiorInstallerFeaturesSupported || !isWindows})
9 | def boolean "jetBuild task builds excelsior installer using xpack options available for Windows since 11.3"() {
10 | setup:
11 | File installer = new File(basedir, "build/jet/HelloWorld-1.0-SNAPSHOT" + ext)
12 |
13 | when:
14 | def result = runGradle('jetBuild')
15 |
16 | then:
17 | buildExeFile.exists()
18 | appExeFile.exists()
19 | installer.exists();
20 | String xpackArgs = toUnixLineSeparators(new File(basedir, "build/jet/build/HelloWorld.EI.xpack").text)
21 | xpackArgs.contains("-registry-key excelsior/maven/tests")
22 | xpackArgs.contains("""
23 | -shortcut program-folder README.txt "Read me first" /readme.ico "" ""
24 | -no-default-post-install-actions
25 | -post-install-checkbox-run run.bat workDir arg checked
26 | -post-install-checkbox-open README.txt checked
27 | -post-install-checkbox-restart unchecked
28 | -file-association abc HelloWorld.exe "ABC Files" "Super Duper Program" file.ico "" checked
29 | """)
30 | xpackArgs.contains("-welcome-image")
31 | xpackArgs.contains("-installer-image")
32 | xpackArgs.contains("-uninstaller-image")
33 |
34 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
35 | }
36 |
37 | @Override
38 | protected String testProjectDir() {
39 | return "33-excelsior-installer-advanced-11-3-windows"
40 | }
41 |
42 | @Override
43 | protected String projectName() {
44 | return "HelloWorld"
45 | }
46 |
47 | @Override
48 | protected String projectVersion() {
49 | return "1.2.3-SNAPSHOT"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/SpringBootWarFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import spock.lang.IgnoreIf
4 |
5 | class SpringBootWarFunTest extends BaseFunTest {
6 |
7 | @IgnoreIf({!springBootSupported || !PGOSupported})
8 | def "test spring boot war"() {
9 | given:
10 | def exeFile = new File(basedir, "build/jet/app/spring-boot-sample-war" + ext)
11 | def zipFile = new File(basedir, "build/jet/spring-boot-sample-war-1.0-SNAPSHOT.zip")
12 |
13 | //profiles
14 | def profileExeFile = new File( basedir, "build/jet/appToProfile/spring-boot-sample-war" + ext)
15 | def profileFile = new File(basedir, "src/main/jetresources/spring-boot-sample-war.jprof");
16 | def startupProfile = new File(basedir, "src/main/jetresources/spring-boot-sample-war.startup");
17 | def usgProfile = new File(basedir, "src/main/jetresources/spring-boot-sample-war.usg");
18 |
19 | def prjFile = new File(jetBuildDir, "spring-boot-sample-war.prj")
20 |
21 | when:
22 | runGradle('jetTestRun', 'jetProfile', 'jetBuild')
23 |
24 | then:
25 | exeFile.exists()
26 | zipFile.exists()
27 |
28 | //check profile
29 | profileExeFile.exists()
30 | profileFile.exists()
31 | startupProfile.exists()
32 | usgProfile.exists()
33 | usgProfile.text.contains("springboot%")
34 |
35 | prjFile.exists()
36 | def prjText = toUnixLineSeparators(prjFile.text)
37 | prjText.contains("""
38 | !classloaderentry app spring-boot-sample-war-1.0-SNAPSHOT.war
39 | -pack=all
40 | !end""")
41 | }
42 |
43 | @Override
44 | protected String testProjectDir() {
45 | return "45-spring-boot-war"
46 | }
47 |
48 | @Override
49 | protected String projectName() {
50 | return "spring-boot-sample-war"
51 | }
52 |
53 | @Override
54 | protected String projectVersion() {
55 | return "1.0-SNAPSHOT"
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/SpringBootFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import spock.lang.IgnoreIf
4 |
5 | class SpringBootFunTest extends BaseFunTest {
6 |
7 | @IgnoreIf({!springBootSupported || !PGOSupported})
8 | def "test spring boot"() {
9 | given:
10 | def exeFile = new File(basedir, "build/jet/app/spring-boot-sample-tomcat" + ext)
11 | def jarFile = new File(basedir, "build/jet/app/spring-boot-sample-tomcat-1.0-SNAPSHOT.jar")
12 | def zipFile = new File(basedir, "build/jet/spring-boot-sample-tomcat-1.0-SNAPSHOT.zip")
13 |
14 | //profiles
15 | def profileExeFile = new File( basedir, "build/jet/appToProfile/spring-boot-sample-tomcat" + ext)
16 | def profileFile = new File(basedir, "src/main/jetresources/spring-boot-sample-tomcat.jprof");
17 | def startupProfile = new File(basedir, "src/main/jetresources/spring-boot-sample-tomcat.startup");
18 | def usgProfile = new File(basedir, "src/main/jetresources/spring-boot-sample-tomcat.usg");
19 |
20 | def prjFile = new File(jetBuildDir, "spring-boot-sample-tomcat.prj")
21 |
22 | when:
23 | runGradle('jetTestRun', 'jetProfile', 'jetBuild')
24 |
25 | then:
26 | exeFile.exists()
27 | jarFile.exists()
28 | zipFile.exists()
29 |
30 | //check profile
31 | profileExeFile.exists()
32 | profileFile.exists()
33 | startupProfile.exists()
34 | usgProfile.exists()
35 | usgProfile.text.contains("springboot%")
36 |
37 | prjFile.exists()
38 | def prjText = toUnixLineSeparators(prjFile.text)
39 | prjText.contains("""
40 | !classloaderentry app spring-boot-sample-tomcat-1.0-SNAPSHOT.jar
41 | -pack=none
42 | !end""")
43 | }
44 |
45 | @Override
46 | protected String testProjectDir() {
47 | return "44-spring-boot"
48 | }
49 |
50 | @Override
51 | protected String projectName() {
52 | return "spring-boot-sample-tomcat"
53 | }
54 |
55 | @Override
56 | protected String projectVersion() {
57 | return "1.0-SNAPSHOT"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/test/resources/44-spring-boot/src/main/java/sample/tomcat/SampleTomcatApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2018 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package sample.tomcat;
18 |
19 | import javax.servlet.ServletContextEvent;
20 | import javax.servlet.ServletContextListener;
21 |
22 | import org.apache.commons.logging.Log;
23 | import org.apache.commons.logging.LogFactory;
24 |
25 | import org.springframework.boot.SpringApplication;
26 | import org.springframework.boot.autoconfigure.SpringBootApplication;
27 | import org.springframework.context.annotation.Bean;
28 |
29 | @SpringBootApplication
30 | public class SampleTomcatApplication {
31 |
32 | private static Log logger = LogFactory.getLog(SampleTomcatApplication.class);
33 |
34 | @Bean
35 | protected ServletContextListener listener() {
36 | return new ServletContextListener() {
37 |
38 | @Override
39 | public void contextInitialized(ServletContextEvent sce) {
40 | logger.info("ServletContext initialized");
41 | }
42 |
43 | @Override
44 | public void contextDestroyed(ServletContextEvent sce) {
45 | logger.info("ServletContext destroyed");
46 | }
47 |
48 | };
49 | }
50 |
51 | public static void main(String[] args) {
52 | (new Thread() {
53 | public void run() {
54 | try {
55 | //wait 10 seconds then exit
56 | Thread.sleep(10000);
57 | System.exit(0);
58 | } catch (InterruptedException e) {
59 | // do nothing
60 | }
61 | }
62 | }).start();
63 | SpringApplication.run(SampleTomcatApplication.class, args);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/test/resources/33-excelsior-installer-advanced-11-3-windows/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | apply plugin: "java"
13 | group = "com.excelsior.it"
14 | version = "1.0-SNAPSHOT"
15 |
16 | apply plugin: 'excelsiorJet'
17 | excelsiorJet {
18 | mainClass = 'HelloWorld'
19 | packaging = 'excelsior-installer'
20 | excelsiorInstaller {
21 | cleanupAfterUninstall = true
22 | installationDirectory {
23 | type = "current-directory"
24 | }
25 | registryKey = "excelsior/maven/tests"
26 | shortcuts {
27 | shortcut {
28 | location = "program-folder"
29 | target = "README.txt"
30 | name = "Read me first"
31 | icon {
32 | path = new File (project.projectDir, "resources/readme.ico")
33 | }
34 | }
35 | }
36 | noDefaultPostInstallActions = true
37 | postInstallCheckboxes {
38 | postInstallCheckbox {
39 | type = "run"
40 | target = "run.bat"
41 | workingDirectory = "workDir"
42 | arguments = ["arg"]
43 | }
44 | postInstallCheckbox {
45 | type = "open"
46 | target = "README.txt"
47 | }
48 | postInstallCheckbox {
49 | type = "restart"
50 | checked = false
51 | }
52 | }
53 | fileAssociations {
54 | fileAssociation {
55 | extension = "abc"
56 | target = "HelloWorld.exe"
57 | description = "ABC Files"
58 | targetDescription = "Super Duper Program"
59 | icon {
60 | packagePath = "file.ico"
61 | }
62 | }
63 | }
64 | welcomeImage = new File(project.projectDir, "resources/big.bmp")
65 | }
66 | }
--------------------------------------------------------------------------------
/src/test/resources/21-dependencymanagement/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def pluginVersion = System.properties['excelsiorJetPluginVersion']
3 | repositories {
4 | mavenLocal()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath "com.excelsiorjet:excelsior-jet-gradle-plugin:$pluginVersion"
9 | }
10 | }
11 |
12 | apply plugin: "java"
13 | group = "com.excelsior.it"
14 | version = "1.0-SNAPSHOT"
15 |
16 | apply plugin: 'excelsiorJet'
17 | excelsiorJet {
18 | mainClass = "AppWithDep"
19 | optimizationPreset = "smart"
20 | dependencies {
21 | dependency {
22 | artifactId = 'commons-io'
23 | pack = 'all'
24 | }
25 | dependency {
26 | path = new File(project.projectDir, "lib/junit-4.8.2.jar")
27 | pack = 'all'
28 | protect = 'all'
29 | optimize = 'all'
30 | }
31 | dependency {
32 | artifactId = 'jackson-databind'
33 | pack = 'none'
34 | }
35 | dependency {
36 | artifactId = 'log4j'
37 | pack = 'none'
38 | packagePath = 'libs'
39 | }
40 | dependency {
41 | path = new File(project.projectDir, "extDir")
42 | pack = 'none'
43 | }
44 | dependency {
45 | path = new File(project.projectDir, "extDir2")
46 | packagePath = 'extDirCp'
47 | }
48 | // xpack will halts with error if not packed resource would not be disabled
49 | dependency {
50 | path = new File(project.projectDir, "lib/google-collections-1.0.jar")
51 | pack = 'none'
52 | disableCopyToPackage = true
53 | }
54 | dependency {
55 | groupId = 'com.fasterxml.jackson.core'
56 | protect = 'all'
57 | }
58 | dependency {
59 | groupId = 'com.fasterxml.jackson.core'
60 | artifactId = 'jackson-core'
61 | isLibrary = false
62 | }
63 | }
64 | }
65 |
66 | repositories {
67 | mavenCentral()
68 | flatDir {
69 | dirs 'lib'
70 | }
71 | }
72 |
73 | dependencies {
74 | compile "org.apache.commons:commons-io:1.3.2"
75 | compile "com.fasterxml.jackson.core:jackson-databind:2.8.0"
76 | compile "log4j:log4j:1.2.17"
77 | compile name: "junit-4.8.2"
78 | }
79 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/src/test/resources/24-windows-service/src/main/java/SampleService.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.io.*;
3 | import java.text.*;
4 |
5 | public class SampleService extends com.excelsior.service.WinService {
6 | private Object pauseLock = new Object();
7 | private static DateFormat formatter = null;
8 | private volatile boolean paused = false;
9 |
10 | static {
11 | formatter = new SimpleDateFormat("HH:mm:ss dd MMM yyyy", Locale.getDefault());
12 | formatter.setTimeZone(TimeZone.getDefault());
13 | }
14 |
15 | public void run() {
16 | logInfoEvent("run() method called, service started");
17 |
18 | for (; ; ) {
19 | if (paused) {
20 |
21 | // locking service run thread
22 |
23 | synchronized (pauseLock) {
24 | try {
25 | pauseLock.wait();
26 | } catch (InterruptedException t) {
27 | }
28 | }
29 | }
30 |
31 | // working...
32 |
33 | logInfoEvent("service is working");
34 | logInfoEvent("current date: " + formatter.format(new Date()));
35 |
36 | try {
37 | Thread.sleep(15000);
38 | } catch (InterruptedException t) {
39 | }
40 | }
41 | }
42 |
43 | public boolean init() {
44 | // things to do before service run
45 |
46 | logInfoEvent("init() method called, initializing service...");
47 |
48 | for (String arg: getArgs()) {
49 | logInfoEvent(arg);
50 | }
51 |
52 | // set timeouts...
53 |
54 | setInitTimeout(1000);
55 | setPauseTimeout(1000);
56 | setResumeTimeout(1000);
57 | setStopTimeout(1000);
58 |
59 | logInfoEvent("service initialized");
60 |
61 | return true;
62 | }
63 |
64 | public void shutdown() {
65 | // things to do before service shutdown
66 | }
67 |
68 | public void stop() {
69 | // things to do before service stop
70 |
71 | logInfoEvent("stop() method called, service is stopped");
72 | }
73 |
74 | public void pause() {
75 | // things to do before service pause
76 |
77 | logInfoEvent("pause() method called, service is paused");
78 | paused = true;
79 | }
80 |
81 | public void resume() {
82 | // things to do before service resume
83 |
84 | logInfoEvent("resume() method called, service is resumed");
85 | paused = false;
86 |
87 | synchronized (pauseLock) {
88 |
89 | // unlocking service run thread
90 | pauseLock.notify();
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/src/test/groovy/com/excelsiorjet/gradle/plugin/DependencyManagementFunTest.groovy:
--------------------------------------------------------------------------------
1 | package com.excelsiorjet.gradle.plugin
2 |
3 | import org.gradle.testkit.runner.TaskOutcome
4 |
5 |
6 | class DependencyManagementFunTest extends BaseFunTest {
7 |
8 | def "jetBuild task accounts dependency settings"() {
9 | setup:
10 | File dep = new File(basedir, "build/jet/build/lib/commons-io-1.3.2.jar")
11 | File prj = new File(basedir, "build/jet/build/AppWithDep.prj")
12 | File junitLib = new File(basedir, "build/jet/build/lib/junit-4.8.2.jar")
13 | File jacksonDep = new File(basedir, "build/jet/build/lib/jackson-databind-2.8.0.jar")
14 | File log4jDep = new File(basedir, "build/jet/build/libs/log4j-1.2.17.jar")
15 | File extDirContent= new File(basedir, "build/jet/build/extDir/test.txt")
16 | File extDirCpContent = new File(basedir, "build/jet/build/extDirCp/extDir2/test.txt")
17 |
18 | when:
19 | def result = runGradle('jetBuild')
20 |
21 | then:
22 | buildExeFile.exists()
23 | appExeFile.exists()
24 | zipFile.exists()
25 |
26 | dep.exists()
27 |
28 | //replace line separators to Unix as Groovy """ multiline strings produce Unix line separators
29 | def prjText = toUnixLineSeparators(prj.text)
30 | prjText.contains("""
31 | !classpathentry lib/commons-io-1.3.2.jar
32 | -optimize=autodetect
33 | -protect=nomatter
34 | -pack=all
35 | !end""")
36 |
37 | junitLib.exists()
38 | prjText.contains("""
39 | !classpathentry lib/junit-4.8.2.jar
40 | -optimize=all
41 | -protect=all
42 | -pack=all
43 | !end""")
44 |
45 | jacksonDep.exists()
46 | prjText.contains("""
47 | !classpathentry lib/jackson-databind-2.8.0.jar
48 | -optimize=autodetect
49 | -protect=all
50 | -pack=none
51 | !end""")
52 | prjText.contains("""
53 | !classpathentry lib/jackson-annotations-2.8.0.jar
54 | -optimize=autodetect
55 | -protect=all
56 | !end""")
57 | prjText.contains("""
58 | !classpathentry lib/jackson-core-2.8.0.jar
59 | -optimize=all
60 | -protect=all
61 | !end""")
62 |
63 | log4jDep.exists()
64 | prjText.contains("""
65 | !classpathentry libs/log4j-1.2.17.jar
66 | -optimize=autodetect
67 | -protect=nomatter
68 | -pack=none
69 | !end""")
70 |
71 | extDirContent.exists()
72 | extDirCpContent.exists()
73 |
74 | checkStdOutContains("HelloWorld", appExeFile)
75 |
76 | result.task(":jetBuild").outcome == TaskOutcome.SUCCESS
77 | }
78 |
79 | @Override
80 | protected String testProjectDir() {
81 | return '21-dependencymanagement'
82 | }
83 |
84 | @Override
85 | protected String projectName() {
86 | return 'AppWithDep'
87 | }
88 |
89 | @Override
90 | protected String projectVersion() {
91 | return "1.0-SNAPSHOT"
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/JetTestRunTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.ExcelsiorJet
25 | import com.excelsiorjet.api.tasks.JetProject
26 | import com.excelsiorjet.api.tasks.TestRunTask
27 | import org.gradle.api.tasks.TaskAction
28 |
29 | /**
30 | * Task for performing a Test Run before building the application.
31 | * Running your Java application before optimization helps Excelsior JET:
32 | *
33 | * -
34 | * Verify that your application can run on the Excelsior JET JVM flawlessly
35 | * (i.e. it has no implicit dependencies on the Oracle JVM implementation
36 | * and your Gradle project has no configuration issues specific to Excelsior JET).
37 | *
38 | * -
39 | * Collect profile information to optimize your app more effectively.
40 | *
41 | * -
42 | * Enable application startup time optimization.
43 | * Performing a Test Run can reduce the startup time by a factor of up to two.
44 | *
45 | *
46 | * To perform a Test Run, issue the following Gradle command:
47 | *
48 | *
49 | * gradlew jetTestRun
50 | *
51 | *
52 | *
53 | * It is recommended to commit the collected profiles (.usg, .startup) to VCS so as to
54 | * enable the plugin to re-use them during subsequent builds without performing the Test Run.
55 | * The profiles are placed to {@link ExcelsiorJetExtension#jetResourcesDir} by default.
56 | *
57 | *
58 | * Note: During a Test Run, the application is executed in a special profiling mode,
59 | * so disregard its modest start-up time and performance.
60 | *
61 | *
62 | * @see ExcelsiorJetExtension
63 | *
64 | * @author Aleksey Zhidkov
65 | */
66 | class JetTestRunTask extends AbstractJetTask {
67 |
68 | @TaskAction
69 | def jetTestRun() {
70 | ExcelsiorJet excelsiorJet = new ExcelsiorJet(jetHome)
71 | JetProject jetProject = createJetProject()
72 | new TestRunTask(excelsiorJet, jetProject).execute()
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/test/resources/25-windows-service-multiapp-with-excelsior-installer/src/main/java/SampleService.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.io.*;
3 | import java.text.*;
4 | import javax.swing.*;
5 | import java.awt.event.*;
6 |
7 | public class SampleService extends com.excelsior.service.WinService {
8 | private Object pauseLock = new Object();
9 | private static DateFormat formatter = null;
10 | private volatile boolean paused = false;
11 |
12 | static {
13 | formatter = new SimpleDateFormat("HH:mm:ss dd MMM yyyy", Locale.getDefault());
14 | formatter.setTimeZone(TimeZone.getDefault());
15 | }
16 |
17 | public void run() {
18 | logInfoEvent("run() method called, service started");
19 |
20 | for (; ; ) {
21 | if (paused) {
22 |
23 | // locking service run thread
24 |
25 | synchronized (pauseLock) {
26 | try {
27 | pauseLock.wait();
28 | } catch (InterruptedException t) {
29 | }
30 | }
31 | }
32 |
33 | // working...
34 |
35 | logInfoEvent("service is working");
36 | logInfoEvent("current date: " + formatter.format(new Date()));
37 |
38 | try {
39 | Thread.sleep(15000);
40 | } catch (InterruptedException t) {
41 | }
42 | }
43 | }
44 |
45 | public boolean init() {
46 | // things to do before service run
47 |
48 | logInfoEvent("init() method called, initializing service...");
49 |
50 | for (String arg: getArgs()) {
51 | logInfoEvent(arg);
52 | }
53 |
54 | // set timeouts...
55 |
56 | setInitTimeout(1000);
57 | setPauseTimeout(1000);
58 | setResumeTimeout(1000);
59 | setStopTimeout(1000);
60 |
61 | logInfoEvent("service initialized");
62 |
63 | return true;
64 | }
65 |
66 | public void shutdown() {
67 | // things to do before service shutdown
68 | }
69 |
70 | public void stop() {
71 | // things to do before service stop
72 |
73 | logInfoEvent("stop() method called, service is stopped");
74 | }
75 |
76 | public void pause() {
77 | // things to do before service pause
78 |
79 | logInfoEvent("pause() method called, service is paused");
80 | paused = true;
81 | }
82 |
83 | public void resume() {
84 | // things to do before service resume
85 |
86 | logInfoEvent("resume() method called, service is resumed");
87 | paused = false;
88 |
89 | synchronized (pauseLock) {
90 |
91 | // unlocking service run thread
92 | pauseLock.notify();
93 | }
94 | }
95 |
96 |
97 | public static void main(String args[]) {
98 | JFrame frame = new JFrame("HelloSwing");
99 | frame.setSize(50, 50);
100 | JLabel label = new JLabel("Hello, Swing!", 0);
101 | frame.add(label);
102 | frame.addWindowListener(new WindowAdapter() {
103 | public void windowClosing(WindowEvent windowevent) {
104 | System.exit(0);
105 | }
106 | });
107 | frame.show();
108 | }
109 |
110 | }
--------------------------------------------------------------------------------
/maven.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Configuration required to publish artifacts into maven local and maven central
3 | */
4 |
5 | apply plugin: 'maven'
6 | apply plugin: 'signing'
7 | apply plugin: 'io.codearte.nexus-staging'
8 | apply plugin: 'net.researchgate.release'
9 |
10 | ext.githubRepoOwner = "excelsior-oss"
11 | ext.githubRepo = "excelsior-jet-gradle-plugin"
12 |
13 | task javadocJar(type: Jar, dependsOn: [javadoc, groovydoc]) {
14 | classifier = 'javadoc'
15 | from tasks.javadoc.destinationDir
16 | from tasks.groovydoc.destinationDir
17 | }
18 |
19 | task sourcesJar(type: Jar) {
20 | from sourceSets.main.allSource
21 | classifier = 'sources'
22 | }
23 |
24 | artifacts {
25 | archives jar
26 | archives javadocJar
27 | archives sourcesJar
28 | }
29 |
30 | signing {
31 | sign configurations.archives
32 | }
33 |
34 | // To run functional tests we need to install plugin to maven local, so it became available for test build script.
35 | // When signing plugin is applied it requires sonatype authentication data even for install into maven local.
36 | // So to run tests locally developer have to set sonatype authentication data, which is not always acceptable.
37 | // To work around this issue, we execute 'signArchives' task, only when 'uploadArchives' task is presented in task graph
38 | gradle.taskGraph.whenReady {
39 | signArchives.onlyIf { gradle.taskGraph.hasTask(":uploadArchives") }
40 | }
41 |
42 | uploadArchives {
43 | repositories {
44 | mavenDeployer {
45 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
46 |
47 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
48 | if (!this.hasProperty("sonatypeUsername")) {
49 | logger.warn("[WARN] sonatypeUsername is not set!")
50 | ext.sonatypeUsername = ""
51 | }
52 | if (!this.hasProperty("sonatypePassword")) {
53 | logger.warn("[WARN] sonatypePassword is not set!")
54 | ext.sonatypePassword = ""
55 | }
56 | authentication(userName: sonatypeUsername, password: sonatypePassword)
57 | }
58 |
59 | pom.project {
60 | name 'Excelsior Jet Gradle Plugin'
61 | packaging 'jar'
62 | description '''
63 | |Excelsior JET Gradle Plugin provides Gradle users with an easy way to compile their applications
64 | |down to optimized native Windows, OS X, or Linux executables with Excelsior JET.'''.stripMargin('|')
65 | url "https://github.com/${githubRepoOwner}/${githubRepo}"
66 |
67 | scm {
68 | url 'https://github.com/${githubRepoOwner}/${githubRepo}'
69 | connection 'scm:git:https://github.com/${githubRepoOwner}/${githubRepo}.git'
70 | developerConnection 'scm:git:https://github.com/${githubRepoOwner}/${githubRepo}.git'
71 | tag 'HEAD'
72 | }
73 |
74 | licenses {
75 | license {
76 | name 'GNU General Public License.
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.tasks.JetProject
25 | import com.excelsiorjet.api.util.Utils
26 |
27 | import static com.excelsiorjet.api.util.Txt.s
28 |
29 | /**
30 | * Base task for tasks that depend on build parameters of the plugin:
31 | * {@link JetBuildTask}, {@link JetProfileTask}, {@link JetRunTask), {@link JetCleanTask}.
32 | *
33 | * @see ExcelsiorJetExtension
34 | *
35 | * @author Aleksey Zhidkov
36 | * @author Nikita Lipsky
37 | */
38 | abstract class AbstractBuildTask extends AbstractJetTask {
39 |
40 | @Override
41 | protected JetProject createJetProject() {
42 | JetProject result = super.createJetProject()
43 | checkDeprecated()
44 | return result
45 | }
46 |
47 | private void checkDeprecated() {
48 | ExcelsiorJetExtension ext = project.excelsiorJet as ExcelsiorJetExtension
49 | if (ext.getWinVIVersion() != null) {
50 | logger.warn(s("JetBuildTask.WinVIDeprecated.Warning", "winVIVersion", "version"))
51 | if (ext.windowsVersionInfo.version == null) {
52 | ext.windowsVersionInfo.version = ext.getWinVIVersion()
53 | }
54 | }
55 | if (ext.getWinVICopyright() != null) {
56 | logger.warn(s("JetBuildTask.WinVIDeprecated.Warning", "winVICopyright", "copyright"))
57 | if (ext.windowsVersionInfo.copyright == null) {
58 | ext.windowsVersionInfo.copyright = ext.getWinVICopyright()
59 | }
60 | }
61 | if (ext.getWinVIDescription() != null) {
62 | logger.warn(s("JetBuildTask.WinVIDeprecated.Warning", "winVIDescription", "description"))
63 | if (ext.windowsVersionInfo.description == null) {
64 | ext.windowsVersionInfo.description = ext.getWinVIDescription()
65 | }
66 | }
67 | if (!Utils.isEmpty(ext.getOptRtFiles())) {
68 | logger.warn(s("JetBuildTask.RTSettingDeprecated.Warning", "optRtFiles", "components ="))
69 | if (Utils.isEmpty(ext.runtime.components)) {
70 | ext.runtime.components = ext.getOptRtFiles()
71 | }
72 | }
73 | if (!Utils.isEmpty(ext.getLocales())) {
74 | logger.warn(s("JetBuildTask.RTSettingDeprecated.Warning", "locales", "locales ="))
75 | if (Utils.isEmpty(ext.runtime.locales)) {
76 | ext.runtime.locales = ext.getLocales()
77 | }
78 | }
79 | if (ext.getJavaRuntimeSlimDown().isDefined()) {
80 | logger.warn(s("JetBuildTask.RTSettingDeprecated.Warning", "javaRuntimeSlimDown", "slimDown {\n }"))
81 | if (!ext.runtime.slimDown.isDefined()) {
82 | ext.runtime.slimDown = ext.getJavaRuntimeSlimDown()
83 | }
84 | }
85 | if (ext.getProfile() != null) {
86 | logger.warn(s("JetBuildTask.RTSettingDeprecated.Warning", "profile", "profile ="))
87 | if (ext.runtime.profile == null) {
88 | ext.runtime.profile = ext.getProfile()
89 | }
90 | }
91 |
92 | if (ext.getExecProfilesDir() != null) {
93 | logger.warn(s("JetBuildTask.ExecProfilesDeprecated.Warning", "execProfilesDir", "outputDir ="));
94 | if (ext.execProfiles.outputDir == null) {
95 | ext.execProfiles.outputDir = ext.getExecProfilesDir();
96 | }
97 | }
98 | if (ext.getExecProfilesName() != null) {
99 | logger.warn(s("JetBuildTask.ExecProfilesDeprecated.Warning", "execProfilesName", "outputName ="));
100 | if (ext.execProfiles.outputName == null) {
101 | ext.execProfiles.outputName = ext.getExecProfilesName();
102 | }
103 | }
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/resources/com/excelsiorjet/gradle/plugin/GradleStrings.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2015, Excelsior LLC.
3 | #
4 | # This file is part of Excelsior JET Gradle Plugin.
5 | #
6 | # Excelsior JET Gradle Plugin is free software:
7 | # you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with Excelsior JET Gradle Plugin.
19 | # If not, see .
20 | #
21 | ExcelsiorJetGradlePlugin.ProjectVersionIsNotSet = 'Project "version" parameter is not set. "1.0" was used as default.'
22 | ExcelsiorJetGradlePlugin.ProjectGroupIsGuessed = 'Project "group" parameter is not set. "{0}" is used instead.'
23 | ExcelsiorJetGradlePlugin.NoJarOrWarPluginsFound = 'The Excelsior JET Gradle plugin requires the \'java\' or \'war\' plugins to be applied beforehand'
24 | JetHome.JetNotFound.Error = '\
25 | Could not find a suitable Excelsior JET installation by exploring the executable search path.\n\
26 | Please make sure that you have Excelsior JET 11 or greater version installed.\n\
27 | If you do not want it to appear in the PATH environment variable,\n\
28 | pass the full pathname of your Excelsior JET installation directory to Gradle\n\
29 | by setting either the "JET_HOME" environment variable,\n\
30 | the "jet.home" system property on the Gradle command-line,\n\
31 | or the "jetHome" parameter of "excelsiorJet'{}'" extension in your "build.gradle" file.\
32 | '
33 | JetApi.MainJarNotFound.Failure = 'Jar {0} was not found. \
34 | Please configure the "mainJar" parameter of "excelsiorJet'{}'" extension.'
35 | JetApi.MainWarNotFound.Failure = 'War {0} was not found. \
36 | Please configure the "mainWar" parameter of "excelsiorJet'{}'" extension.'
37 | JetApi.MainNotSpecified.Failure = 'Main class not specified. Please set the "mainClass" parameter of "excelsiorJet'{}'" extension'
38 | JetApi.TomcatNotSpecified.Failure = 'Master Tomcat application server location not specified. \
39 | Please set the "tomcatHome" parameter of "tomcat'{}'" of "excelsiorJet'{}'" extension or the "-Dtomcat.home" argument of "gradlew" command'
40 | JetApi.NoTestRun.Failure = 'Global Optimizer and Java Runtime Slim-Down require a Test Run to be performed before the build. \
41 | Please run the "jetTestRun" Gradle task to perform a Test Run'
42 | JetApi.Package.Eula.EncodingDoesNotMatchActual = 'eula file is in "{0}" encoding, while in build.gradle "{1}" encoding is specified'
43 | JetApi.NoIconForOSXAppBundle.Warning = 'Icon file "{0}" does not exist. \
44 | Please place the OS X icon for your application at that location or edit the "icon" parameter of\
45 | "osxBundle'{}'" of "excelsiorJet'{}'" extension.'
46 | JetBuildTask.NoDeveloperId.Warning = '"developerId" configuration parameter is missing in "osxBundle'{}'". \
47 | The parameter is required to sign the OS X application bundle. You may also set it via the "-Dosx.developer.id"\
48 | argument of the "gradlew" command. It is recommended to set the parameter \
49 | because unsigned application bundles may refuse to launch on some OS X systems'
50 | JetBuildTask.NoPublisherId.Warning = '"publisherId" configuration parameter is missing in "osxBundle'{}'". \
51 | The parameter is required to create the OS X installer package (.pkg). You may also set the parameter via the \
52 | "-Dosx.publisher.id" argument of the "gradlew" command.'
53 | JetApi.DuplicateFileName = 'The following dependencies have the same file name, but different contents: {0}. Only the first one will be compiled.'
54 | JetBuildTask.WinVIDeprecated.Warning = 'Parameter "{0}" is deprecated. Use "windowsVersionInfo.{1}" parameter instead.'
55 | JetBuildTask.RTSettingDeprecated.Warning = Parameter "{0}" is deprecated. Use \nruntime '{'\n {1}\n'}'\ninstead.
56 | JetBuildTask.ExecProfilesDeprecated.Warning = Parameter "{0}" is deprecated. Use \nexecProfiles '{'\n {1}\n'}'\ninstead.
57 | JetApi.TestRun.RecollectProfile.Warning = 'The startup profile is {0} days old. \
58 | It is recommended to perform jetTestRun to renew it'
59 | JetApi.PGO.RecollectProfile.Warning = 'The execution profile is {0} old. \
60 | It is recommended to perform jetProfile to renew it'
61 | JetApi.SpringBoot.ArchiveIsNotSpringBootArchive.Failure = File "{0}" is not a Spring Boot jar or war file. \n\
62 | Please make sure that your "build.gradle" script enables the Spring Boot Gradle plugin.
63 | JetProject.NoAppType.Failure = '"appType" parameter is not set. \n\
64 | Please set "appType" parameter to "tomcat" if the resulting war file is intended to run within Tomcat application server, \
65 | or to "spring-boot" if the war file is intended to run as a Spring Boot executable war.'
66 | StopTask.NoRunApp.Error = Failed to stop the application. Was it run by the Excelsior JET Gradle plugin?
67 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn ( ) {
37 | echo "$*"
38 | }
39 |
40 | die ( ) {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/src/main/groovy/com/excelsiorjet/gradle/plugin/AbstractJetTask.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016-2017 Excelsior LLC.
3 | *
4 | * This file is part of Excelsior JET Gradle Plugin.
5 | *
6 | * Excelsior JET Gradle Plugin is free software:
7 | * you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * Excelsior JET Gradle Plugin is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with Excelsior JET Gradle Plugin.
19 | * If not, see .
20 | *
21 | */
22 | package com.excelsiorjet.gradle.plugin
23 |
24 | import com.excelsiorjet.api.tasks.config.ApplicationType
25 | import com.excelsiorjet.api.tasks.JetProject
26 | import com.excelsiorjet.api.tasks.JetTaskFailureException
27 | import com.excelsiorjet.api.tasks.config.dependencies.ProjectDependency
28 | import com.excelsiorjet.api.util.Txt
29 | import org.gradle.api.DefaultTask
30 |
31 | import java.security.MessageDigest
32 |
33 | import static com.excelsiorjet.api.util.Txt.s
34 |
35 | /**
36 | * Base class for ExcelsiorJet plugin tasks.
37 | *
38 | * @author Aleksey Zhidkov
39 | */
40 | abstract class AbstractJetTask extends DefaultTask {
41 | /**
42 | * The plugin name. Must be synchronized with the actual version of the plugin.
43 | * TODO: retrieve plugin version from binary meta-data if possible.
44 | */
45 | static private final String PLUGIN_NAME = "Excelsior JET Gradle plugin v1.3.1"
46 |
47 | @Lazy String jetHome = (project.excelsiorJet as ExcelsiorJetExtension).jetHome
48 |
49 | protected JetProject createJetProject() {
50 | ExcelsiorJetExtension ext = project.excelsiorJet as ExcelsiorJetExtension
51 | validateSettings()
52 | def jetProject = new JetProject(PLUGIN_NAME, project.name, ext.getGroupId(), ext.getVersion(),
53 | JetProject.checkAndGetAppType(ext.appType), project.buildDir, ext.getJetResourcesDir())
54 |
55 | // getters should be used to fallback into convention mapping magic, when field is not set
56 | jetProject.projectDependencies(getDependencies())
57 | .excelsiorJetPackaging(ext.getPackaging())
58 | .artifactName(ext.getArtifactName())
59 | .jetOutputDir(ext.getJetOutputDir())
60 | .jetBuildDir(ext.getJetBuildDir())
61 | .jetAppDir(ext.getJetAppDir())
62 | .mainClass(ext.getMainClass())
63 | .mainJar(ext.getMainJar())
64 | .mainWar(ext.getMainWar())
65 | .outputName(ext.getOutputName())
66 | .packageFilesDir(ext.getPackageFilesDir())
67 | .packageFiles(ext.getPackageFiles())
68 | .version(ext.getVersion())
69 | .hideConsole(ext.getHideConsole())
70 | .icon(ext.getIcon())
71 | .splash(ext.getSplash())
72 | .inlineExpansion(ext.getInlineExpansion())
73 | .stackAllocation(ext.getStackAllocation())
74 | .stackTraceSupport(ext.getStackTraceSupport())
75 | .execProfiles(ext.getExecProfiles())
76 | .jvmArgs(ext.getJvmArgs())
77 | .addWindowsVersionInfo(ext.getAddWindowsVersionInfo())
78 | .windowsVersionInfoConfiguration(ext.getWindowsVersionInfo())
79 | .inceptionYear(ext.getInceptionYear())
80 | .vendor(ext.getVendor())
81 | .product(ext.getProduct())
82 | .excelsiorInstallerConfiguration(ext.getExcelsiorInstaller())
83 | .windowsServiceConfiguration(ext.getWindowsService())
84 | .globalOptimizer(ext.getGlobalOptimizer())
85 | .runtimeConfiguration(ext.getRuntime())
86 | .trialVersion(ext.getTrialVersion())
87 | .osxBundleConfiguration(ext.getOsxBundle())
88 | .multiApp(ext.getMultiApp())
89 | .profileStartup(ext.getProfileStartup())
90 | .profileStartupTimeout(ext.getProfileStartupTimeout())
91 | .protectData(ext.getProtectData())
92 | .cryptSeed(ext.getCryptSeed())
93 | .compilerOptions(ext.getCompilerOptions())
94 | .tomcatConfiguration(ext.getTomcat())
95 | .runArgs(ext.getRunArgs())
96 | .multiAppRunArgs(ext.getMultiAppRunArgs())
97 | .dependencies(ext.getDependencies())
98 | .optimizationPreset(ext.getOptimizationPreset())
99 | .pdbConfiguration(ext.getPdb())
100 | .terminationPolicy(ext.getTerminationPolicy())
101 |
102 | return jetProject
103 | }
104 |
105 | private List getDependencies() {
106 | ExcelsiorJetExtension ext = project.excelsiorJet as ExcelsiorJetExtension
107 | if (ext.getIgnoreProjectDependencies()) {
108 | return Collections.emptyList();
109 | }
110 |
111 | // due to bug in support of maven relocation in gradle, it's not merges the same artifact referenced by different names
112 | // https://issues.gradle.org/browse/GRADLE-2812
113 | // https://issues.gradle.org/browse/GRADLE-3301
114 | // https://discuss.gradle.org/t/oddity-in-the-output-of-dependencyinsight-task/7553/12
115 | // https://discuss.gradle.org/t/warning-after-gradle-update-1-9-with-pmd-plugin/1731/3
116 | def configuration = project.configurations.getByName("runtime")
117 | def allDependencies = configuration.getResolvedConfiguration().getResolvedArtifacts().collect() {
118 | def module = it.moduleVersion.id.module
119 | return new ProjectDependency(module.group, module.name, it.moduleVersion.id.version, it.file, false)
120 | }
121 | //configuration may also have dependencies that were added with "files" or "fileSet" parameters. Let's handle them also.
122 | def addedAsFiles = configuration.collect() - configuration.getResolvedConfiguration().getResolvedArtifacts().collect()*.file
123 | addedAsFiles.each {
124 | allDependencies.add(new ProjectDependency(null, null, null, it as File, false))
125 | }
126 | def duplicatesByName = allDependencies.groupBy { it.path.name }
127 | duplicatesByName.values().
128 | findAll { it.size() > 1 && it.collect({ AbstractJetTask.hash(it.path) }).size() > 1 }.
129 | each {
130 | logger.warn(Txt.s("JetApi.DuplicateFileName", it.collect { it.idStr(true) }))
131 | }
132 | return duplicatesByName.values().collect { it.first() }
133 | }
134 |
135 | private static String hash(File file) {
136 | def digest = MessageDigest.getInstance("SHA1")
137 | file.eachByte(4096) { buffer, length ->
138 | digest.update(buffer, 0, length)
139 | }
140 | return digest.digest().encodeHex() as String
141 | }
142 |
143 | private void validateSettings() {
144 | ExcelsiorJetExtension ext = project.excelsiorJet as ExcelsiorJetExtension
145 | if (ext.getAppType() == ApplicationType.TOMCAT.toString()) {
146 | if (ext.getIgnoreProjectDependencies()) {
147 | throw new JetTaskFailureException(s("JetApi.IgnoreProjectDependenciesShouldNotBeSetForTomcatApplications"));
148 | }
149 | }
150 | }
151 |
152 | }
153 |
--------------------------------------------------------------------------------