-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/adoble/adr-j
# Conflicts: # doc/usage/INSTALL.md # src/main/java/org/doble/adr/SystemEditorRunner.java
- Loading branch information
Showing
3 changed files
with
78 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,33 @@ | ||
# Install ADR-J | ||
|
||
## Windows | ||
|
||
1. Download the source code. | ||
2. Make sure you have gradle installed (https://gradle.org/). | ||
3. Run `gradlew releaseJar`. This should create a file `build/releases/adr-j.jar`. | ||
4. Set the environment variable `ADR_HOME` to the folder where you downloaded the source code. This should contain the `build` folder. | ||
5. Set the environment variable `EDITOR` or `VISUAL` to the location of the editor you what to use for editing the ADRs (e.g. Atom) | ||
6. Add `%ADR_HOME%\launch-scripts` to the `PATH` environment variable | ||
|
||
You should now be able to type `adr` from the command line and see a response. | ||
# Install ADR-J | ||
|
||
## Windows | ||
|
||
1. Download the source code. | ||
2. Make sure you have gradle installed (https://gradle.org/). | ||
3. Run `gradlew releaseJar`. This should create a file `build/releases/adr-j.jar`. | ||
4. Set the environment variable `ADR_HOME` to the folder where you downloaded the source code. This should contain the `build` folder. | ||
5. Set the environment variable `EDITOR` or `VISUAL` to the location of the editor you what to use for editing the ADRs (e.g. Atom) | ||
6. Add `%ADR_HOME%\launch-scripts` to the `PATH` environment variable | ||
|
||
You should now be able to type `adr` from the command line and see a response. | ||
|
||
## Unix | ||
|
||
1. Download the source code. | ||
2. Make sure you have gradle installed (https://gradle.org/). | ||
3. Run `.\gradlew releaseJar`. This should create a file `build/releases/adr-j.jar`. | ||
4. Set the environment variable `ADR_HOME` to the folder where you downloaded the source code. This should contain the `build` folder. For instance this could be done by using the adding the following to the `~/.bashrc` file: | ||
``` | ||
# For example | ||
export ADR_HOME=~/adr-j | ||
``` | ||
|
||
5. Set the environment variable `EDITOR` or `VISUAL` to the location of the editor you what to use for editing the ADRs (e.g. Atom), e.g. in the `~/.bashrc` file: | ||
``` | ||
# For example | ||
export EDITOR=/usr/bin/vi | ||
``` | ||
|
||
6. Move `%ADR_HOME%\launch-scripts\adr` to the `~/bin` directory. | ||
|
||
Of course, there are many other ways to install adr-j on unix depending on your personal preferences; important is that the environment variables are set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
java -jar $ADR_HOME/build/releases/adr-j.jar "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,43 @@ | ||
/** | ||
* Fires up the editor when the tool is being invoked from the command line. | ||
* | ||
*/ | ||
package org.doble.adr; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* @author adoble | ||
* | ||
*/ | ||
public class SystemEditorRunner extends EditorRunner { | ||
|
||
/* (non-Javadoc) | ||
* @see org.doble.adr.EditorRunner#run(java.nio.file.Path, org.doble.adr.Environment) | ||
*/ | ||
@Override | ||
public void run(Path path, String editorCommand) throws ADRException { | ||
|
||
// String adrFileName = path.getFileName().toString(); | ||
String adrPathName = path.toString(); | ||
|
||
try { | ||
Runtime runTime = Runtime.getRuntime(); | ||
String cmd = editorCommand + " " + adrPathName; | ||
runTime.exec(cmd); | ||
|
||
} catch (IOException e) { | ||
throw new ADRException("FATAL: Could not open the editor.", e); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
/** | ||
* Fires up the editor when the tool is being invoked from the command line. | ||
* | ||
*/ | ||
package org.doble.adr; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* @author adoble | ||
* | ||
*/ | ||
public class SystemEditorRunner extends EditorRunner { | ||
|
||
/* (non-Javadoc) | ||
* @see org.doble.adr.EditorRunner#run(java.nio.file.Path, org.doble.adr.Environment) | ||
*/ | ||
@Override | ||
public void run(Path path, String editorCommand) throws ADRException { | ||
|
||
String adrPathName = path.toString(); | ||
Process p = null; | ||
try { | ||
ProcessBuilder processBuilder = new ProcessBuilder(editorCommand,adrPathName); | ||
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT); | ||
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); | ||
processBuilder.redirectInput(ProcessBuilder.Redirect.INHERIT); | ||
|
||
p = processBuilder.start(); | ||
p.waitFor(); | ||
|
||
} catch (IOException | InterruptedException e) { | ||
throw new ADRException("FATAL: Could not open the editor.", e); | ||
} finally { | ||
if (p != null){ | ||
p.destroy(); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |