-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run example using Maven, no IDE required #4
Comments
I'll make it work :)
…Sent from my Commodore 64
On 26 Sep 2017, at 8:17 pm, Matt ***@***.***> wrote:
I noticed you mentioned that the current stuff can only be run using the IDE.
You could set up an execution target in Maven so that you can run it easily without the IDE. If you want to that is. The code I use is below ;-)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java></executable>
<mainClass>st.redline.Stic</mainClass>
<arguments>
<argument>st.redline.example.Test</argument>
</arguments>
</configuration>
</plugin>
The only problem with this, is you need to make your classpath handling more robust since Maven modifies the classpath at runtime, rather than specifying java.class.path variable.
Here's my hacky change to Stic's classPaths() method:
public String[] classPaths() {
String[] classPaths = classPath().split(File.pathSeparator);
ArrayList<String> urlClassPaths = new ArrayList<>(java.util.Arrays.asList(classPaths));
URLClassLoader cl = (URLClassLoader) (Thread.currentThread().getContextClassLoader());
for (URL url : cl.getURLs()) {
if ("file".equals(url.getProtocol())) {
urlClassPaths.add(url.getFile());
}
}
classPaths = urlClassPaths.toArray(classPaths);
return classPaths;
}
Cheers,
Matt
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
branch: jcl/classpath Redline must find a Smalltalk file in the classpath or in a JAR. You can run Redline from the command line with the following command to run Test.st java -cp redline-0.6-SNAPSHOT.jar -jar redline-0.6-SNAPSHOT.jar st.redline.example.Test NOTE When compiling with Maven (mvn clean package) the resulting JAR is in the target folder, including the Smalltalk sources so the following shorter command line also works. java -jar target/redline-0.6-SNAPSHOT.jar st.redline.example.Test |
I noticed you mentioned that the current stuff can only be run using the IDE.
You could set up an execution target in Maven so that you can run it easily without the IDE. If you want to that is. The code I use is below ;-)
The only problem with this, is you need to make your classpath handling more robust since Maven modifies the classpath at runtime, rather than specifying
java.class.path
variable.Here's my hacky change to Stic's
classPaths()
method:Cheers,
Matt
The text was updated successfully, but these errors were encountered: