Fixing runtime CLI on windows

This commit is contained in:
Clebert Suconic 2015-05-11 13:25:50 -04:00
parent efd6261d25
commit 5a3727c8f3
5 changed files with 98 additions and 22 deletions

View File

@ -131,8 +131,8 @@
<version>1.9</version>
<classifier>bin</classifier>
<type>exe</type>
<outputDirectory>${basedir}/target/classes/org/apache/artemis/cli/commands/bin</outputDirectory>
<destFileName>activemq-service.exe</destFileName>
<outputDirectory>${basedir}/target/classes/org/apache/activemq/artemis/cli/commands/bin/</outputDirectory>
<destFileName>artemis-service.exe</destFileName>
</artifactItem>
</artifactItems>
</configuration>

View File

@ -61,6 +61,19 @@ public class Create implements Action
private static final Integer HQ_PORT = 5445;
public static final String BIN_ARTEMIS_CMD = "bin/artemis.cmd";
public static final String BIN_ARTEMIS_SERVICE_EXE = "bin/artemis-service.exe";
public static final String BIN_ARTEMIS_SERVICE_XML = "bin/artemis-service.xml";
public static final String ETC_ARTEMIS_PROFILE_CMD = "etc/artemis.profile.cmd";
public static final String BIN_ARTEMIS = "bin/artemis";
public static final String BIN_ARTEMIS_SERVICE = "bin/artemis-service";
public static final String ETC_ARTEMIS_PROFILE = "etc/artemis.profile";
public static final String ETC_LOGGING_PROPERTIES = "etc/logging.properties";
public static final String ETC_BOOTSTRAP_XML = "etc/bootstrap.xml";
public static final String ETC_BROKER_XML = "etc/broker.xml";
public static final String ETC_ARTEMIS_ROLES_PROPERTIES = "etc/artemis-roles.properties";
public static final String ETC_ARTEMIS_USERS_PROPERTIES = "etc/artemis-users.properties";
@Arguments(description = "The instance directory to hold the broker's configuration and data", required = true)
File directory;
@ -116,6 +129,14 @@ public class Create implements Action
}
}
/** This method is made public for the testsuite */
public InputStream openStream(String source)
{
return this.getClass().getResourceAsStream(source);
}
public Object run(ActionContext context) throws Exception
{
this.context = context;
@ -205,34 +226,34 @@ public class Create implements Action
if (IS_WINDOWS)
{
write("bin/artemis.cmd", null, false);
write("bin/artemis-service.exe");
write("bin/artemis-service.xml", filters, false);
write("etc/artemis.profile.cmd", filters, false);
write(BIN_ARTEMIS_CMD, null, false);
write(BIN_ARTEMIS_SERVICE_EXE);
write(BIN_ARTEMIS_SERVICE_XML, filters, false);
write(ETC_ARTEMIS_PROFILE_CMD, filters, false);
}
if (!IS_WINDOWS || IS_CYGWIN)
{
write("bin/artemis", null, true);
makeExec("bin/artemis");
write("bin/artemis-service", null, true);
makeExec("bin/artemis-service");
write("etc/artemis.profile", filters, true);
makeExec("etc/artemis.profile");
write(BIN_ARTEMIS, null, true);
makeExec(BIN_ARTEMIS);
write(BIN_ARTEMIS_SERVICE, null, true);
makeExec(BIN_ARTEMIS_SERVICE);
write(ETC_ARTEMIS_PROFILE, filters, true);
makeExec(ETC_ARTEMIS_PROFILE);
}
write("etc/logging.properties", null, false);
write("etc/bootstrap.xml", null, false);
write("etc/broker.xml", filters, false);
write("etc/artemis-roles.properties", null, false);
write("etc/artemis-users.properties", null, false);
write(ETC_LOGGING_PROPERTIES, null, false);
write(ETC_BOOTSTRAP_XML, null, false);
write(ETC_BROKER_XML, filters, false);
write(ETC_ARTEMIS_ROLES_PROPERTIES, null, false);
write(ETC_ARTEMIS_USERS_PROPERTIES, null, false);
context.out.println("");
context.out.println("You can now start the broker by executing: ");
context.out.println("");
context.out.println(String.format(" \"%s\" run", path(new File(directory, "bin/artemis"), true)));
File service = new File(directory, "bin/artemis-service");
File service = new File(directory, BIN_ARTEMIS_SERVICE);
context.out.println("");
if (!IS_WINDOWS || IS_CYGWIN)
@ -351,7 +372,7 @@ public class Create implements Action
private String readTextFile(String source) throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (InputStream in = this.getClass().getResourceAsStream(source))
try (InputStream in = openStream(source))
{
copy(in, out);
}
@ -367,7 +388,7 @@ public class Create implements Action
}
try (FileOutputStream fout = new FileOutputStream(target))
{
try (InputStream in = this.getClass().getResourceAsStream(source))
try (InputStream in = openStream(source))
{
copy(in, fout);
}

View File

@ -25,7 +25,7 @@ set ARTEMIS_INSTANCE=%CD%
POPD
:CHECK_ARTEMIS_INSTANCE
if exist "%ARTEMIS_INSTANCE%\bin\activemq.cmd" goto CHECK_JAVA
if exist "%ARTEMIS_INSTANCE%\bin\artemis.cmd" goto CHECK_JAVA
:NO_HOME
echo ARTEMIS_INSTANCE environment variable is set incorrectly. Please set ARTEMIS_INSTANCE.

View File

@ -0,0 +1,55 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.activemq.artemis.test;
import java.io.InputStream;
import org.apache.activemq.artemis.cli.commands.Create;
import org.junit.Assert;
import org.junit.Test;
public class StreamClassPathTest
{
/** Validate if all the known resources are available on the classpath for the jar */
@Test
public void testFindStreams() throws Exception
{
openStream(Create.BIN_ARTEMIS_CMD);
openStream(Create.BIN_ARTEMIS_SERVICE_EXE);
openStream(Create.BIN_ARTEMIS_SERVICE_XML);
openStream(Create.ETC_ARTEMIS_PROFILE_CMD);
openStream(Create.BIN_ARTEMIS);
openStream(Create.BIN_ARTEMIS_SERVICE);
openStream(Create.ETC_ARTEMIS_PROFILE);
openStream(Create.ETC_LOGGING_PROPERTIES);
openStream(Create.ETC_BOOTSTRAP_XML);
openStream(Create.ETC_BROKER_XML);
openStream(Create.ETC_ARTEMIS_ROLES_PROPERTIES);
openStream(Create.ETC_ARTEMIS_USERS_PROPERTIES);
}
private void openStream(String source) throws Exception
{
Create create = new Create();
InputStream in = create.openStream(source);
Assert.assertNotNull(source + " not found", in);
in.close();
}
}

View File

@ -30,7 +30,7 @@ under the License.
<journal-directory>./target/journal</journal-directory>
<journal-min-files>10</journal-min-files>
<journal-min-files>2</journal-min-files>
<large-messages-directory>./target/large-messages</large-messages-directory>