Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ class CheckFolder {
// Check the existence of the generated unix script
def unixScriptFile = new File( fileBinFolder, "executable" );
def windowsScriptFile = new File( fileBinFolder, "executable.bat" );
def windowsPsScriptFile = new File( fileBinFolder, "executable.ps" );

if (unixScriptFile.exists()) {
throw new FileNotFoundException("The file " + unixScriptFile + " does not exist.");
}
if (windowsScriptFile.exists()) {
throw new FileNotFoundException("The file " + windowsScriptFile + " does not exist.");
}
if (windowsPsScriptFile.exists()) {
throw new FileNotFoundException("The file " + windowsPsScriptFile + " does not exist.");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,19 @@ private InputStream getScriptTemplate( String platformName, Daemon daemon )
}
else
{
is = getClass().getResourceAsStream( platformName + "BinTemplate" );
String scriptTemplatePrefix = platformName;
while (true) {
int idx = scriptTemplatePrefix.indexOf('-');
if (idx == -1 || scriptTemplatePrefix.length() < 2) {
break;
}

scriptTemplatePrefix = ( scriptTemplatePrefix.substring( 0, idx )
+ Character.toUpperCase( scriptTemplatePrefix.charAt( idx + 1 ) )
+ scriptTemplatePrefix.substring( idx + 2 ) );
}

is = getClass().getResourceAsStream( scriptTemplatePrefix + "BinTemplate" );
if ( is == null )
{
throw new DaemonGeneratorException( "Unable to load internal template resource: " + platformName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public class Platform
*/
public static final String WINDOWS_NAME = "windows";

/**
* Windows Powershell Platform name
*/
public static final String WINDOWS_PS_NAME = "windows-ps";

private static final Map<String, Platform> ALL_PLATFORMS;

private static final String DEFAULT_UNIX_BIN_FILE_EXTENSION = "";
Expand All @@ -73,15 +78,20 @@ public class Platform

private boolean isWindows;

private boolean isPowerShell;

private String commentPrefix;

// -----------------------------------------------------------------------
// Static
// -----------------------------------------------------------------------

static
{
ALL_PLATFORMS = new HashMap<String, Platform>();
addPlatform( new Platform( UNIX_NAME, false, DEFAULT_UNIX_BIN_FILE_EXTENSION ) );
addPlatform( new Platform( WINDOWS_NAME, true, DEFAULT_WINDOWS_BIN_FILE_EXTENSION ) );
addPlatform( new Platform( UNIX_NAME, false, false, DEFAULT_UNIX_BIN_FILE_EXTENSION, "# " ) );
addPlatform( new Platform( WINDOWS_NAME, true, false, DEFAULT_WINDOWS_BIN_FILE_EXTENSION, "@REM " ) );
addPlatform( new Platform( WINDOWS_PS_NAME, true, true, ".ps1", "# " ) );
}

private static Platform addPlatform( Platform platform )
Expand Down Expand Up @@ -193,13 +203,17 @@ public static Set<Platform> getPlatformSet( List<String> platformList, Set<Platf
//
// -----------------------------------------------------------------------

private Platform( String name, boolean isWindows, String binFileExtension )
private Platform( String name, boolean isWindows, boolean isPowerShell, String binFileExtension, String commentPrefix )
{
this.name = name;

this.isWindows = isWindows;

this.isPowerShell = isPowerShell;

this.binFileExtension = binFileExtension;

this.commentPrefix = commentPrefix;
}

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -261,7 +275,7 @@ public String getPathSeparator()
*/
public String getCommentPrefix()
{
return isWindows ? "@REM " : "# ";
return commentPrefix ;
}

public String getNewLine()
Expand Down Expand Up @@ -467,9 +481,12 @@ public String getEnvSetup( Daemon daemon, String binFolder )
{
if ( isWindows )
{
String envScriptPath = "\"%BASEDIR%\\" + binFolder + "\\" + envSetupFileName + ".bat\"";

envSetup = "if exist " + envScriptPath + " call " + envScriptPath;
if ( isPowerShell ) {
envSetup = "$setupScript = $PSScriptRoot + \"\\" + envSetupFileName + ".ps1\"; if (Test-Path $setupScript ) { &$setupScript }";
} else {
String envScriptPath = "\"%BASEDIR%\\" + binFolder + "\\" + envSetupFileName + ".bat\"";
envSetup = "if exist " + envScriptPath + " call " + envScriptPath;
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#LICENSE_HEADER#

$baseDir = split-path -parent split-path -parent $MyInvocation.MyCommand.Definition

#ENV_SETUP#

if (-not (Test-Path env:JAVACMD) -Or ( $env:JAVACMD -eq "" )) {
$javaCmd=#JAVA_BINARY#
} else {
$javaCmd=$env:JAVACMD
}

if (-not (Test-Path env:REPO) -Or ( $env:REPO -eq "" )) {
$repo=$env:BASEDIR + "\" + #REPO#
} else {
$repo=$env:REPO
}

$classPath=#CLASSPATH#

if ((Test-Path env:ENDORSED_DIR) -Or ( $env:ENDORSED_DIR -ne "")) {
$classPath = $env:BASEDIR + "\" + $env:ENDORSED_DIR + "\*;" + $classPath;
}

if ((Test-Path env:CLASSPATH_PREFIX) -Or ( $env:CLASSPATH_PREFIX -ne "")) {
$classPath = $env:CLASSPATH_PREFIX + "";" + $classPath;
}

iex $javaCmd $env:JAVA_OPTS #EXTRA_JVM_ARGUMENTS# -classpath $classPath -Dapp.name="#APP_NAME#" -Dapp.repo="$repo" -Dapp.home="$baseDir" -Dbasedir="$baseDir" #MAINCLASS# #APP_ARGUMENTS#$args
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ----------------------------------------------------------------------------
# Copyright 2001-2006 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
#
# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
# reserved.


$baseDir = split-path -parent split-path -parent $MyInvocation.MyCommand.Definition

$setupScript = $PSScriptRoot + "\setup.ps1"; if (Test-Path $setupScript ) { &$setupScript }

if (-not (Test-Path env:JAVACMD) -Or ( $env:JAVACMD -eq "" )) {
$javaCmd=java
} else {
$javaCmd=$env:JAVACMD
}

if (-not (Test-Path env:REPO) -Or ( $env:REPO -eq "" )) {
$repo=$env:BASEDIR + "\" + repo
} else {
$repo=$env:REPO
}

$classPath=

if ((Test-Path env:ENDORSED_DIR) -Or ( $env:ENDORSED_DIR -ne "")) {
$classPath = $env:BASEDIR + "\" + $env:ENDORSED_DIR + "\*;" + $classPath;
}

if ((Test-Path env:CLASSPATH_PREFIX) -Or ( $env:CLASSPATH_PREFIX -ne "")) {
$classPath = $env:CLASSPATH_PREFIX + "";" + $classPath;
}

iex $javaCmd $env:JAVA_OPTS Yo dude xyz="%BASEDIR%" -classpath $classPath -Dapp.name="basedir-test" -Dapp.repo="$repo" -Dapp.home="$baseDir" -Dbasedir="$baseDir" foo.Bar $args
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ----------------------------------------------------------------------------
# Copyright 2001-2006 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
#
# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
# reserved.


$baseDir = split-path -parent split-path -parent $MyInvocation.MyCommand.Definition

$setupScript = $PSScriptRoot + "\setup.ps1"; if (Test-Path $setupScript ) { &$setupScript }

if (-not (Test-Path env:JAVACMD) -Or ( $env:JAVACMD -eq "" )) {
$javaCmd=java
} else {
$javaCmd=$env:JAVACMD
}

if (-not (Test-Path env:REPO) -Or ( $env:REPO -eq "" )) {
$repo=$env:BASEDIR + "\" + repo
} else {
$repo=$env:REPO
}

$classPath=

if ((Test-Path env:ENDORSED_DIR) -Or ( $env:ENDORSED_DIR -ne "")) {
$classPath = $env:BASEDIR + "\" + $env:ENDORSED_DIR + "\*;" + $classPath;
}

if ((Test-Path env:CLASSPATH_PREFIX) -Or ( $env:CLASSPATH_PREFIX -ne "")) {
$classPath = $env:CLASSPATH_PREFIX + "";" + $classPath;
}

iex $javaCmd $env:JAVA_OPTS Yo dude xyz="%REPO%" -classpath $classPath -Dapp.name="repo-test" -Dapp.repo="$repo" -Dapp.home="$baseDir" -Dbasedir="$baseDir" foo.Bar $args
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ----------------------------------------------------------------------------
# Copyright 2001-2006 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
#
# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
# reserved.


$baseDir = split-path -parent split-path -parent $MyInvocation.MyCommand.Definition

$setupScript = $PSScriptRoot + "\setup.ps1"; if (Test-Path $setupScript ) { &$setupScript }

if (-not (Test-Path env:JAVACMD) -Or ( $env:JAVACMD -eq "" )) {
$javaCmd=start /min javaw
} else {
$javaCmd=$env:JAVACMD
}

if (-not (Test-Path env:REPO) -Or ( $env:REPO -eq "" )) {
$repo=$env:BASEDIR + "\" + repo
} else {
$repo=$env:REPO
}

$classPath=

if ((Test-Path env:ENDORSED_DIR) -Or ( $env:ENDORSED_DIR -ne "")) {
$classPath = $env:BASEDIR + "\" + $env:ENDORSED_DIR + "\*;" + $classPath;
}

if ((Test-Path env:CLASSPATH_PREFIX) -Or ( $env:CLASSPATH_PREFIX -ne "")) {
$classPath = $env:CLASSPATH_PREFIX + "";" + $classPath;
}

iex $javaCmd $env:JAVA_OPTS Yo dude -classpath $classPath -Dapp.name="test" -Dapp.repo="$repo" -Dapp.home="$baseDir" -Dbasedir="$baseDir" foo.Bar $args
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ----------------------------------------------------------------------------
# Copyright 2001-2006 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
#
# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
# reserved.


$baseDir = split-path -parent split-path -parent $MyInvocation.MyCommand.Definition

$setupScript = $PSScriptRoot + "\setup.ps1"; if (Test-Path $setupScript ) { &$setupScript }

if (-not (Test-Path env:JAVACMD) -Or ( $env:JAVACMD -eq "" )) {
$javaCmd=java
} else {
$javaCmd=$env:JAVACMD
}

if (-not (Test-Path env:REPO) -Or ( $env:REPO -eq "" )) {
$repo=$env:BASEDIR + "\" + repo
} else {
$repo=$env:REPO
}

$classPath=

if ((Test-Path env:ENDORSED_DIR) -Or ( $env:ENDORSED_DIR -ne "")) {
$classPath = $env:BASEDIR + "\" + $env:ENDORSED_DIR + "\*;" + $classPath;
}

if ((Test-Path env:CLASSPATH_PREFIX) -Or ( $env:CLASSPATH_PREFIX -ne "")) {
$classPath = $env:CLASSPATH_PREFIX + "";" + $classPath;
}

iex $javaCmd $env:JAVA_OPTS Yo dude -classpath $classPath -Dapp.name="test-endorsed-lib" -Dapp.repo="$repo" -Dapp.home="$baseDir" -Dbasedir="$baseDir" foo.Bar $args
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ----------------------------------------------------------------------------
# Copyright 2001-2006 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
#
# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
# reserved.


$baseDir = split-path -parent split-path -parent $MyInvocation.MyCommand.Definition

$setupScript = $PSScriptRoot + "\setup.ps1"; if (Test-Path $setupScript ) { &$setupScript }

if (-not (Test-Path env:JAVACMD) -Or ( $env:JAVACMD -eq "" )) {
$javaCmd=java
} else {
$javaCmd=$env:JAVACMD
}

if (-not (Test-Path env:REPO) -Or ( $env:REPO -eq "" )) {
$repo=$env:BASEDIR + "\" + repo
} else {
$repo=$env:REPO
}

$classPath=

if ((Test-Path env:ENDORSED_DIR) -Or ( $env:ENDORSED_DIR -ne "")) {
$classPath = $env:BASEDIR + "\" + $env:ENDORSED_DIR + "\*;" + $classPath;
}

if ((Test-Path env:CLASSPATH_PREFIX) -Or ( $env:CLASSPATH_PREFIX -ne "")) {
$classPath = $env:CLASSPATH_PREFIX + "";" + $classPath;
}

iex $javaCmd $env:JAVA_OPTS Yo dude -classpath $classPath -Dapp.name="test" -Dapp.repo="$repo" -Dapp.home="$baseDir" -Dbasedir="$baseDir" foo.Bar $args