This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from fabianofernandeszup/fix-java8-template-b…
…uild-and-add-java11 Fix java8 template and add template java11
- Loading branch information
Showing
22 changed files
with
339 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM cimg/openjdk:11.0.5 | ||
|
||
USER root | ||
|
||
RUN mkdir /rit | ||
COPY . /rit | ||
RUN sed -i 's/\r//g' /rit/set_umask.sh | ||
RUN sed -i 's/\r//g' /rit/run.sh | ||
RUN chmod +x /rit/set_umask.sh | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["/rit/set_umask.sh"] | ||
CMD ["/rit/run.sh"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,37 @@ | ||
{ | ||
"dockerImageBuilder": "cimg/openjdk:11.0.5", | ||
"inputs": [ | ||
{ | ||
"cache": { | ||
"active": true, | ||
"newLabel": "Type new value. ", | ||
"qty": 6 | ||
}, | ||
"label": "Type : ", | ||
"name": "sample_text", | ||
"type": "text" | ||
}, | ||
{ | ||
"default": "in1", | ||
"items": [ | ||
"in_list1", | ||
"in_list2", | ||
"in_list3", | ||
"in_listN" | ||
], | ||
"label": "Pick your : ", | ||
"name": "sample_list", | ||
"type": "text" | ||
}, | ||
{ | ||
"default": "false", | ||
"items": [ | ||
"false", | ||
"true" | ||
], | ||
"label": "Pick: ", | ||
"name": "sample_bool", | ||
"type": "bool" | ||
} | ||
] | ||
} |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,32 @@ | ||
# JAVA | ||
BIN_FOLDER=bin | ||
SH=$(BIN_FOLDER)/run.sh | ||
BAT=$(BIN_FOLDER)/run.bat | ||
BUILD=mvn clean install | ||
CLEAN=mvn clean | ||
JAR_FILE=Main.jar | ||
TARGET=target | ||
|
||
build: java-build sh-unix bat-windows docker | ||
$(CLEAN) | ||
|
||
java-build: | ||
mkdir -p $(BIN_FOLDER) | ||
$(BUILD) | ||
mv $(TARGET)/$(JAR_FILE) $(BIN_FOLDER) | ||
rm -Rf $(TARGET) | ||
|
||
sh-unix: | ||
echo '#!/bin/sh' > $(SH) | ||
echo 'java -jar "$$(dirname "$$0")"/$(JAR_FILE)' >> $(SH) | ||
chmod +x $(SH) | ||
|
||
bat-windows: | ||
echo '@ECHO OFF' > $(BAT) | ||
echo 'java -jar $(JAR_FILE)' >> $(BAT) | ||
|
||
test: | ||
mvn clean install | ||
|
||
docker: | ||
cp Dockerfile set_umask.sh $(BIN_FOLDER) |
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,11 @@ | ||
# Ritchie Formula | ||
|
||
## command | ||
|
||
```bash | ||
#rit-replace{formulaCmd} | ||
``` | ||
|
||
## description | ||
|
||
description of formula |
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,33 @@ | ||
:: Java parameters | ||
echo off | ||
SETLOCAL | ||
SET BIN_FOLDER=bin | ||
SET BIN_NAME=Main.jar | ||
SET BAT_FILE=%BIN_FOLDER%\run.bat | ||
SET SH_FILE=%BIN_FOLDER%\run.sh | ||
:build | ||
call mvn clean install 1>&2 | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
mkdir %BIN_FOLDER% | ||
copy target\%BIN_NAME% %BIN_FOLDER%\%BIN_NAME% | ||
rmdir /Q /S target | ||
CALL :BAT_WINDOWS | ||
CALL :SH_LINUX | ||
CALL :CP_DOCKER | ||
GOTO DONE | ||
|
||
:BAT_WINDOWS | ||
echo @ECHO OFF > %BAT_FILE% | ||
echo java -jar %BIN_NAME% >> %BAT_FILE% | ||
GOTO DONE | ||
|
||
:SH_LINUX | ||
echo java -jar "$(dirname "$0")"/%BIN_NAME% > %SH_FILE% | ||
GOTO DONE | ||
|
||
:CP_DOCKER | ||
copy Dockerfile %BIN_FOLDER% | ||
copy set_umask.sh %BIN_FOLDER% | ||
GOTO DONE | ||
|
||
:DONE |
File renamed without changes.
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,17 @@ | ||
{ | ||
"execution": [ | ||
"local", | ||
"docker" | ||
], | ||
"os": { | ||
"deps": [], | ||
"support": [ | ||
"windows", | ||
"mac", | ||
"linux" | ||
] | ||
}, | ||
"tags": [ | ||
"#rit-replace{formulaTags}" | ||
] | ||
} |
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,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.ritchie</groupId> | ||
<artifactId>formula</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>${java.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.version}</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> | ||
</properties> | ||
|
||
<build> | ||
<finalName>Main</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<!-- Build an executable JAR --> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>${maven-jar-plugin.version}</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<!-- <addClasspath>true</addClasspath> --> | ||
<mainClass>com.ritchie.Main</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<appendAssemblyId>false</appendAssemblyId> | ||
<archive> | ||
<manifest> | ||
<mainClass>com.ritchie.Main</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
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,3 @@ | ||
#!/bin/sh | ||
umask 0011 | ||
$1 |
14 changes: 14 additions & 0 deletions
14
templates/create_formula/languages/java8/src/main/java/com/ritchie/Main.java
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,14 @@ | ||
package com.ritchie; | ||
|
||
import com.ritchie.formula.Formula; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
String input1 = System.getenv("SAMPLE_TEXT"); | ||
String input2 = System.getenv("SAMPLE_LIST"); | ||
boolean input3 = Boolean.parseBoolean(System.getenv("SAMPLE_BOOL")); | ||
Formula formula = new Formula(input1, input2, input3); | ||
System.out.println(formula.Run()); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
templates/create_formula/languages/java8/src/main/java/com/ritchie/formula/Formula.java
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,47 @@ | ||
package com.ritchie.formula; | ||
|
||
public class Formula { | ||
|
||
private String input1; | ||
private String input2; | ||
private boolean input3; | ||
|
||
public String Run() { | ||
return String.format( | ||
"Hello World!\n" | ||
+ "You receive %s in text.\n" | ||
+ "You receive %s in list.\n" | ||
+ "You receive %s in boolean.\n", | ||
input1, input2, input3); | ||
} | ||
|
||
public Formula(String input1, String input2, boolean input3) { | ||
this.input1 = input1; | ||
this.input2 = input2; | ||
this.input3 = input3; | ||
} | ||
|
||
public String getInput1() { | ||
return input1; | ||
} | ||
|
||
public void setInput1(String input1) { | ||
this.input1 = input1; | ||
} | ||
|
||
public String getInput2() { | ||
return input2; | ||
} | ||
|
||
public void setInput2(String input2) { | ||
this.input2 = input2; | ||
} | ||
|
||
public boolean isInput3() { | ||
return input3; | ||
} | ||
|
||
public void setInput3(boolean input3) { | ||
this.input3 = input3; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
templates/create_formula/languages/java8/src/test/java/com/ritchie/formula/FormulaTest.java
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,19 @@ | ||
package com.ritchie.formula; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
public class FormulaTest { | ||
|
||
@Test | ||
public void run() { | ||
Formula formula = new Formula("Hello", "World", true); | ||
String excpeted = | ||
"Hello World!\n" | ||
+ "You receive Hello in text.\n" | ||
+ "You receive World in list.\n" | ||
+ "You receive true in boolean.\n"; | ||
assertEquals(excpeted, formula.Run()); | ||
} | ||
} |