├── .blaze ├── blaze.conf ├── blaze.java └── pom.xml ├── .github └── workflows │ ├── linux-java11.yaml │ ├── linux-java17.yaml │ ├── linux-java21.yaml │ ├── linux-java8.yaml │ ├── macos-arm64.yaml │ └── windows-x64.yaml ├── .gitignore ├── CHANGELOG.md ├── README.md ├── blaze-archive ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── fizzed │ │ └── blaze │ │ ├── Archives.java │ │ └── archive │ │ ├── ArchiveFormat.java │ │ ├── ArchiveFormats.java │ │ ├── ArchiveHelper.java │ │ ├── ArchiveInfo.java │ │ ├── Archiver.java │ │ ├── Compressor.java │ │ └── Unarchive.java │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── archive │ │ ├── ArchiveHelperTest.java │ │ └── UnarchiveTest.java │ └── resources │ └── fixtures │ ├── hello.txt.bz2 │ ├── hello.txt.gz │ ├── hello.txt.zst │ ├── sample-no-root-dir.tar │ ├── sample-no-root-dir.tar.bz2 │ ├── sample-no-root-dir.tar.gz │ ├── sample-no-root-dir.tar.xz │ ├── sample-no-root-dir.tar.zst │ ├── sample-no-root-dir.zip │ ├── sample-with-root-dir-encrypted.zip │ ├── sample-with-root-dir.7z │ ├── sample-with-root-dir.tar │ ├── sample-with-root-dir.tar.bz2 │ ├── sample-with-root-dir.tar.gz │ └── sample-with-root-dir.zip ├── blaze-core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── fizzed │ │ │ └── blaze │ │ │ ├── Config.java │ │ │ ├── Context.java │ │ │ ├── Contexts.java │ │ │ ├── Systems.java │ │ │ ├── Task.java │ │ │ ├── cli │ │ │ ├── Bootstrap.java │ │ │ ├── Bootstrap1.java │ │ │ └── JdkLoggerHelper.java │ │ │ ├── core │ │ │ ├── AbstractEngine.java │ │ │ ├── Action.java │ │ │ ├── Actions.java │ │ │ ├── Blaze.java │ │ │ ├── BlazeClassLoader.java │ │ │ ├── BlazeException.java │ │ │ ├── BlazeTask.java │ │ │ ├── CompilationException.java │ │ │ ├── ConsolePrompter.java │ │ │ ├── ContextHolder.java │ │ │ ├── DefaultContext.java │ │ │ ├── Dependency.java │ │ │ ├── DependencyResolveException.java │ │ │ ├── DependencyResolver.java │ │ │ ├── DependencyResolvers.java │ │ │ ├── DirectoryNotEmptyException.java │ │ │ ├── Engine.java │ │ │ ├── ExecMixin.java │ │ │ ├── ExecutableNotFoundException.java │ │ │ ├── FileNotFoundException.java │ │ │ ├── GlobberMixin.java │ │ │ ├── MavenProjectGenerator.java │ │ │ ├── MessageOnlyException.java │ │ │ ├── MissingConfigurationException.java │ │ │ ├── NoSuchTaskException.java │ │ │ ├── PathsMixin.java │ │ │ ├── PipeErrorMixin.java │ │ │ ├── PipeMixin.java │ │ │ ├── Prompter.java │ │ │ ├── Result.java │ │ │ ├── Script.java │ │ │ ├── ScriptFileLocator.java │ │ │ ├── UnexpectedExitValueException.java │ │ │ ├── UriMixin.java │ │ │ ├── Verbosity.java │ │ │ ├── VerbosityMixin.java │ │ │ └── WrappedBlazeException.java │ │ │ ├── internal │ │ │ ├── ClassLoaderHelper.java │ │ │ ├── ConfigHelper.java │ │ │ ├── ConfigImpl.java │ │ │ ├── ConfigPaths.java │ │ │ ├── ContextImpl.java │ │ │ ├── DefaultScriptFileLocator.java │ │ │ ├── DependencyHelper.java │ │ │ ├── EngineHelper.java │ │ │ ├── ExpectPrompter.java │ │ │ ├── FileHelper.java │ │ │ ├── InstallHelper.java │ │ │ ├── IntRangeHelper.java │ │ │ └── NoopDependencyResolver.java │ │ │ ├── jdk │ │ │ ├── BlazeJdkEngine.java │ │ │ ├── BlazeJdkScript.java │ │ │ └── TargetObjectScript.java │ │ │ ├── local │ │ │ ├── LocalExec.java │ │ │ └── LocalSession.java │ │ │ ├── system │ │ │ ├── Copy.java │ │ │ ├── Exec.java │ │ │ ├── ExecSession.java │ │ │ ├── Head.java │ │ │ ├── LineAction.java │ │ │ ├── Mkdir.java │ │ │ ├── Move.java │ │ │ ├── Pipeline.java │ │ │ ├── Prompt.java │ │ │ ├── Remove.java │ │ │ ├── RequireExec.java │ │ │ ├── Tail.java │ │ │ └── Which.java │ │ │ └── util │ │ │ ├── BasicPaths.java │ │ │ ├── BlazeRunner.java │ │ │ ├── BlazeUtils.java │ │ │ ├── ByteArray.java │ │ │ ├── BytePipe.java │ │ │ ├── ByteRingBuffer.java │ │ │ ├── CaptureOutput.java │ │ │ ├── CloseGuardedInputStream.java │ │ │ ├── CloseGuardedOutputStream.java │ │ │ ├── CommandLines.java │ │ │ ├── Converter.java │ │ │ ├── DeferredFileInputStream.java │ │ │ ├── DeferredFileOutputStream.java │ │ │ ├── DurationFormatter.java │ │ │ ├── Globber.java │ │ │ ├── HumanReadables.java │ │ │ ├── ImmutableUri.java │ │ │ ├── InputStreamPumper.java │ │ │ ├── IntRange.java │ │ │ ├── InterruptibleInputStream.java │ │ │ ├── LineOutputStream.java │ │ │ ├── MutableUri.java │ │ │ ├── NameValue.java │ │ │ ├── ObjectHelper.java │ │ │ ├── ProcessHandleReflected.java │ │ │ ├── ProcessHelper.java │ │ │ ├── ProcessHelper8.java │ │ │ ├── ProcessHelper9.java │ │ │ ├── ProcessReaper.java │ │ │ ├── SchemeProvider.java │ │ │ ├── Streamable.java │ │ │ ├── StreamableInput.java │ │ │ ├── StreamableOutput.java │ │ │ ├── Streamables.java │ │ │ ├── TerminalLine.java │ │ │ ├── Timer.java │ │ │ ├── VerboseLogger.java │ │ │ ├── WaitFor.java │ │ │ ├── WrappedInputStream.java │ │ │ └── WrappedOutputStream.java │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── com.fizzed.blaze.core.Engine │ │ └── bin │ │ ├── blaze │ │ ├── blaze.bat │ │ └── blaze.ps1 │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ ├── core │ │ ├── BlazeBuilderTest.java │ │ └── TestScriptObject.java │ │ ├── internal │ │ ├── ContextImplTest.java │ │ ├── DependencyHelperTest.java │ │ ├── DependencyTest.java │ │ └── EngineHelperTest.java │ │ ├── jdk │ │ ├── BlazeJdkEngineTest.java │ │ ├── DemoMain.java │ │ └── TargetObjectScriptTest.java │ │ ├── system │ │ ├── CopyTest.java │ │ ├── ExecCaptureOutputTest.java │ │ ├── ExecTest.java │ │ ├── MoveTest.java │ │ ├── RemoveTest.java │ │ ├── RequiredExecTest.java │ │ ├── ShellTestHelper.java │ │ ├── TailTest.java │ │ ├── TestAbstractBase.java │ │ └── WhichTest.java │ │ └── util │ │ ├── BasicPathTest.java │ │ ├── BytePipeTest.java │ │ ├── ConverterTest.java │ │ ├── GlobberTest.java │ │ ├── LineOutputStreamTest.java │ │ ├── MutableUriTest.java │ │ ├── ProcessHandleReflectedTest.java │ │ ├── ProcessHelperTest.java │ │ └── StreamablesMatchedTest.java │ └── resources │ ├── bin │ ├── echo-sleep-test │ ├── echo-sleep-test.bat │ ├── hello-world-test │ ├── hello-world-test.bat │ ├── hello-world-test2 │ ├── hello-world-test2.ps1 │ └── tee.exe │ ├── fixtures │ ├── pattern.txt │ └── resource-locator.txt │ ├── globber │ ├── globber.html │ ├── globber.txt │ └── src │ │ └── java │ │ └── java.txt │ ├── jdk │ ├── hello.java │ ├── only_public.java │ ├── project0 │ │ └── blaze.java │ ├── project1 │ │ └── blaze │ │ │ └── blaze.java │ ├── project2 │ │ └── .blaze │ │ │ └── blaze.java │ ├── project3 │ │ └── .blaze │ │ │ ├── blaze.conf │ │ │ └── blaze.java │ └── project4 │ │ └── .blaze │ │ ├── blaze.conf │ │ ├── blaze.java │ │ └── blaze.local.conf │ └── logback.xml ├── blaze-docker ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── docker │ │ ├── DockerConnect.java │ │ ├── DockerExec.java │ │ ├── DockerSession.java │ │ ├── Dockers.java │ │ └── impl │ │ ├── HeaderToken.java │ │ └── ProcessRow.java │ └── test │ └── java │ └── com │ └── fizzed │ └── blaze │ └── docker │ ├── Demo.java │ ├── DockerExecTest.java │ ├── DockerTestHelper.java │ └── DockersTest.java ├── blaze-groovy ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── fizzed │ │ │ └── blaze │ │ │ └── groovy │ │ │ ├── BlazeGroovyEngine.java │ │ │ └── BlazeGroovyScript.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.fizzed.blaze.core.Engine │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── groovy │ │ ├── BlazeGroovyEngineTest.java │ │ └── TryIt.java │ └── resources │ └── groovy │ ├── compile_fail.groovy │ ├── empty.groovy │ ├── hello.groovy │ ├── message_only_exception.groovy │ ├── script_initialized.groovy │ └── two_tasks.groovy ├── blaze-haproxy ├── pom.xml └── src │ ├── main │ ├── docker │ │ ├── Dockerfile │ │ └── haproxy.cfg │ └── java │ │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── haproxy │ │ ├── HaproxyConnect.java │ │ ├── HaproxyInfo.java │ │ ├── HaproxySession.java │ │ ├── HaproxyStat.java │ │ ├── HaproxyStats.java │ │ ├── Haproxys.java │ │ └── impl │ │ └── HaproxySessionImpl.java │ └── test │ └── java │ └── com │ └── fizzed │ └── blaze │ └── haproxy │ └── Demo.java ├── blaze-http ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── fizzed │ │ └── blaze │ │ ├── Https.java │ │ └── http │ │ └── Http.java │ └── test │ └── java │ └── com │ └── fizzed │ └── blaze │ └── http │ └── HttpTest.java ├── blaze-ivy ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── fizzed │ │ │ └── blaze │ │ │ └── ivy │ │ │ ├── AuthenticationException.java │ │ │ ├── IvyAuthenticator.java │ │ │ ├── IvyDependencyResolver.java │ │ │ ├── MavenRepositoryUrl.java │ │ │ ├── MavenServer.java │ │ │ └── MavenSettings.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.fizzed.blaze.core.DependencyResolver │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── ivy │ │ ├── IvyDependencyResolverTest.java │ │ └── MavenSettingsTest.java │ └── resources │ ├── logback.xml │ └── maven-settings.xml ├── blaze-kotlin ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── fizzed │ │ │ └── blaze │ │ │ └── kotlin │ │ │ ├── BlazeKotlinEngine.java │ │ │ ├── BlazeKotlinScript.java │ │ │ ├── CountingSLF4JMessageCollector.java │ │ │ ├── KotlinCompiler.java │ │ │ └── KotlinSourceFile.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.fizzed.blaze.core.Engine │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── kotlin │ │ ├── BlazeKotlinEngineTest.java │ │ └── Demo.java │ └── resources │ └── kotlin │ ├── hello.kt │ ├── noclazz.kt │ └── only_public.kt ├── blaze-lite ├── pom.xml └── src │ └── main │ └── resources │ ├── logging.properties │ └── simplelogger.properties ├── blaze-mysql ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── mysql │ │ ├── MysqlConnect.java │ │ ├── MysqlInfo.java │ │ ├── MysqlSession.java │ │ └── Mysqls.java │ └── test │ └── java │ └── com │ └── fizzed │ └── blaze │ └── mysql │ └── Demo.java ├── blaze-nashorn ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── fizzed │ │ │ └── blaze │ │ │ └── nashorn │ │ │ ├── BlazeNashornEngine.java │ │ │ └── BlazeNashornScript.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.fizzed.blaze.core.Engine │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── nashorn │ │ └── BlazeNashornEngineTest.java │ └── resources │ └── nashorn │ ├── blaze.js │ ├── capture_output.js │ ├── dependency.conf │ ├── dependency.js │ ├── empty.js │ ├── hello.js │ ├── log.js │ ├── new_default_task.conf │ ├── new_default_task.js │ ├── noengine.txt │ └── two_tasks.js ├── blaze-postoffice ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── fizzed │ │ └── blaze │ │ ├── PostOffices.java │ │ └── postoffice │ │ └── Mail.java │ └── test │ └── java │ └── com │ └── fizzed │ └── blaze │ └── postoffice │ └── MailTest.java ├── blaze-ssh ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── fizzed │ │ │ └── blaze │ │ │ ├── SecureShells.java │ │ │ └── ssh │ │ │ ├── SshChainedConnect.java │ │ │ ├── SshConnect.java │ │ │ ├── SshException.java │ │ │ ├── SshExec.java │ │ │ ├── SshFile.java │ │ │ ├── SshFileAttributes.java │ │ │ ├── SshProvider.java │ │ │ ├── SshSession.java │ │ │ ├── SshSftp.java │ │ │ ├── SshSftpException.java │ │ │ ├── SshSftpGet.java │ │ │ ├── SshSftpNoSuchFileException.java │ │ │ ├── SshSftpPut.java │ │ │ ├── SshSftpSession.java │ │ │ ├── impl │ │ │ ├── JschConnect.java │ │ │ ├── JschExec.java │ │ │ ├── JschExecProxy.java │ │ │ ├── JschProvider.java │ │ │ ├── JschSession.java │ │ │ ├── JschSftp.java │ │ │ ├── JschSftpSession.java │ │ │ ├── PathHelper.java │ │ │ ├── SshScpBETA.java │ │ │ ├── SshSftpSupport.java │ │ │ └── SshSupport.java │ │ │ └── util │ │ │ ├── ProxyCommand.java │ │ │ └── SshCommand.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.fizzed.blaze.ssh.SshProvider │ └── test │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── ssh │ │ ├── SshBaseTest.java │ │ ├── SshCommand.java │ │ ├── SshCommandHandler.java │ │ ├── SshConnectTest.java │ │ ├── SshExecTest.java │ │ ├── SshIntegrationTest.java │ │ ├── SshUtils.java │ │ ├── TestHelper.java │ │ └── util │ │ └── SshCommandTest.java │ └── resources │ ├── example │ ├── lib │ │ ├── lib.txt │ │ └── more │ │ │ └── more.txt │ └── test1.txt │ ├── logback.xml │ └── sshd │ ├── .ssh │ ├── config │ ├── id_rsa │ └── id_rsa.pub │ ├── public_key │ └── .ssh │ │ ├── id_rsa │ │ └── id_rsa.pub │ └── ssh-test.txt ├── blaze-vagrant ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── fizzed │ │ └── blaze │ │ └── vagrant │ │ └── VagrantSshProvider.java │ └── resources │ └── META-INF │ └── services │ └── com.fizzed.blaze.ssh.SshProvider ├── blaze.jar ├── buildx-results.txt ├── docs ├── BASIC.md ├── CONFIG.md ├── DEV.md ├── EXAMPLES.md ├── HTTP.md ├── SSH.md ├── WHY.md └── blaze-demo.gif ├── examples ├── find_java.conf ├── find_java.java ├── git.conf ├── git.groovy ├── git.java ├── git.js ├── globber.groovy ├── globber.java ├── globber.js ├── globber.kt ├── globber.kts ├── grep.conf ├── grep.java ├── guava.conf ├── guava.groovy ├── guava.java ├── guava.js ├── hello.groovy ├── hello.java ├── hello.js ├── hello.kt ├── http.conf ├── http.groovy ├── http.java ├── http.js ├── javac.groovy ├── javac.java ├── javac.js ├── ls.conf ├── ls.java ├── natives.conf ├── natives.java ├── pipeline.java ├── pipeline.txt ├── prompt.java ├── sftp.conf ├── sftp.java ├── ssh.conf ├── ssh.java ├── try_all.java ├── undertow.conf ├── undertow.groovy ├── undertow.java └── undertow.js └── pom.xml /.blaze/blaze.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:blaze-ssh" 3 | "com.fizzed:blaze-public-project:1.0.1" 4 | ] 5 | 6 | java.source.version = 8 -------------------------------------------------------------------------------- /.blaze/blaze.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import com.fizzed.blaze.Contexts; 18 | import static com.fizzed.blaze.Contexts.withBaseDir; 19 | 20 | import com.fizzed.blaze.Task; 21 | import com.fizzed.blaze.core.Blaze; 22 | import com.fizzed.blaze.project.PublicBlaze; 23 | 24 | import java.util.List; 25 | import java.util.stream.Collectors; 26 | 27 | import com.fizzed.buildx.Target; 28 | import org.slf4j.Logger; 29 | 30 | public class blaze extends PublicBlaze { 31 | static private final Logger log = Contexts.logger(); 32 | 33 | @Task(order=1, value="Try all scripts in examples/ dir") 34 | public void try_all() throws Exception { 35 | // execute another blaze script in this jvm 36 | new Blaze.Builder() 37 | .file(withBaseDir("../examples/try_all.java")) 38 | .build() 39 | .execute(); 40 | } 41 | 42 | @Override 43 | protected List crossTestTargets() { 44 | return super.crossTestTargets().stream() 45 | .filter(v -> !v.getArch().contains("riscv64")) 46 | .filter(v -> !v.getOs().contains("freebsd")) 47 | .filter(v -> !v.getOs().contains("openbsd")) 48 | .collect(Collectors.toList()); 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /.github/workflows/linux-java11.yaml: -------------------------------------------------------------------------------- 1 | name: Java 11 2 | 3 | on: 4 | push 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Azul JDK 11 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: 11 15 | distribution: 'zulu' 16 | cache: 'maven' 17 | - name: Test in Maven 18 | run: mvn test 19 | -------------------------------------------------------------------------------- /.github/workflows/linux-java17.yaml: -------------------------------------------------------------------------------- 1 | name: Java 17 2 | 3 | on: 4 | push 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Azul JDK 17 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: 17 15 | distribution: 'zulu' 16 | cache: 'maven' 17 | - name: Test in Maven 18 | run: mvn test 19 | -------------------------------------------------------------------------------- /.github/workflows/linux-java21.yaml: -------------------------------------------------------------------------------- 1 | name: Java 21 2 | 3 | on: 4 | push 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Azul JDK 21 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: 21 15 | distribution: 'zulu' 16 | cache: 'maven' 17 | - name: Test in Maven 18 | run: mvn test 19 | -------------------------------------------------------------------------------- /.github/workflows/linux-java8.yaml: -------------------------------------------------------------------------------- 1 | name: Java 8 2 | 3 | on: 4 | push 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Azul JDK 8 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: 8 15 | distribution: 'zulu' 16 | cache: 'maven' 17 | - name: Test in Maven 18 | run: mvn test 19 | -------------------------------------------------------------------------------- /.github/workflows/macos-arm64.yaml: -------------------------------------------------------------------------------- 1 | name: MacOS arm64 2 | 3 | on: 4 | push 5 | 6 | jobs: 7 | build: 8 | runs-on: macos-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Azul JDK 11 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: 11 15 | distribution: 'zulu' 16 | cache: 'maven' 17 | - name: Test in Maven 18 | run: mvn test -------------------------------------------------------------------------------- /.github/workflows/windows-x64.yaml: -------------------------------------------------------------------------------- 1 | name: Windows x64 2 | 3 | on: 4 | push 5 | 6 | jobs: 7 | build: 8 | runs-on: windows-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Azul JDK 11 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: 11 15 | distribution: 'zulu' 16 | cache: 'maven' 17 | - name: Test in Maven 18 | run: mvn test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | target 3 | blaze-lite/dependency-reduced-pom.xml 4 | ssh/src/test/java/ssh.* 5 | *.iml 6 | examples/pom.xml 7 | .idea 8 | .buildx 9 | -------------------------------------------------------------------------------- /blaze-archive/src/main/java/com/fizzed/blaze/Archives.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze; 2 | 3 | import com.fizzed.blaze.archive.Unarchive; 4 | 5 | import java.io.File; 6 | import java.nio.file.Path; 7 | import java.nio.file.Paths; 8 | 9 | public class Archives { 10 | 11 | static public Unarchive unarchive(Path file) { 12 | return new Unarchive(Contexts.currentContext(), file); 13 | } 14 | 15 | static public Unarchive unarchive(File file) { 16 | return new Unarchive(Contexts.currentContext(), file.toPath()); 17 | } 18 | 19 | static public Unarchive unarchive(String file) { 20 | return new Unarchive(Contexts.currentContext(), Paths.get(file)); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /blaze-archive/src/main/java/com/fizzed/blaze/archive/ArchiveFormat.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.archive; 2 | 3 | public class ArchiveFormat { 4 | 5 | final private Archiver archiver; 6 | final private Compressor compressor; 7 | final private String[] extensions; 8 | 9 | public ArchiveFormat(Archiver archiver, Compressor compressor, String... extensions) { 10 | this.archiver = archiver; 11 | this.compressor = compressor; 12 | this.extensions = extensions; 13 | } 14 | 15 | public Archiver getArchiver() { 16 | return archiver; 17 | } 18 | 19 | public Compressor getCompressor() { 20 | return compressor; 21 | } 22 | 23 | public String[] getExtensions() { 24 | return extensions; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /blaze-archive/src/main/java/com/fizzed/blaze/archive/ArchiveFormats.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.archive; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ArchiveFormats { 7 | 8 | static public final List ALL; 9 | static { 10 | ALL = new ArrayList<>(); 11 | // build our compatability list, then add in any special extra cases (e.g. extensions) 12 | // add all the archives in first 13 | for (Archiver archiver : Archiver.values()) { 14 | ALL.add(new ArchiveFormat(archiver, null, archiver.getExtension())); 15 | } 16 | 17 | // .tar archives can simply be compressed with any compression we support 18 | for (Compressor compressor : Compressor.values()) { 19 | ALL.add(new ArchiveFormat(Archiver.TAR, compressor, Archiver.TAR.getExtension() + compressor.getExtension())); 20 | } 21 | 22 | // .tgz special case 23 | ALL.add(new ArchiveFormat(Archiver.TAR, Compressor.GZ, ".tgz")); 24 | 25 | // all compressors too 26 | for (Compressor compressor : Compressor.values()) { 27 | ALL.add(new ArchiveFormat(null, compressor, compressor.getExtension())); 28 | } 29 | } 30 | 31 | /* 32 | static public ArchiveFormat detectByFileName(String fileName) { 33 | final String n = fileName.toLowerCase(); 34 | 35 | // find the longest matching extension 36 | String matchedExtension = null; 37 | ArchiveFormat matchedFormat = null; 38 | 39 | for (ArchiveFormat af : ALL) { 40 | for (String ext : af.getExtensions()) { 41 | if (n.endsWith(ext) && (matchedExtension == null || ext.length() > matchedExtension.length())) { 42 | matchedExtension = ext; 43 | matchedFormat = af; 44 | } 45 | } 46 | } 47 | 48 | return matchedFormat; 49 | }*/ 50 | 51 | } -------------------------------------------------------------------------------- /blaze-archive/src/main/java/com/fizzed/blaze/archive/ArchiveInfo.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.archive; 2 | 3 | public class ArchiveInfo { 4 | 5 | private Archiver archiver; 6 | private Compressor compressor; 7 | private String archivedName; 8 | private String unarchivedName; 9 | 10 | public ArchiveInfo(Archiver archiver, Compressor compressor, String archivedName, String unarchivedName) { 11 | this.archiver = archiver; 12 | this.compressor = compressor; 13 | this.archivedName = archivedName; 14 | this.unarchivedName = unarchivedName; 15 | } 16 | 17 | public Archiver getArchiver() { 18 | return archiver; 19 | } 20 | 21 | public ArchiveInfo setArchiver(Archiver archiver) { 22 | this.archiver = archiver; 23 | return this; 24 | } 25 | 26 | public Compressor getCompressor() { 27 | return compressor; 28 | } 29 | 30 | public ArchiveInfo setCompressor(Compressor compressor) { 31 | this.compressor = compressor; 32 | return this; 33 | } 34 | 35 | public String getArchivedName() { 36 | return archivedName; 37 | } 38 | 39 | public ArchiveInfo setArchivedName(String archivedName) { 40 | this.archivedName = archivedName; 41 | return this; 42 | } 43 | 44 | public String getUnarchivedName() { 45 | return unarchivedName; 46 | } 47 | 48 | public ArchiveInfo setUnarchivedName(String unarchivedName) { 49 | this.unarchivedName = unarchivedName; 50 | return this; 51 | } 52 | } -------------------------------------------------------------------------------- /blaze-archive/src/main/java/com/fizzed/blaze/archive/Archiver.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.archive; 2 | 3 | public enum Archiver { 4 | 5 | ZIP(".zip"), 6 | TAR(".tar"), 7 | SEVENZ(".7z"); 8 | 9 | private final String extension; 10 | 11 | Archiver(String extension) { 12 | this.extension = extension; 13 | } 14 | 15 | public String getExtension() { 16 | return extension; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /blaze-archive/src/main/java/com/fizzed/blaze/archive/Compressor.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.archive; 2 | 3 | public enum Compressor { 4 | 5 | GZ(".gz"), 6 | BZ2(".bz2"), 7 | XZ(".xz"), 8 | ZSTD(".zst"); 9 | 10 | private final String extension; 11 | 12 | Compressor(String extension) { 13 | this.extension = extension; 14 | } 15 | 16 | public String getExtension() { 17 | return extension; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/hello.txt.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/hello.txt.bz2 -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/hello.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/hello.txt.gz -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/hello.txt.zst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/hello.txt.zst -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.bz2 -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.gz -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.xz -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.zst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-no-root-dir.tar.zst -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-no-root-dir.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-no-root-dir.zip -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-with-root-dir-encrypted.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-with-root-dir-encrypted.zip -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-with-root-dir.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-with-root-dir.7z -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-with-root-dir.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-with-root-dir.tar.bz2 -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-with-root-dir.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-with-root-dir.tar.gz -------------------------------------------------------------------------------- /blaze-archive/src/test/resources/fixtures/sample-with-root-dir.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-archive/src/test/resources/fixtures/sample-with-root-dir.zip -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze; 17 | 18 | import java.io.File; 19 | import java.nio.file.Path; 20 | import org.slf4j.Logger; 21 | 22 | /** 23 | * 24 | * @author joelauer 25 | */ 26 | public interface Context { 27 | 28 | Config config(); 29 | 30 | Logger logger(); 31 | 32 | Path scriptFile(); 33 | 34 | Path baseDir(); 35 | 36 | Path withBaseDir(Path path); 37 | 38 | Path withBaseDir(File file); 39 | 40 | Path withBaseDir(String path); 41 | 42 | Path userDir(); 43 | 44 | Path withUserDir(Path path); 45 | 46 | Path withUserDir(File file); 47 | 48 | Path withUserDir(String path); 49 | 50 | void fail(String message); 51 | 52 | String prompt(String prompt, Object... args); 53 | 54 | char[] passwordPrompt(String prompt, Object... args); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/Task.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Target(ElementType.METHOD) 25 | public @interface Task { 26 | 27 | String value() default ""; 28 | 29 | int order() default 0; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/cli/Bootstrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.cli; 17 | 18 | import com.fizzed.blaze.core.BlazeClassLoader; 19 | import java.net.URL; 20 | 21 | public class Bootstrap { 22 | 23 | static public void main(String[] args) throws Exception { 24 | BlazeClassLoader blazeClassLoader = new BlazeClassLoader( 25 | new URL[0], Thread.currentThread().getContextClassLoader()); 26 | 27 | // 28 | 29 | Class bootstrap1Class = blazeClassLoader.loadClass(Bootstrap1.class.getCanonicalName()); 30 | Bootstrap1 bootstrap1 = (Bootstrap1)bootstrap1Class.newInstance(); 31 | 32 | Thread.currentThread().setContextClassLoader(blazeClassLoader); 33 | 34 | bootstrap1.run(args); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/AbstractEngine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.Context; 19 | import java.util.List; 20 | 21 | abstract public class AbstractEngine implements Engine { 22 | 23 | protected Context initialContext; 24 | 25 | @Override 26 | public boolean isInitialized() { 27 | return initialContext != null; 28 | } 29 | 30 | @Override 31 | public void init(Context initialContext) throws BlazeException { 32 | this.initialContext = initialContext; 33 | } 34 | 35 | @Override 36 | public List getFileExtensions() { 37 | throw new UnsupportedOperationException(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.Context; 19 | 20 | public abstract class Action,V> { 21 | 22 | protected final Context context; 23 | protected volatile boolean used; 24 | 25 | public Action(Context context) { 26 | this.context = context; 27 | } 28 | 29 | public R runResult() throws BlazeException { 30 | if (used) { 31 | throw new BlazeException("Can only run once"); 32 | } 33 | R result = this.doRun(); 34 | used = true; 35 | return result; 36 | } 37 | 38 | public V run() throws BlazeException { 39 | return runResult().get(); 40 | } 41 | 42 | abstract protected R doRun() throws BlazeException; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Actions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.util.CaptureOutput; 19 | import com.fizzed.blaze.util.StreamableOutput; 20 | 21 | public class Actions { 22 | 23 | static public CaptureOutput toCaptureOutput(A action, R result) { 24 | StreamableOutput output = action.getPipeOutput(); 25 | 26 | if (!(output instanceof CaptureOutput)) { 27 | throw new IllegalArgumentException("Action " + action.getClass().getCanonicalName() + " did not have a pipeOutput set to an instance of " + CaptureOutput.class.getCanonicalName()); 28 | } 29 | 30 | return (CaptureOutput)output; 31 | } 32 | 33 | static public CaptureOutput toCaptureError(A action, R result) { 34 | StreamableOutput output = action.getPipeError(); 35 | 36 | if (!(output instanceof CaptureOutput)) { 37 | throw new IllegalArgumentException("Action " + action.getClass().getCanonicalName() + " did not have a pipeError set to an instance of " + CaptureOutput.class.getCanonicalName()); 38 | } 39 | 40 | return (CaptureOutput)output; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/BlazeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | /** 19 | * 20 | * @author joelauer 21 | */ 22 | public class BlazeException extends RuntimeException { 23 | 24 | /** 25 | * Constructs an instance of BlazeException with the specified 26 | * detail message. 27 | * 28 | * @param msg the detail message. 29 | */ 30 | public BlazeException(String msg) { 31 | super(msg); 32 | } 33 | 34 | public BlazeException(String msg, Throwable cause) { 35 | super(msg, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/CompilationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | /** 19 | * 20 | * @author joelauer 21 | */ 22 | public class CompilationException extends MessageOnlyException { 23 | 24 | /** 25 | * Constructs an instance of MessageOnlyException with the 26 | * specified detail message. 27 | * 28 | * @param msg the detail message. 29 | */ 30 | public CompilationException(String msg) { 31 | super(msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/ConsolePrompter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import java.io.BufferedReader; 19 | import java.io.IOException; 20 | import java.io.InputStreamReader; 21 | 22 | /** 23 | * 24 | * @author joelauer 25 | */ 26 | public class ConsolePrompter implements Prompter { 27 | 28 | @Override 29 | public String prompt(String prompt, Object... args) { 30 | if (System.console() != null) { 31 | return System.console().readLine(prompt, args); 32 | } 33 | System.out.print(String.format(prompt, args)); 34 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 35 | try { 36 | return reader.readLine(); 37 | } catch (IOException e) { 38 | throw new BlazeException(e.getMessage(), e); 39 | } 40 | } 41 | 42 | @Override 43 | public char[] passwordPrompt(String prompt, Object... args) { 44 | if (System.console() != null) { 45 | return System.console().readPassword(prompt, args); 46 | } 47 | return prompt(prompt, args).toCharArray(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/ContextHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.internal.ContextImpl; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class ContextHolder { 28 | private static final Logger log = LoggerFactory.getLogger(ContextHolder.class); 29 | 30 | private static final ThreadLocal CONTEXT = 31 | new ThreadLocal() { 32 | @Override protected ContextImpl initialValue() { 33 | log.info("Creating default context for thread " + Thread.currentThread().getName()); 34 | return new DefaultContext(); 35 | } 36 | }; 37 | 38 | static public void set(Context context) { 39 | // set context to the the thread local 40 | CONTEXT.set(context); 41 | } 42 | 43 | static public Context get() { 44 | Context context = CONTEXT.get(); 45 | 46 | if (context == null) { 47 | throw new IllegalStateException("Context not bound. Did you forget to call " 48 | + ContextHolder.class.getCanonicalName() + ".set(context)?"); 49 | } 50 | 51 | return context; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/DefaultContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.internal.ConfigHelper; 19 | import com.fizzed.blaze.internal.ContextImpl; 20 | 21 | public class DefaultContext extends ContextImpl { 22 | 23 | public DefaultContext() { 24 | super(null, null, null, ConfigHelper.create(null)); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/DependencyResolveException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.core.BlazeException; 19 | 20 | /** 21 | * 22 | * @author joelauer 23 | */ 24 | public class DependencyResolveException extends BlazeException { 25 | 26 | /** 27 | * Constructs an instance of DependencyResolveException with 28 | * the specified detail message. 29 | * 30 | * @param msg the detail message. 31 | */ 32 | public DependencyResolveException(String msg) { 33 | super(msg); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/DependencyResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.Context; 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.text.ParseException; 22 | import java.util.List; 23 | 24 | /** 25 | * Resolves a list of dependencies to a list of Files (jars) that need to be 26 | * available locally on the filesystem. 27 | * 28 | * @author jjlauer 29 | */ 30 | public interface DependencyResolver { 31 | 32 | List resolve(Context context, List resolvedDependencies, List dependencies) throws DependencyResolveException, ParseException, IOException; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/DependencyResolvers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.internal.NoopDependencyResolver; 19 | import java.util.Iterator; 20 | import java.util.ServiceLoader; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | public interface DependencyResolvers { 25 | static final Logger log = LoggerFactory.getLogger(DependencyResolvers.class); 26 | 27 | static public DependencyResolver load() { 28 | ServiceLoader loader = ServiceLoader.load(DependencyResolver.class); 29 | Iterator iterator = loader.iterator(); 30 | 31 | DependencyResolver resolver = null; 32 | while (iterator.hasNext()) { 33 | DependencyResolver r = iterator.next(); 34 | if (resolver != null) { 35 | throw new IllegalStateException("Multiple dependency resolvers on classpath!"); 36 | } 37 | resolver = r; 38 | } 39 | 40 | if (resolver == null) { 41 | // fallback to resolver that does nothing 42 | return new NoopDependencyResolver(); 43 | } 44 | 45 | return resolver; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/DirectoryNotEmptyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | public class DirectoryNotEmptyException extends BlazeException { 19 | 20 | public DirectoryNotEmptyException(String msg) { 21 | super(msg); 22 | } 23 | 24 | public DirectoryNotEmptyException(String msg, Throwable cause) { 25 | super(msg, cause); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Engine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.Context; 19 | import java.util.List; 20 | 21 | public interface Engine { 22 | 23 | public String getName(); 24 | 25 | public List getFileExtensions(); 26 | 27 | public boolean isInitialized(); 28 | 29 | public void init(Context initialContext) throws BlazeException; 30 | 31 | public S compile(Context context) throws BlazeException; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/ExecutableNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.core.BlazeException; 19 | 20 | /** 21 | * 22 | * @author joelauer 23 | */ 24 | public class ExecutableNotFoundException extends BlazeException { 25 | 26 | /** 27 | * Constructs an instance of ExecutableNotFoundException with 28 | * the specified detail message. 29 | * 30 | * @param msg the detail message. 31 | */ 32 | public ExecutableNotFoundException(String msg) { 33 | super(msg); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/FileNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.core.BlazeException; 19 | 20 | /** 21 | * 22 | * @author joelauer 23 | */ 24 | public class FileNotFoundException extends BlazeException { 25 | 26 | public FileNotFoundException(String msg) { 27 | super(msg); 28 | } 29 | 30 | public FileNotFoundException(String msg, Throwable cause) { 31 | super(msg, cause); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/MessageOnlyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | /** 19 | * 20 | * @author joelauer 21 | */ 22 | public class MessageOnlyException extends BlazeException { 23 | 24 | /** 25 | * Constructs an instance of MessageOnlyException with the 26 | * specified detail message. 27 | * 28 | * @param msg the detail message. 29 | */ 30 | public MessageOnlyException(String msg) { 31 | super(msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/MissingConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.core.BlazeException; 19 | 20 | /** 21 | * 22 | * @author joelauer 23 | */ 24 | public class MissingConfigurationException extends BlazeException { 25 | 26 | /** 27 | * Constructs an instance of MissingConfigurationException with 28 | * the specified detail message. 29 | * 30 | * @param msg the detail message. 31 | */ 32 | public MissingConfigurationException(String msg) { 33 | super(msg); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/NoSuchTaskException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.core.MessageOnlyException; 19 | 20 | /** 21 | * 22 | * @author joelauer 23 | */ 24 | public class NoSuchTaskException extends MessageOnlyException { 25 | 26 | final private String task; 27 | 28 | public NoSuchTaskException(String task) { 29 | this(task, "Task '" + task + "' not found"); 30 | } 31 | 32 | public NoSuchTaskException(String task, String msg) { 33 | super(msg); 34 | this.task = task; 35 | } 36 | 37 | public String getTask() { 38 | return task; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/PipeErrorMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.util.StreamableOutput; 19 | import com.fizzed.blaze.util.Streamables; 20 | import java.io.File; 21 | import java.io.OutputStream; 22 | import java.nio.file.Path; 23 | 24 | /** 25 | * Mixin with pipeError support. 26 | * 27 | * @author joelauer 28 | * @param 29 | */ 30 | public interface PipeErrorMixin extends PipeMixin { 31 | 32 | StreamableOutput getPipeError(); 33 | 34 | T pipeError(StreamableOutput pipeError); 35 | 36 | default public T pipeError(OutputStream stream) { 37 | return pipeError(Streamables.output(stream)); 38 | } 39 | 40 | default public T pipeError(Path path) { 41 | return pipeError(Streamables.output(path)); 42 | } 43 | 44 | default public T pipeError(File file) { 45 | return pipeError(Streamables.output(file)); 46 | } 47 | 48 | default public T disablePipeError() { 49 | return pipeError((StreamableOutput)null); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Prompter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | /** 19 | * 20 | * @author joelauer 21 | */ 22 | public interface Prompter { 23 | 24 | String prompt(String prompt, Object... args); 25 | 26 | char[] passwordPrompt(String prompt, Object... args); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Result.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import java.util.function.BiFunction; 19 | 20 | public class Result { 21 | 22 | private final A action; 23 | private final V value; 24 | 25 | public Result(A action, V value) { 26 | this.action = action; 27 | this.value = value; 28 | } 29 | 30 | public A action() { 31 | return this.action; 32 | } 33 | 34 | public V get() { 35 | return this.value; 36 | } 37 | 38 | public U map(BiFunction mapper) { 39 | return mapper.apply(action, (R)this); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Script.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import java.util.List; 19 | 20 | public interface Script { 21 | 22 | List tasks() throws BlazeException; 23 | 24 | void execute(String task) throws Exception; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/ScriptFileLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import java.nio.file.Path; 19 | 20 | /** 21 | * Locates a script file. 22 | * 23 | * @author joelauer 24 | */ 25 | public interface ScriptFileLocator { 26 | 27 | public Path locate(Path directory) throws BlazeException; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/UnexpectedExitValueException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.util.IntRange; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * 24 | * @author joelauer 25 | */ 26 | public class UnexpectedExitValueException extends BlazeException { 27 | 28 | final private List expected; 29 | final private Integer actual; 30 | 31 | /** 32 | * Constructs an instance of MessageOnlyException with the 33 | * specified detail message. 34 | * 35 | * @param msg the detail message. 36 | */ 37 | public UnexpectedExitValueException(String msg, List expected, Integer actual) { 38 | super(msg + " (expected = " + expected + "; actual = " + actual + ")"); 39 | this.expected = expected; 40 | this.actual = actual; 41 | } 42 | 43 | public List getExpected() { 44 | return expected; 45 | } 46 | 47 | public Integer getActual() { 48 | return actual; 49 | } 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/UriMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.util.MutableUri; 19 | 20 | /** 21 | * Mixin for directly supplying MutableUri methods in an action by simply 22 | * providing a getUri() method. 23 | * 24 | * @author joelauer 25 | */ 26 | public interface UriMixin { 27 | 28 | public MutableUri getUri(); 29 | 30 | default public T host(String host) { 31 | getUri().host(host); 32 | return (T)this; 33 | } 34 | 35 | default public T port(Integer port) { 36 | getUri().port(port); 37 | return (T)this; 38 | } 39 | 40 | default public T username(String username) { 41 | getUri().username(username); 42 | return (T)this; 43 | } 44 | 45 | default public T password(String password) { 46 | getUri().password(password); 47 | return (T)this; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/Verbosity.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.core; 2 | 3 | public enum Verbosity { 4 | 5 | DEFAULT(0), 6 | VERBOSE(1), 7 | DEBUG(2), 8 | TRACE(3); 9 | 10 | final int level; 11 | 12 | Verbosity(int level) { 13 | this.level = level; 14 | } 15 | 16 | public int getLevel() { 17 | return this.level; 18 | } 19 | 20 | public Verbosity from(int value) { 21 | for (Verbosity v : Verbosity.values()) { 22 | if (value == v.level) { 23 | return v; 24 | } 25 | } 26 | throw new IllegalArgumentException("Unable to find Verbosity for value " + value); 27 | } 28 | 29 | public boolean gte(Verbosity other) { 30 | return this.level >= other.level; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/VerbosityMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | import com.fizzed.blaze.util.VerboseLogger; 19 | 20 | /** 21 | * Mixin for path() in an action by simply providing a getPaths() method. 22 | * 23 | * @author joelauer 24 | */ 25 | public interface VerbosityMixin { 26 | 27 | VerboseLogger getVerboseLogger(); 28 | 29 | default T verbose() { 30 | return this.verbosity(Verbosity.VERBOSE); 31 | } 32 | 33 | default T debug() { 34 | return this.verbosity(Verbosity.DEBUG); 35 | } 36 | 37 | default T trace() { 38 | return this.verbosity(Verbosity.TRACE); 39 | } 40 | 41 | default T verbosity(Verbosity verbosity) { 42 | this.getVerboseLogger().setLevel(verbosity); 43 | return (T)this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/core/WrappedBlazeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | public class WrappedBlazeException extends BlazeException { 19 | 20 | public WrappedBlazeException(Throwable t) { 21 | super(t.getMessage(), t); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/internal/ConfigPaths.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.internal; 2 | 3 | import java.nio.file.Path; 4 | 5 | public class ConfigPaths { 6 | 7 | private final Path primaryFile; 8 | private final Path localFile; 9 | 10 | public ConfigPaths(Path primaryFile, Path localFile) { 11 | this.primaryFile = primaryFile; 12 | this.localFile = localFile; 13 | } 14 | 15 | public Path getPrimaryFile() { 16 | return primaryFile; 17 | } 18 | 19 | public Path getLocalFile() { 20 | return localFile; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/internal/EngineHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.internal; 17 | 18 | import com.fizzed.blaze.core.Engine; 19 | import java.util.Iterator; 20 | import java.util.List; 21 | import java.util.ServiceLoader; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | public class EngineHelper { 26 | static private final Logger log = LoggerFactory.getLogger(EngineHelper.class); 27 | 28 | private static final ServiceLoader ENGINE_LOADER 29 | = ServiceLoader.load(Engine.class, ClassLoaderHelper.currentThreadContextClassLoader()); 30 | 31 | static public Engine findByFileExtension(String fileExtension, boolean invalidateCache) { 32 | if (invalidateCache) { 33 | ENGINE_LOADER.reload(); 34 | } 35 | 36 | Iterator iterator = ENGINE_LOADER.iterator(); 37 | 38 | while (iterator.hasNext()) { 39 | Engine engine = iterator.next(); 40 | 41 | List exts = engine.getFileExtensions(); 42 | for (String ext : exts) { 43 | if (ext.equals(fileExtension)) { 44 | return engine; 45 | } 46 | } 47 | } 48 | 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/internal/ExpectPrompter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.internal; 17 | 18 | import com.fizzed.blaze.core.Prompter; 19 | import java.util.LinkedList; 20 | import java.util.Queue; 21 | 22 | /** 23 | * 24 | * @author joelauer 25 | */ 26 | public class ExpectPrompter implements Prompter { 27 | 28 | private final Queue answers; 29 | 30 | public ExpectPrompter() { 31 | this.answers = new LinkedList<>(); 32 | } 33 | 34 | public Queue answers() { 35 | return this.answers; 36 | } 37 | 38 | public void add(String answer) { 39 | this.answers.add(answer); 40 | } 41 | 42 | public void verifyHasNextAnswer(String prompt) { 43 | if (answers.isEmpty()) { 44 | throw new IllegalStateException("No answer provided beforehand for " + prompt); 45 | } 46 | } 47 | 48 | @Override 49 | public String prompt(String prompt, Object... args) { 50 | verifyHasNextAnswer(prompt); 51 | return this.answers.remove(); 52 | } 53 | 54 | @Override 55 | public char[] passwordPrompt(String prompt, Object... args) { 56 | verifyHasNextAnswer(prompt); 57 | return this.answers.remove().toCharArray(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/internal/IntRangeHelper.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.internal; 2 | 3 | import com.fizzed.blaze.util.IntRange; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class IntRangeHelper { 9 | 10 | static public boolean contains(List values, Integer value) { 11 | for (IntRange range : values) { 12 | if (range.matches(value)) { 13 | return true; 14 | } 15 | } 16 | return false; 17 | } 18 | 19 | static public Integer[] toExpandedArray(List values) { 20 | // create an array of the entire int range 21 | final List _values = new ArrayList<>(); 22 | for (IntRange v : values) { 23 | for (int i = v.getFrom(); i <= v.getTo(); i++) { 24 | _values.add(i); 25 | } 26 | } 27 | return _values.toArray(new Integer[0]); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/internal/NoopDependencyResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.internal; 17 | 18 | import com.fizzed.blaze.core.Dependency; 19 | import com.fizzed.blaze.core.DependencyResolveException; 20 | import com.fizzed.blaze.core.DependencyResolver; 21 | import com.fizzed.blaze.Context; 22 | import java.io.File; 23 | import java.io.IOException; 24 | import java.text.ParseException; 25 | import java.util.List; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * Dependency resolver that does nothing. 31 | */ 32 | public class NoopDependencyResolver implements DependencyResolver { 33 | private static final Logger log = LoggerFactory.getLogger(NoopDependencyResolver.class); 34 | 35 | @Override 36 | public List resolve(Context context, List resolvedDependencies, List dependencies) throws DependencyResolveException, ParseException, IOException { 37 | log.trace("Noop resolving in effect (doing nothing)"); 38 | return null; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/jdk/BlazeJdkScript.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.jdk; 17 | 18 | public class BlazeJdkScript extends TargetObjectScript { 19 | 20 | public BlazeJdkScript(Object targetObject) { 21 | super(targetObject); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/local/LocalSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.local; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.system.Exec; 20 | import com.fizzed.blaze.system.ExecSession; 21 | import com.fizzed.blaze.util.ImmutableUri; 22 | import com.fizzed.blaze.util.MutableUri; 23 | 24 | public class LocalSession implements ExecSession { 25 | 26 | static private final MutableUri LOCAL_URL = new MutableUri("local://localhost"); 27 | private final Context context; 28 | 29 | public LocalSession(Context context) { 30 | this.context = context; 31 | } 32 | 33 | @Override 34 | public Exec newExec() { 35 | return new LocalExec(context); 36 | } 37 | 38 | @Override 39 | public ImmutableUri uri() { 40 | return LOCAL_URL; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/system/ExecSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.system; 17 | 18 | import com.fizzed.blaze.util.ImmutableUri; 19 | 20 | public interface ExecSession { 21 | 22 | public ImmutableUri uri(); 23 | 24 | public Exec newExec(); 25 | 26 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/system/Head.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.system; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.core.BlazeException; 20 | import com.fizzed.blaze.core.PipeMixin; 21 | import java.util.Deque; 22 | import static com.fizzed.blaze.util.Streamables.lineOutput; 23 | 24 | public class Head extends LineAction> implements PipeMixin { 25 | 26 | public Head(Context context) { 27 | super(context); 28 | } 29 | 30 | @Override 31 | protected Result doRun() throws BlazeException { 32 | Deque processedLines = LineAction.processLines(this.charset, this, (lines) -> { 33 | return lineOutput((line) -> { 34 | if (lines.size() < this.count) { 35 | lines.add(line); 36 | } 37 | // discard rest... 38 | }); 39 | }); 40 | return new Result(this, processedLines); 41 | } 42 | 43 | static public class Result extends com.fizzed.blaze.core.Result,Result> { 44 | 45 | Result(Head action, Deque value) { 46 | super(action, value); 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/system/Tail.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.system; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.core.BlazeException; 20 | import static com.fizzed.blaze.util.Streamables.lineOutput; 21 | import java.util.Deque; 22 | 23 | public class Tail extends LineAction> { 24 | 25 | public Tail(Context context) { 26 | super(context); 27 | } 28 | 29 | @Override 30 | protected Result doRun() throws BlazeException { 31 | Deque processedLines = LineAction.processLines(this.charset, this, (lines) -> { 32 | return lineOutput((line) -> { 33 | if (lines.size() >= this.count) { 34 | lines.remove(); 35 | } 36 | lines.add(line); 37 | }); 38 | }); 39 | return new Tail.Result(this, processedLines); 40 | } 41 | 42 | static public class Result extends com.fizzed.blaze.core.Result,Result> { 43 | 44 | Result(Tail action, Deque value) { 45 | super(action, value); 46 | } 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/BlazeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | import com.fizzed.blaze.core.BlazeException; 19 | import java.util.concurrent.TimeUnit; 20 | 21 | public class BlazeUtils { 22 | 23 | static public void sleep(long millis) { 24 | try { 25 | Thread.sleep(millis); 26 | } catch (InterruptedException e) { 27 | throw new BlazeException(e.getMessage(), e); 28 | } 29 | } 30 | 31 | static public void sleep(long timeout, TimeUnit timeUnit) { 32 | try { 33 | Thread.sleep(timeUnit.toMillis(timeout)); 34 | } catch (InterruptedException e) { 35 | throw new BlazeException(e.getMessage(), e); 36 | } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/CommandLines.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.util; 2 | 3 | import java.util.List; 4 | 5 | public class CommandLines { 6 | 7 | static public String debug(List commands) { 8 | StringBuilder sb = new StringBuilder(); 9 | 10 | for (String command : commands) { 11 | if (sb.length() > 0) { 12 | sb.append(" "); 13 | } 14 | // do we need quotes? 15 | if (command.contains(" ")) { 16 | sb.append("\""); 17 | sb.append(command); 18 | sb.append("\""); 19 | } else { 20 | sb.append(command); 21 | } 22 | } 23 | 24 | return sb.toString(); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/DurationFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | public class DurationFormatter { 19 | 20 | static public String format(double millis) { 21 | return format((long)millis); 22 | } 23 | 24 | static public String format(long millis) { 25 | int seconds = (int) (millis / 1000) % 60 ; 26 | int minutes = (int) ((millis / (1000*60)) % 60); 27 | int hours = (int) ((millis / (1000*60*60)) % 24); 28 | // int days = (int) (millis / (1000*60*60*24)); 29 | 30 | if (hours > 0) { 31 | return String.format("%02d:%02d:%02d", hours, minutes, seconds); 32 | } else { 33 | return String.format("%02d:%02d", minutes, seconds); 34 | } 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/HumanReadables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | public class HumanReadables { 19 | 20 | static public double kilobytes(long bytes) { 21 | return kilobytes((double)bytes); 22 | } 23 | 24 | static public double kilobytes(double bytes) { 25 | return bytes / 1024d; 26 | } 27 | 28 | static public double megabytes(long bytes) { 29 | return megabytes((double)bytes); 30 | } 31 | 32 | static public double megabytes(double bytes) { 33 | return (double)bytes / 1024d / 1024d; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/ImmutableUri.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * 22 | * @author joelauer 23 | */ 24 | public interface ImmutableUri { 25 | 26 | String getFragment(); 27 | 28 | String getHost(); 29 | 30 | List> getParameters(); 31 | 32 | String getPassword(); 33 | 34 | String getPath(); 35 | 36 | Integer getPort(); 37 | 38 | String getScheme(); 39 | 40 | String getUsername(); 41 | 42 | @Override 43 | String toString(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/IntRange.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.util; 2 | 3 | public class IntRange { 4 | 5 | private final Integer from; 6 | private final Integer to; 7 | 8 | public IntRange(Integer from, Integer to) { 9 | this.from = from; 10 | this.to = to; 11 | if (from > to) { 12 | throw new IllegalArgumentException("From must be less than to"); 13 | } 14 | } 15 | 16 | public Integer getFrom() { 17 | return from; 18 | } 19 | 20 | public Integer getTo() { 21 | return to; 22 | } 23 | 24 | public boolean matches(Integer value) { 25 | return value >= from && value <= to; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return from + "->" + to; 31 | } 32 | 33 | @Override 34 | public final boolean equals(Object o) { 35 | if (!(o instanceof IntRange)) return false; 36 | 37 | IntRange intRange = (IntRange) o; 38 | return from.equals(intRange.from) && to.equals(intRange.to); 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | int result = from.hashCode(); 44 | result = 31 * result + to.hashCode(); 45 | return result; 46 | } 47 | 48 | static public IntRange intRange(Integer from, Integer to) { 49 | return new IntRange(from, to); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/NameValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | public class NameValue { 19 | 20 | final private N name; 21 | final private V value; 22 | 23 | public NameValue(N name, V value) { 24 | ObjectHelper.requireNonNull(name, "name cannot be null"); 25 | this.name = name; 26 | this.value = value; 27 | } 28 | 29 | public N name() { 30 | return name; 31 | } 32 | 33 | public V value() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return name + "=" + value; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/ProcessHelper.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.util; 2 | 3 | public interface ProcessHelper { 4 | 5 | void destroy(Process process, long normalTerminationTimeoutMillis) throws InterruptedException; 6 | 7 | void destroyWithDescendants(Process process, long normalTerminationTimeoutMillis) throws InterruptedException; 8 | 9 | static ProcessHelper get() { 10 | if (ProcessHelper9.isAvailable()) { 11 | return new ProcessHelper9(); 12 | } else { 13 | return new ProcessHelper8(); 14 | } 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/ProcessHelper8.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | public class ProcessHelper8 implements ProcessHelper { 7 | static private final Logger log = LoggerFactory.getLogger(ProcessHelper8.class); 8 | 9 | @Override 10 | public void destroy(Process process, long normalTerminationTimeoutMillis) throws InterruptedException { 11 | if (process.isAlive()) { 12 | log.debug("Destroying/killing process w/ normal termination {} (will wait {} ms)", process, normalTerminationTimeoutMillis); 13 | // try to destroy process normally, then wait till timeout 14 | process.destroy(); 15 | boolean killed = new WaitFor(() -> !process.isAlive()).await(normalTerminationTimeoutMillis, 100L); 16 | if (!killed) { 17 | log.debug("Normal termination timed out. Destroying/killing process {} forcibly", process); 18 | process.destroyForcibly(); 19 | } 20 | } 21 | } 22 | 23 | @Override 24 | public void destroyWithDescendants(Process process, long normalTerminationTimeoutMillis) throws InterruptedException { 25 | // this is not supported on java 8, so we'll only do the main process 26 | log.debug("Destroying processes with descendants is only supported on Java 9+ (so we will only destroy parent process instead)"); 27 | this.destroy(process, normalTerminationTimeoutMillis); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/SchemeProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | import java.util.Iterator; 19 | import java.util.List; 20 | import java.util.Objects; 21 | import java.util.ServiceLoader; 22 | 23 | public interface SchemeProvider { 24 | 25 | List schemes(); 26 | 27 | static public

P load(String scheme, Class

type) { 28 | ServiceLoader

loader = ServiceLoader.load(type); 29 | Iterator

iterator = loader.iterator(); 30 | while (iterator.hasNext()) { 31 | P provider = iterator.next(); 32 | for (String s : provider.schemes()) { 33 | if (Objects.equals(s, scheme)) { 34 | return provider; 35 | } 36 | } 37 | } 38 | throw new IllegalArgumentException("Unsupported scheme '" + scheme + "' (no provider on classpath?)"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/Streamable.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.util; 2 | 3 | import java.io.Closeable; 4 | import java.io.IOException; 5 | import java.nio.file.Path; 6 | import java.util.Objects; 7 | 8 | public abstract class Streamable implements Closeable { 9 | 10 | protected final T stream; 11 | protected final String name; 12 | protected final Path path; 13 | protected final Long size; 14 | 15 | public Streamable(T stream, String name, Path path, Long size) { 16 | Objects.requireNonNull(stream, "stream cannot be null"); 17 | Objects.requireNonNull(name, "name cannot be null"); 18 | this.stream = stream; 19 | this.name = name; 20 | this.path = path; 21 | this.size = size; 22 | } 23 | 24 | public T stream() { 25 | return stream; 26 | } 27 | 28 | public String name() { 29 | return name; 30 | } 31 | 32 | public Path path() { 33 | return path; 34 | } 35 | 36 | public Long size() { 37 | return size; 38 | } 39 | 40 | @Override 41 | public void close() throws IOException { 42 | stream.close(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/StreamableInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | import java.io.InputStream; 19 | import java.nio.file.Path; 20 | 21 | public class StreamableInput extends Streamable { 22 | 23 | public StreamableInput(InputStream stream, String name, Path path, Long size) { 24 | super(stream, name, path, size); 25 | } 26 | 27 | /** 28 | static private InputStream maybeWrap(final InputStream stream, final boolean closeable) { 29 | if (closeable) { 30 | return stream; 31 | } else { 32 | return new CloseGuardedInputStream(stream); 33 | } 34 | } 35 | */ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/Timer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | /** 19 | * Simple timing utility. 20 | * 21 | * @author joelauer 22 | */ 23 | public class Timer { 24 | 25 | final private long start; 26 | private long stop; 27 | 28 | public Timer() { 29 | this.start = System.currentTimeMillis(); 30 | } 31 | 32 | public Timer stop() { 33 | this.stop = System.currentTimeMillis(); 34 | return this; 35 | } 36 | 37 | public long elapsed() { 38 | if (this.stop == 0) { 39 | return System.currentTimeMillis() - this.start; 40 | } 41 | return (this.stop - this.start); 42 | } 43 | 44 | public long millis() { 45 | return (this.stop - this.start); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return this.elapsed() + " ms"; 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /blaze-core/src/main/java/com/fizzed/blaze/util/WrappedOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.util; 17 | 18 | import java.io.IOException; 19 | import java.io.OutputStream; 20 | import java.util.Objects; 21 | 22 | /** 23 | * Wraps an output stream. Useful for subclassing and overriding methods 24 | * to either listen for events or modify behavior slightly (e.g. not allowing 25 | * a stream to actually be closed). 26 | * 27 | * @author joelauer 28 | */ 29 | public class WrappedOutputStream extends OutputStream { 30 | 31 | final protected OutputStream output; 32 | 33 | public WrappedOutputStream(OutputStream output) { 34 | Objects.requireNonNull(output, "output cannot be null"); 35 | this.output = output; 36 | } 37 | 38 | @Override 39 | public void close() throws IOException { 40 | output.close(); 41 | } 42 | 43 | @Override 44 | public void flush() throws IOException { 45 | output.flush(); 46 | } 47 | 48 | @Override 49 | public void write(byte[] b, int off, int len) throws IOException { 50 | output.write(b, off, len); 51 | } 52 | 53 | @Override 54 | public void write(byte[] b) throws IOException { 55 | output.write(b); 56 | } 57 | 58 | @Override 59 | public void write(int b) throws IOException { 60 | output.write(b); 61 | } 62 | } -------------------------------------------------------------------------------- /blaze-core/src/main/resources/META-INF/services/com.fizzed.blaze.core.Engine: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.jdk.BlazeJdkEngine -------------------------------------------------------------------------------- /blaze-core/src/main/resources/bin/blaze: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | java -jar blaze.jar "$@" -------------------------------------------------------------------------------- /blaze-core/src/main/resources/bin/blaze.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | java -jar blaze.jar %* -------------------------------------------------------------------------------- /blaze-core/src/main/resources/bin/blaze.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-core/src/main/resources/bin/blaze.ps1 -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/core/TestScriptObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.core; 17 | 18 | public class TestScriptObject { 19 | 20 | public void main() { 21 | // do nothing 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/internal/ContextImplTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.internal; 17 | 18 | import java.nio.file.Files; 19 | import java.nio.file.Path; 20 | import java.nio.file.Paths; 21 | import java.util.Optional; 22 | import static org.hamcrest.CoreMatchers.is; 23 | import static org.hamcrest.CoreMatchers.not; 24 | import static org.hamcrest.CoreMatchers.nullValue; 25 | import static org.junit.Assert.assertThat; 26 | import org.junit.Test; 27 | 28 | public class ContextImplTest { 29 | 30 | @Test 31 | public void dirIfExists() { 32 | assertThat(ContextImpl.dirIfExists(null), is(Optional.empty())); 33 | assertThat(ContextImpl.dirIfExists("."), is(Optional.of(Paths.get(".")))); 34 | } 35 | 36 | @Test 37 | public void findUserDir() { 38 | Path userDir = ContextImpl.findUserDir(); 39 | assertThat(userDir, is(not(nullValue()))); 40 | assertThat(Files.isDirectory(userDir), is(true)); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/internal/DependencyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.internal; 17 | 18 | import com.fizzed.blaze.core.Dependency; 19 | import java.util.HashSet; 20 | import java.util.Set; 21 | import static org.hamcrest.CoreMatchers.is; 22 | import static org.hamcrest.CoreMatchers.not; 23 | import static org.junit.Assert.assertThat; 24 | import org.junit.Test; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class DependencyTest { 31 | 32 | @Test 33 | public void testEquals() { 34 | Dependency a = new Dependency("com.example", "hello", "1.0.0"); 35 | Dependency b = new Dependency("com.example", "hello", "1.0.1"); 36 | Dependency c = new Dependency("com.example", "hello", "1.0.0"); 37 | 38 | assertThat(a.equals(b), is(not(true))); 39 | assertThat(a.equals(c), is(true)); 40 | 41 | Set set = new HashSet<>(); 42 | 43 | set.add(a); 44 | 45 | assertThat(set.contains(b), is(not(true))); 46 | assertThat(set.contains(c), is(true)); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/internal/EngineHelperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.internal; 17 | 18 | import com.fizzed.blaze.internal.EngineHelper; 19 | import com.fizzed.blaze.core.Engine; 20 | import static org.hamcrest.CoreMatchers.not; 21 | import static org.hamcrest.CoreMatchers.sameInstance; 22 | import static org.junit.Assert.assertThat; 23 | import org.junit.Ignore; 24 | import org.junit.Test; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class EngineHelperTest { 31 | 32 | @Test @Ignore("service loader does return same instance") 33 | public void newInstanceReturned() { 34 | Engine engine0 = EngineHelper.findByFileExtension(".java", false); 35 | 36 | Engine engine1 = EngineHelper.findByFileExtension(".java", false); 37 | 38 | assertThat(engine0, not(sameInstance(engine1))); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/jdk/DemoMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.jdk; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.internal.ContextImpl; 20 | import com.fizzed.blaze.internal.FileHelper; 21 | import com.fizzed.blaze.util.Timer; 22 | import java.io.File; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class DemoMain { 31 | static private final Logger log = LoggerFactory.getLogger(DemoMain.class); 32 | 33 | static public void main(String[] args) throws Exception { 34 | File scriptFile = FileHelper.resourceAsFile("/jdk/hello.java"); 35 | 36 | Context context = new ContextImpl(null, null, scriptFile.toPath(), null); 37 | 38 | BlazeJdkEngine engine = new BlazeJdkEngine(); 39 | 40 | engine.init(context); 41 | 42 | Timer timer = new Timer(); 43 | 44 | BlazeJdkScript script = engine.compile(context); 45 | 46 | log.info("Compiled in {} ms", timer.stop().millis()); 47 | 48 | script.execute("main"); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/jdk/TargetObjectScriptTest.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.jdk; 2 | 3 | import com.fizzed.blaze.core.BlazeTask; 4 | import org.junit.Test; 5 | 6 | import java.util.List; 7 | import java.util.Set; 8 | import java.util.stream.Collectors; 9 | 10 | import static org.hamcrest.CoreMatchers.hasItems; 11 | import static org.hamcrest.CoreMatchers.is; 12 | import static org.hamcrest.Matchers.hasSize; 13 | import static org.junit.Assert.*; 14 | 15 | public class TargetObjectScriptTest { 16 | 17 | static public class TestA { 18 | 19 | static public void helloStatic() {} 20 | 21 | public void helloWorldA() {} 22 | 23 | } 24 | 25 | static public class TestB extends TestA { 26 | 27 | static public void helloStatic() {} 28 | 29 | public void helloWorldB() {} 30 | 31 | } 32 | 33 | @Test 34 | public void tasksFromA() { 35 | TargetObjectScript tos = new TargetObjectScript(new TestA()); 36 | 37 | List tasks = tos.tasks(); 38 | 39 | assertThat(tasks, hasSize(1)); 40 | assertThat(tasks.get(0).getName(), is("helloWorldA")); 41 | } 42 | 43 | @Test 44 | public void tasksFromB() { 45 | TargetObjectScript tos = new TargetObjectScript(new TestB()); 46 | 47 | List tasks = tos.tasks(); 48 | 49 | assertThat(tasks, hasSize(2)); 50 | 51 | // get a hashset of names 52 | Set taskNames = tasks.stream().map(v -> v.getName()).collect(Collectors.toSet()); 53 | 54 | assertThat(taskNames, hasItems("helloWorldB", "helloWorldA")); 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/system/ShellTestHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.system; 17 | 18 | import com.fizzed.blaze.internal.FileHelper; 19 | import java.io.File; 20 | 21 | /** 22 | * 23 | * @author joelauer 24 | */ 25 | public class ShellTestHelper { 26 | 27 | static public File getBinDirAsResource() throws Exception { 28 | // fix permissions from maven copy (otherwise test fails) 29 | FileHelper.resourceAsFile("/bin/hello-world-test").setExecutable(true); 30 | FileHelper.resourceAsFile("/bin/hello-world-test.bat").setExecutable(true); 31 | FileHelper.resourceAsFile("/bin/hello-world-test2").setExecutable(true); 32 | FileHelper.resourceAsFile("/bin/hello-world-test2.ps1").setExecutable(true); 33 | 34 | // must use a resource that exists to then get its parent 35 | return FileHelper.resourceAsFile("/bin/hello-world-test").getParentFile(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/system/TailTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.system; 17 | 18 | import java.io.StringReader; 19 | import java.util.Deque; 20 | import org.apache.commons.io.input.ReaderInputStream; 21 | import static org.hamcrest.CoreMatchers.is; 22 | import static org.junit.Assert.assertThat; 23 | import org.junit.Test; 24 | 25 | /** 26 | * 27 | * @author Joe Lauer 28 | */ 29 | public class TailTest { 30 | 31 | @Test 32 | public void works() throws Exception { 33 | Tail tail = new Tail(null); 34 | 35 | String s = "a\nb\nc\n"; 36 | 37 | StringReader sr = new StringReader(s); 38 | 39 | tail.pipeInput(new ReaderInputStream(sr)); 40 | 41 | Deque output = tail.run(); 42 | 43 | assertThat(output.size(), is(3)); 44 | assertThat(output.remove(), is("a")); 45 | assertThat(output.remove(), is("b")); 46 | assertThat(output.remove(), is("c")); 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /blaze-core/src/test/java/com/fizzed/blaze/util/ProcessHandleReflectedTest.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze.util; 2 | 3 | import com.fizzed.jne.JavaVersion; 4 | import org.junit.Test; 5 | 6 | import java.util.List; 7 | 8 | import static org.hamcrest.MatcherAssert.assertThat; 9 | import static org.hamcrest.Matchers.*; 10 | 11 | public class ProcessHandleReflectedTest { 12 | 13 | static private final JavaVersion JAVA_VERSION = JavaVersion.current(); 14 | 15 | @Test 16 | public void current() { 17 | // this should 100% work on Java 9+ 18 | if (JAVA_VERSION.getMajor() >= 9) { 19 | ProcessHandleReflected currentHandle = ProcessHandleReflected.current(); 20 | 21 | long pid = currentHandle.pid(); 22 | 23 | assertThat(pid, greaterThan(0L)); 24 | } 25 | } 26 | 27 | @Test 28 | public void isAlive() { 29 | if (JAVA_VERSION.getMajor() >= 9) { 30 | ProcessHandleReflected currentHandle = ProcessHandleReflected.current(); 31 | 32 | boolean alive = currentHandle.isAlive(); 33 | 34 | assertThat(alive, is(true)); 35 | } 36 | } 37 | 38 | @Test 39 | public void descendants() { 40 | if (JAVA_VERSION.getMajor() >= 9) { 41 | ProcessHandleReflected currentHandle = ProcessHandleReflected.current(); 42 | 43 | List descendants = currentHandle.descendants(); 44 | 45 | // should just be the single jvm process or no descendants at all 46 | assertThat(descendants.size(), lessThan(2)); 47 | } 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/echo-sleep-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | for i in `seq 1 5000`; do 3 | echo "Iteration $i (will now sleep for 1 sec)" 4 | sleep 1 5 | done -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/echo-sleep-test.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | for /l %%x in (1, 1, 5000) do ( 3 | echo Iteration %%x [will now sleep for 1 sec] 4 | ping /n 1 /w 1000 localhost >nul 5 | ) -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/hello-world-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | echo "Hello World 7586930100" -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/hello-world-test.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | echo Hello World 7586930100 -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/hello-world-test2: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | echo "Hello World 5624112309877" -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/hello-world-test2.ps1: -------------------------------------------------------------------------------- 1 | Write-Output "Hello World 5624112309877" -------------------------------------------------------------------------------- /blaze-core/src/test/resources/bin/tee.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-core/src/test/resources/bin/tee.exe -------------------------------------------------------------------------------- /blaze-core/src/test/resources/fixtures/pattern.txt: -------------------------------------------------------------------------------- 1 | ## What is a blaze script? 2 | 3 | A Blaze script is a 100% valid JVM class with public methods that typically uses 4 | an empty (root) package declaration. Each public method becomes the externally 5 | accessible task that can be called from the command-line. Since most JVM languages 6 | support this kind of structure, Blaze can easily support a wide variety of 7 | JVM languages. 8 | 9 | ## Install to your project 10 | 11 | Download `blaze.jar` to your project directory. If you have `wget` available 12 | 13 | wget -O blaze.jar 'http://repo1.maven.org/maven2/com/fizzed/blaze-lite/0.9.1/blaze-lite-0.9.1.jar' 14 | 15 | If you have `curl` available 16 | 17 | curl -o blaze.jar 'http://repo1.maven.org/maven2/com/fizzed/blaze-lite/0.9.1/blaze-lite-0.9.1.jar' 18 | 19 | Or simply [download the file in your web browser](http://repo1.maven.org/maven2/com/fizzed/blaze-lite/0.9.1/blaze-lite-0.9.1.jar) 20 | and save it to your project directory with a name of `blaze.jar` 21 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/fixtures/resource-locator.txt: -------------------------------------------------------------------------------- 1 | ## What is a blaze script? 2 | 3 | A Blaze script is a 100% valid JVM class with public methods that typically uses 4 | an empty (root) package declaration. Each public method becomes the externally 5 | accessible task that can be called from the command-line. Since most JVM languages 6 | support this kind of structure, Blaze can easily support a wide variety of 7 | JVM languages. 8 | 9 | ## Install to your project 10 | 11 | Download `blaze.jar` to your project directory. If you have `wget` available 12 | 13 | wget -O blaze.jar 'http://repo1.maven.org/maven2/com/fizzed/blaze-lite/0.9.1/blaze-lite-0.9.1.jar' 14 | 15 | If you have `curl` available 16 | 17 | curl -o blaze.jar 'http://repo1.maven.org/maven2/com/fizzed/blaze-lite/0.9.1/blaze-lite-0.9.1.jar' 18 | 19 | Or simply [download the file in your web browser](http://repo1.maven.org/maven2/com/fizzed/blaze-lite/0.9.1/blaze-lite-0.9.1.jar) 20 | and save it to your project directory with a name of `blaze.jar` 21 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/globber/globber.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-core/src/test/resources/globber/globber.html -------------------------------------------------------------------------------- /blaze-core/src/test/resources/globber/globber.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-core/src/test/resources/globber/globber.txt -------------------------------------------------------------------------------- /blaze-core/src/test/resources/globber/src/java/java.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-core/src/test/resources/globber/src/java/java.txt -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * 19 | * @author joelauer 20 | */ 21 | public class hello { 22 | 23 | public void main() { 24 | System.out.println("Hello World!"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/only_public.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * 19 | * @author joelauer 20 | */ 21 | public class only_public { 22 | 23 | private void priv() { 24 | // this should not be in tasks 25 | } 26 | 27 | protected void prot() { 28 | // this should not work 29 | } 30 | 31 | public void main() { 32 | System.out.println("Hello World!"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project0/blaze.java: -------------------------------------------------------------------------------- 1 | 2 | public class blaze { 3 | 4 | public void main() { 5 | System.out.println("worked"); 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project1/blaze/blaze.java: -------------------------------------------------------------------------------- 1 | 2 | public class blaze { 3 | 4 | public void main() { 5 | System.out.println("worked"); 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project2/.blaze/blaze.java: -------------------------------------------------------------------------------- 1 | 2 | public class blaze { 3 | 4 | public void main() { 5 | System.out.println("worked"); 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project3/.blaze/blaze.conf: -------------------------------------------------------------------------------- 1 | project3.val1 = "I am a random value in the primary config file" -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project3/.blaze/blaze.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import com.fizzed.blaze.Config; 3 | 4 | public class blaze { 5 | private final Config config = Contexts.config(); 6 | 7 | public void main() { 8 | String val1 = config.value("project3.val1").get(); 9 | System.out.println(val1); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project4/.blaze/blaze.conf: -------------------------------------------------------------------------------- 1 | project4.val1 = "This is val1 in the primary config file" 2 | project4.val2 = "This is val2 in the primary config file" -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project4/.blaze/blaze.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import com.fizzed.blaze.Config; 3 | 4 | public class blaze { 5 | private final Config config = Contexts.config(); 6 | 7 | public void main() { 8 | String val1 = config.value("project4.val1").get(); 9 | System.out.println("val1 = " + val1); 10 | 11 | String val2 = config.value("project4.val2").get(); 12 | System.out.println("val2 = " + val2); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /blaze-core/src/test/resources/jdk/project4/.blaze/blaze.local.conf: -------------------------------------------------------------------------------- 1 | # This will override the value from the primary config file 2 | project4.val1 = "This is val1 in the local config file" -------------------------------------------------------------------------------- /blaze-core/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%-5level] %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /blaze-docker/src/main/java/com/fizzed/blaze/docker/DockerSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.docker; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.core.BlazeException; 20 | import com.fizzed.blaze.local.LocalExec; 21 | import com.fizzed.blaze.system.Exec; 22 | import com.fizzed.blaze.system.ExecSession; 23 | import com.fizzed.blaze.util.ImmutableUri; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | public class DockerSession implements ExecSession { 28 | static private final Logger log = LoggerFactory.getLogger(DockerSession.class); 29 | 30 | private final Context context; 31 | private final ImmutableUri uri; 32 | 33 | public DockerSession(Context context, ImmutableUri uri) { 34 | this.context = context; 35 | this.uri = uri; 36 | 37 | if (!"docker".equalsIgnoreCase(this.uri.getScheme())) { 38 | throw new BlazeException("Only docker scheme supported"); 39 | } 40 | } 41 | 42 | public Context context() { 43 | return this.context; 44 | } 45 | 46 | @Override 47 | public ImmutableUri uri() { 48 | return this.uri; 49 | } 50 | 51 | @Override 52 | public Exec newExec() { 53 | return new DockerExec(this.context, this); 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /blaze-docker/src/main/java/com/fizzed/blaze/docker/impl/HeaderToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.docker.impl; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class HeaderToken { 22 | 23 | private final String name; 24 | private final int start; 25 | 26 | public HeaderToken(String name, int start) { 27 | this.name = name; 28 | this.start = start; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public int getStart() { 36 | return start; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "HeaderToken{" + "name=" + name + ", start=" + start + '}'; 42 | } 43 | 44 | static public List parseHeaderLine( 45 | String line) { 46 | 47 | // split on multiple spaces... 48 | String[] tokens = line.split("\\s{2,}"); 49 | 50 | List headerTokens = new ArrayList<>(tokens.length); 51 | 52 | for (String token : tokens) { 53 | int start = line.indexOf(token); 54 | headerTokens.add(new HeaderToken(token, start)); 55 | } 56 | 57 | return headerTokens; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /blaze-docker/src/test/java/com/fizzed/blaze/docker/DockerExecTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.docker; 17 | 18 | import com.fizzed.blaze.Contexts; 19 | import com.fizzed.blaze.core.BlazeException; 20 | import com.fizzed.blaze.util.MutableUri; 21 | import static org.hamcrest.CoreMatchers.containsString; 22 | import static org.junit.Assert.assertThat; 23 | import static org.junit.Assert.fail; 24 | import org.junit.Test; 25 | 26 | public class DockerExecTest { 27 | 28 | @Test 29 | public void noDockerContainer() { 30 | DockerTestHelper.assumeDockerIsPresent(); 31 | 32 | DockerSession session = new DockerSession(Contexts.currentContext(), new MutableUri("docker://nosuchcontainer")); 33 | 34 | try { 35 | String output = session.newExec() 36 | .command("bash") 37 | .runCaptureOutput() 38 | .asString(); 39 | 40 | fail(); 41 | } 42 | catch (BlazeException e) { 43 | assertThat(e.getMessage(), containsString("is not running")); 44 | } 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /blaze-docker/src/test/java/com/fizzed/blaze/docker/DockerTestHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.docker; 17 | 18 | import com.fizzed.blaze.Contexts; 19 | import com.fizzed.blaze.system.Which; 20 | import java.nio.file.Path; 21 | import org.junit.Assume; 22 | 23 | public class DockerTestHelper { 24 | 25 | static public void assumeDockerIsPresent() { 26 | // this only works if docker is present 27 | Path which = new Which(Contexts.currentContext()) 28 | .command("docker") 29 | .run(); 30 | 31 | Assume.assumeTrue("docker is present", which != null); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /blaze-docker/src/test/java/com/fizzed/blaze/docker/DockersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.docker; 17 | 18 | import static org.hamcrest.CoreMatchers.is; 19 | import static org.junit.Assert.assertThat; 20 | import org.junit.Test; 21 | 22 | public class DockersTest { 23 | 24 | @Test 25 | public void isContainerRunning() { 26 | DockerTestHelper.assumeDockerIsPresent(); 27 | 28 | boolean containerRunning = Dockers.isContainerRunning("nosuchcontainer"); 29 | 30 | assertThat(containerRunning, is(false)); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /blaze-groovy/src/main/resources/META-INF/services/com.fizzed.blaze.core.Engine: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.groovy.BlazeGroovyEngine -------------------------------------------------------------------------------- /blaze-groovy/src/test/java/com/fizzed/blaze/groovy/TryIt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.groovy; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.internal.ContextImpl; 20 | import com.fizzed.blaze.internal.FileHelper; 21 | import com.fizzed.blaze.util.Timer; 22 | import java.io.File; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class TryIt { 31 | static private final Logger log = LoggerFactory.getLogger(TryIt.class); 32 | 33 | static public void main(String[] args) throws Exception { 34 | 35 | File scriptFile = FileHelper.resourceAsFile("/groovy/hello.groovy"); 36 | 37 | Context context = new ContextImpl(null, null, scriptFile.toPath(), null); 38 | 39 | BlazeGroovyEngine engine = new BlazeGroovyEngine(); 40 | 41 | engine.init(context); 42 | 43 | Timer timer = new Timer(); 44 | 45 | BlazeGroovyScript script = engine.compile(context); 46 | 47 | log.info("Compiled in {} ms", timer.stop().millis()); 48 | 49 | script.execute("main"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blaze-groovy/src/test/resources/groovy/compile_fail.groovy: -------------------------------------------------------------------------------- 1 | import static com.fizzed.blaze.Systems.* 2 | 3 | def main() { 4 | -------------------------------------------------------------------------------- /blaze-groovy/src/test/resources/groovy/empty.groovy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-groovy/src/test/resources/groovy/empty.groovy -------------------------------------------------------------------------------- /blaze-groovy/src/test/resources/groovy/hello.groovy: -------------------------------------------------------------------------------- 1 | def main() { 2 | println "Hello World!" 3 | } -------------------------------------------------------------------------------- /blaze-groovy/src/test/resources/groovy/message_only_exception.groovy: -------------------------------------------------------------------------------- 1 | import static com.fizzed.blaze.Systems.* 2 | 3 | def main() { 4 | requireExec("thisdoesnotexist", "This message should be displayed").run() 5 | } -------------------------------------------------------------------------------- /blaze-groovy/src/test/resources/groovy/script_initialized.groovy: -------------------------------------------------------------------------------- 1 | version = "1.0.FINAL" 2 | println("Groovy run() called") 3 | 4 | def main() { 5 | println(version); 6 | } -------------------------------------------------------------------------------- /blaze-groovy/src/test/resources/groovy/two_tasks.groovy: -------------------------------------------------------------------------------- 1 | def main() { 2 | println "Hello World!"; 3 | } 4 | 5 | def blaze() { 6 | println "In Blaze!"; 7 | } -------------------------------------------------------------------------------- /blaze-haproxy/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM haproxy:2.1 2 | COPY src/main/docker/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg 3 | #RUN mkdir /run 4 | RUN mkdir /run/haproxy 5 | RUN apt update 6 | RUN apt -y install socat -------------------------------------------------------------------------------- /blaze-haproxy/src/main/docker/haproxy.cfg: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | log /dev/log local1 notice 4 | #chroot /var/lib/haproxy 5 | stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners 6 | stats timeout 30s 7 | #user haproxy 8 | #group haproxy 9 | #daemon 10 | 11 | # Default SSL material locations 12 | ca-base /etc/ssl/certs 13 | crt-base /etc/ssl/private 14 | 15 | # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate 16 | ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 17 | ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 18 | ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets 19 | 20 | defaults 21 | log global 22 | mode http 23 | option httplog 24 | option dontlognull 25 | timeout connect 5s 26 | timeout client 30s 27 | timeout server 30s 28 | timeout http-keep-alive 60s 29 | option forwardfor 30 | errorfile 400 /usr/local/etc/haproxy/errors/400.http 31 | errorfile 403 /usr/local/etc/haproxy/errors/403.http 32 | errorfile 408 /usr/local/etc/haproxy/errors/408.http 33 | errorfile 500 /usr/local/etc/haproxy/errors/500.http 34 | errorfile 502 /usr/local/etc/haproxy/errors/502.http 35 | errorfile 503 /usr/local/etc/haproxy/errors/503.http 36 | errorfile 504 /usr/local/etc/haproxy/errors/504.http 37 | 38 | listen stats 39 | bind *:8404 40 | stats enable 41 | stats uri / 42 | stats refresh 5s -------------------------------------------------------------------------------- /blaze-haproxy/src/main/java/com/fizzed/blaze/haproxy/HaproxyInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.haproxy; 17 | 18 | import java.util.TreeMap; 19 | 20 | public class HaproxyInfo extends TreeMap { 21 | 22 | public HaproxyInfo() { 23 | super(String.CASE_INSENSITIVE_ORDER); 24 | } 25 | 26 | public String getName() { 27 | return this.get("Name"); 28 | } 29 | 30 | public String getVersion() { 31 | return this.get("Version"); 32 | } 33 | 34 | public String getReleaseDate() { 35 | return this.get("Release_date"); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /blaze-haproxy/src/main/java/com/fizzed/blaze/haproxy/HaproxyStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.haproxy; 17 | 18 | import com.fizzed.blaze.core.BlazeException; 19 | import java.util.ArrayList; 20 | 21 | public class HaproxyStats extends ArrayList { 22 | 23 | public HaproxyStat findServer( 24 | String backend, 25 | String server) { 26 | 27 | return this.stream() 28 | .filter(v -> backend.equals(v.getPrimaryName())) 29 | .filter(v -> server.equals(v.getServerName())) 30 | .findFirst() 31 | .orElseThrow(() -> new BlazeException("Backend server '" + backend + "/" + server + "' not found!")); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /blaze-haproxy/src/main/java/com/fizzed/blaze/haproxy/Haproxys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.haproxy; 17 | 18 | import com.fizzed.blaze.Contexts; 19 | import com.fizzed.blaze.system.ExecSession; 20 | 21 | public class Haproxys { 22 | 23 | static public HaproxyConnect haproxyConnect(ExecSession execSession) { 24 | return new HaproxyConnect(Contexts.currentContext(), execSession); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /blaze-http/src/main/java/com/fizzed/blaze/Https.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze; 2 | 3 | import com.fizzed.blaze.http.Http; 4 | 5 | public class Https { 6 | 7 | static public Http httpHead(String url) { 8 | return new Http(Contexts.currentContext(), Http.METHOD_HEAD, url); 9 | } 10 | 11 | static public Http httpGet(String url) { 12 | return new Http(Contexts.currentContext(), Http.METHOD_GET, url); 13 | } 14 | 15 | static public Http httpPost(String url) { 16 | return new Http(Contexts.currentContext(), Http.METHOD_POST, url); 17 | } 18 | 19 | static public Http httpPut(String url) { 20 | return new Http(Contexts.currentContext(), Http.METHOD_PUT, url); 21 | } 22 | 23 | static public Http httpPatch(String url) { 24 | return new Http(Contexts.currentContext(), Http.METHOD_PATCH, url); 25 | } 26 | 27 | static public Http httpDelete(String url) { 28 | return new Http(Contexts.currentContext(), Http.METHOD_DELETE, url); 29 | } 30 | 31 | static public Http httpMethod(String method, String url) { 32 | return new Http(Contexts.currentContext(), method, url); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /blaze-ivy/src/main/java/com/fizzed/blaze/ivy/AuthenticationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ivy; 17 | 18 | public class AuthenticationException extends RuntimeException { 19 | 20 | public AuthenticationException(String message) { 21 | super(message); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /blaze-ivy/src/main/java/com/fizzed/blaze/ivy/MavenRepositoryUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ivy; 17 | 18 | import com.fizzed.blaze.util.MutableUri; 19 | 20 | public class MavenRepositoryUrl { 21 | 22 | private final String id; 23 | private final MutableUri url; 24 | 25 | public MavenRepositoryUrl(String id, MutableUri url) { 26 | this.id = id; 27 | this.url = url; 28 | } 29 | 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | public MutableUri getUrl() { 35 | return url; 36 | } 37 | 38 | static public MavenRepositoryUrl parse(String value) { 39 | if (value == null) { 40 | return null; 41 | } 42 | 43 | String[] tokens = value.split("\\|"); 44 | String id; 45 | String root; 46 | 47 | if (tokens.length != 2) { 48 | throw new IllegalArgumentException("Malformed repository url. Format should be | but was '" + value + "'"); 49 | } 50 | 51 | id = tokens[0]; 52 | root = tokens[1]; 53 | 54 | MutableUri url = new MutableUri(root); 55 | 56 | return new MavenRepositoryUrl(id, url); 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /blaze-ivy/src/main/java/com/fizzed/blaze/ivy/MavenServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ivy; 17 | 18 | public class MavenServer { 19 | 20 | private String id; 21 | private String username; 22 | private String password; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getUsername() { 33 | return username; 34 | } 35 | 36 | public void setUsername(String username) { 37 | this.username = username; 38 | } 39 | 40 | public String getPassword() { 41 | return password; 42 | } 43 | 44 | public void setPassword(String password) { 45 | this.password = password; 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /blaze-ivy/src/main/resources/META-INF/services/com.fizzed.blaze.core.DependencyResolver: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.ivy.IvyDependencyResolver -------------------------------------------------------------------------------- /blaze-ivy/src/test/java/com/fizzed/blaze/ivy/MavenSettingsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ivy; 17 | 18 | import java.nio.file.Path; 19 | import java.nio.file.Paths; 20 | import static org.hamcrest.Matchers.hasSize; 21 | import static org.hamcrest.Matchers.is; 22 | import static org.junit.Assert.assertThat; 23 | import org.junit.Test; 24 | 25 | public class MavenSettingsTest { 26 | 27 | @Test 28 | public void parse() throws Exception { 29 | Path file = Paths.get("src/test/resources/maven-settings.xml"); 30 | 31 | MavenSettings settings = MavenSettings.parse(file); 32 | 33 | assertThat(settings.getServers(), hasSize(4)); 34 | 35 | assertThat(settings.getServers().get(3).getId(), is("sonatype-nexus-staging")); 36 | assertThat(settings.getServers().get(3).getUsername(), is("dude")); 37 | assertThat(settings.getServers().get(3).getPassword(), is("1&3")); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /blaze-ivy/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%-5level] %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /blaze-ivy/src/test/resources/maven-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | gpg.passphrase 5 | test 6 | 7 | 8 | example-internal 9 | admin 10 | 123 11 | 12 | 13 | gb-internal 14 | yomama 15 | testtest 16 | 17 | 18 | sonatype-nexus-staging 19 | dude 20 | 1&3 21 | 22 | 23 | -------------------------------------------------------------------------------- /blaze-kotlin/src/main/java/com/fizzed/blaze/kotlin/BlazeKotlinScript.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.kotlin; 17 | 18 | import com.fizzed.blaze.jdk.TargetObjectScript; 19 | 20 | public class BlazeKotlinScript extends TargetObjectScript { 21 | 22 | public BlazeKotlinScript(Object targetObject) { 23 | super(targetObject); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /blaze-kotlin/src/main/resources/META-INF/services/com.fizzed.blaze.core.Engine: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.kotlin.BlazeKotlinEngine -------------------------------------------------------------------------------- /blaze-kotlin/src/test/java/com/fizzed/blaze/kotlin/Demo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.kotlin; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.core.ContextHolder; 20 | import com.fizzed.blaze.internal.ContextImpl; 21 | import com.fizzed.blaze.util.Timer; 22 | import java.io.File; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 28 | * @author Joe Lauer 29 | */ 30 | public class Demo { 31 | static private final Logger log = LoggerFactory.getLogger(Demo.class); 32 | 33 | static public void main(String[] args) throws Exception { 34 | //File scriptFile = FileHelper.resourceAsFile("/jdk/hello.java"); 35 | File scriptFile = new File("src/test/resources/kotlin/hello.kt"); 36 | 37 | Context context = new ContextImpl(null, null, scriptFile.toPath(), null); 38 | ContextHolder.set(context); 39 | 40 | BlazeKotlinEngine engine = new BlazeKotlinEngine(); 41 | 42 | engine.init(context); 43 | 44 | Timer timer = new Timer(); 45 | 46 | BlazeKotlinScript script = engine.compile(context); 47 | 48 | log.info("Compiled in {} ms", timer.stop().millis()); 49 | 50 | script.execute("main"); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /blaze-kotlin/src/test/resources/kotlin/hello.kt: -------------------------------------------------------------------------------- 1 | class hello { 2 | 3 | fun main() { 4 | System.out.println("Hello World!") 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /blaze-kotlin/src/test/resources/kotlin/noclazz.kt: -------------------------------------------------------------------------------- 1 | fun main() { 2 | System.out.println("Hello World!") 3 | } -------------------------------------------------------------------------------- /blaze-kotlin/src/test/resources/kotlin/only_public.kt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | class only_public() { 4 | 5 | private fun priv() { 6 | // private 7 | } 8 | 9 | fun main() { 10 | System.out.println("Hello World!") 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /blaze-lite/src/main/resources/logging.properties: -------------------------------------------------------------------------------- 1 | handlers = java.util.logging.ConsoleHandler 2 | #java.util.logging.ConsoleHandler.level = INFO 3 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 4 | #java.util.logging.SimpleFormatter.format = [%1$tc] %4$s: %2$s - %5$s %6$s%n 5 | java.util.logging.SimpleFormatter.format = [%4$s] %5$s %6$s%n -------------------------------------------------------------------------------- /blaze-lite/src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | org.slf4j.simpleLogger.logFile=System.err 2 | org.slf4j.simpleLogger.defaultLogLevel=info 3 | org.slf4j.simpleLogger.log.script=info 4 | org.slf4j.simpleLogger.showLogName=false 5 | org.slf4j.simpleLogger.showShortLogName=false 6 | org.slf4j.simpleLogger.showThreadName=false 7 | org.slf4j.simpleLogger.showDateTime=false 8 | org.slf4j.simpleLogger.levelInBrackets=true 9 | -------------------------------------------------------------------------------- /blaze-mysql/src/main/java/com/fizzed/blaze/mysql/MysqlInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.mysql; 17 | 18 | public class MysqlInfo { 19 | 20 | private final String productName; 21 | private final String productVersion; 22 | 23 | public MysqlInfo(String productName, String productVersion) { 24 | this.productName = productName; 25 | this.productVersion = productVersion; 26 | } 27 | 28 | public String getProductName() { 29 | return productName; 30 | } 31 | 32 | public String getProductVersion() { 33 | return productVersion; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /blaze-mysql/src/main/java/com/fizzed/blaze/mysql/Mysqls.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.mysql; 17 | 18 | import com.fizzed.blaze.Contexts; 19 | import com.fizzed.blaze.util.MutableUri; 20 | import java.net.URI; 21 | 22 | public class Mysqls { 23 | 24 | static public MysqlConnect mysqlConnect(String uri) { 25 | return mysqlConnect(MutableUri.of(uri)); 26 | } 27 | 28 | static public MysqlConnect mysqlConnect(URI uri) { 29 | return mysqlConnect(new MutableUri(uri)); 30 | } 31 | 32 | static public MysqlConnect mysqlConnect(MutableUri uri) { 33 | return new MysqlConnect(Contexts.currentContext(), uri); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /blaze-mysql/src/test/java/com/fizzed/blaze/mysql/Demo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.mysql; 17 | 18 | import java.io.IOException; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | public class Demo { 23 | static private final Logger log = LoggerFactory.getLogger(Demo.class); 24 | 25 | static public void main(String[] args) throws InterruptedException, IOException { 26 | 27 | try (MysqlSession mysql = Mysqls.mysqlConnect("mysql://root:test@localhost:3309").run()) { 28 | 29 | // mysql.createDatabase("mytest", true); 30 | 31 | mysql.dropDatabase("mytest", true); 32 | 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /blaze-nashorn/src/main/resources/META-INF/services/com.fizzed.blaze.core.Engine: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.nashorn.BlazeNashornEngine -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/blaze.js: -------------------------------------------------------------------------------- 1 | var main = function() { 2 | print("Default Blaze!"); 3 | } -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/capture_output.js: -------------------------------------------------------------------------------- 1 | var sys = Packages.com.fizzed.blaze.Systems; 2 | var ctx = Packages.com.fizzed.blaze.Contexts; 3 | var strms = Packages.com.fizzed.blaze.util.Streamables; 4 | var str = ""; 5 | 6 | var main = function() { 7 | var binDir = ctx.withBaseDir("../bin"); 8 | var capture = strms.captureOutput(); 9 | sys.exec("hello-world-test") 10 | .path(binDir) 11 | .pipeOutput(capture) 12 | .run(); 13 | str = capture.toString(); 14 | } 15 | 16 | var output = function() { 17 | print(str); 18 | } -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/dependency.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:crux-util:release" 3 | ] -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/dependency.js: -------------------------------------------------------------------------------- 1 | var main = function() { 2 | var v = Java.type("com.fizzed.crux.util.TimeUUID"); 3 | // var Joiner = Java.type("com.google.common.base.Joiner"); 4 | // var s = Joiner.on("; ").skipNulls().join("Harry", null, "Ron", "Hermione"); 5 | print(s); 6 | } 7 | -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/empty.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze-nashorn/src/test/resources/nashorn/empty.js -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/hello.js: -------------------------------------------------------------------------------- 1 | var main = function() { 2 | print("Hello World!"); 3 | } 4 | -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/log.js: -------------------------------------------------------------------------------- 1 | /* global Packages */ 2 | 3 | var main = function() { 4 | var log = Packages.com.fizzed.blaze.Contexts.logger(); 5 | log.info("Did this work?"); 6 | } -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/new_default_task.conf: -------------------------------------------------------------------------------- 1 | blaze.default.task = blaze -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/new_default_task.js: -------------------------------------------------------------------------------- 1 | var blaze = function() { 2 | print("New Default Task!"); 3 | } -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/noengine.txt: -------------------------------------------------------------------------------- 1 | var main = function() { 2 | print("Default Blaze!"); 3 | } -------------------------------------------------------------------------------- /blaze-nashorn/src/test/resources/nashorn/two_tasks.js: -------------------------------------------------------------------------------- 1 | var main = function() { 2 | print("Hello World!"); 3 | } 4 | 5 | var blaze = function() { 6 | print("In Blaze!"); 7 | } 8 | -------------------------------------------------------------------------------- /blaze-postoffice/src/main/java/com/fizzed/blaze/PostOffices.java: -------------------------------------------------------------------------------- 1 | package com.fizzed.blaze; 2 | 3 | import com.fizzed.blaze.postoffice.Mail; 4 | 5 | public class PostOffices { 6 | 7 | static public Mail mail() { 8 | return new Mail(Contexts.currentContext()); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | public class SshException extends RuntimeException { 19 | 20 | public SshException(String msg, Throwable t) { 21 | super(msg, t); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshExec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.system.Exec; 20 | 21 | abstract public class SshExec extends Exec { 22 | 23 | final protected SshSession session; 24 | protected boolean pty; 25 | 26 | public SshExec(Context context, SshSession session) { 27 | super(context); 28 | this.session = session; 29 | this.pty = false; 30 | } 31 | 32 | public SshExec pty(boolean value) { 33 | this.pty = value; 34 | return this; 35 | } 36 | 37 | // static public class Result extends com.fizzed.blaze.system.Exec.Result { 38 | // 39 | // public Result(SshExec action, Integer value) { 40 | // super(action, value); 41 | // } 42 | // 43 | // } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import java.nio.file.Path; 19 | 20 | public class SshFile { 21 | 22 | private final Path path; 23 | private final SshFileAttributes attributes; 24 | 25 | public SshFile(Path path, SshFileAttributes attributes) { 26 | this.path = path; 27 | this.attributes = attributes; 28 | } 29 | 30 | public Path path() { 31 | return path; 32 | } 33 | 34 | public String fileName() { 35 | return path.getFileName().toString(); 36 | } 37 | 38 | public SshFileAttributes attributes() { 39 | return attributes; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshFileAttributes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import java.nio.file.attribute.BasicFileAttributes; 19 | import java.nio.file.attribute.PosixFilePermission; 20 | import java.util.Set; 21 | 22 | public interface SshFileAttributes extends BasicFileAttributes { 23 | 24 | int gid(); 25 | 26 | int uid(); 27 | 28 | Set permissions(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.util.MutableUri; 20 | import com.fizzed.blaze.util.SchemeProvider; 21 | 22 | public interface SshProvider extends SchemeProvider { 23 | 24 | /** 25 | * Creates a new SshConnect. 26 | * @param context The context to connect with 27 | * @param uri The uri to connect to 28 | * @return The new SshConnect 29 | */ 30 | SshConnect connect(Context context, MutableUri uri); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.ssh.impl.SshSupport; 20 | import com.fizzed.blaze.util.ImmutableUri; 21 | import com.fizzed.blaze.system.ExecSession; 22 | 23 | public interface SshSession extends SshSupport, ExecSession { 24 | 25 | Context context(); 26 | 27 | ImmutableUri uri(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshSftp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.core.Action; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | abstract public class SshSftp extends Action { 24 | static private final Logger log = LoggerFactory.getLogger(SshSftp.class); 25 | 26 | final protected SshSession session; 27 | 28 | public SshSftp(Context context, SshSession session) { 29 | super(context); 30 | this.session = session; 31 | } 32 | 33 | static public class Result extends com.fizzed.blaze.core.Result { 34 | 35 | public Result(SshSftp action, SshSftpSession value) { 36 | super(action, value); 37 | } 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshSftpException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | public class SshSftpException extends SshException { 19 | 20 | private final int errorCode; 21 | 22 | public SshSftpException(int errorCode, String msg, Throwable t) { 23 | super(msg, t); 24 | this.errorCode = errorCode; 25 | } 26 | 27 | public int getErrorCode() { 28 | return errorCode; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/SshSftpNoSuchFileException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | public class SshSftpNoSuchFileException extends SshSftpException { 19 | 20 | public SshSftpNoSuchFileException(int errorCode, String msg, Throwable t) { 21 | super(errorCode, msg, t); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/impl/JschProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh.impl; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.ssh.SshConnect; 20 | import com.fizzed.blaze.ssh.SshProvider; 21 | import com.fizzed.blaze.util.MutableUri; 22 | import java.util.Arrays; 23 | import java.util.List; 24 | 25 | public class JschProvider implements SshProvider { 26 | 27 | public static final List SCHEMES = Arrays.asList("ssh"); 28 | 29 | @Override 30 | public List schemes() { 31 | return SCHEMES; 32 | } 33 | 34 | @Override 35 | public SshConnect connect(Context context, MutableUri uri) { 36 | return new JschConnect(context, uri); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/impl/PathHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh.impl; 17 | 18 | import java.nio.file.Path; 19 | 20 | public class PathHelper { 21 | 22 | static public String toString(Path path) { 23 | // TODO: figure out path of remote system? 24 | // for now assume its linux 25 | 26 | char pathSep = '/'; 27 | 28 | StringBuilder s = new StringBuilder(); 29 | 30 | // is absolute? normal path.isAbsolute() doesn't work since local FS 31 | // may not match remote FS 32 | if (path.startsWith("\\") || path.startsWith("/")) { 33 | s.append(pathSep); 34 | } 35 | 36 | int count = path.getNameCount(); 37 | for (int i = 0; i < count; i++) { 38 | Path name = path.getName(i); 39 | if (i != 0) { 40 | s.append(pathSep); 41 | } 42 | s.append(name.toString()); 43 | } 44 | 45 | return s.toString(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/impl/SshSftpSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh.impl; 17 | 18 | import com.fizzed.blaze.ssh.SshSftpException; 19 | import com.fizzed.blaze.util.Streamable; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | import java.nio.file.Path; 23 | 24 | public interface SshSftpSupport { 25 | 26 | void get(Path source, Streamable target) throws SshSftpException; 27 | 28 | void put(Streamable source, String target) throws SshSftpException; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/impl/SshSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh.impl; 17 | 18 | import java.io.Closeable; 19 | 20 | public interface SshSupport extends Closeable { 21 | 22 | boolean closed(); 23 | 24 | default public void verifyOpen() { 25 | if (this.closed()) { 26 | throw new IllegalStateException("Session is closed"); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/java/com/fizzed/blaze/ssh/util/ProxyCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh.util; 17 | 18 | /** 19 | * Helps working with an OpenSSH ProxyCommand. Examples: 20 | * 21 | * ProxyCommand ssh -q jump1.example.com nc %h %p 22 | * ProxyCommand ssh vivek@Jumphost nc FooServer 22 23 | * ProxyCommand ssh root@v.backup2 nc %h %p %r 24 | * ProxyCommand ssh gateway -W %h:%p 25 | * ProxyCommand ssh -i /home/fred/.ssh/rsa_key jumphost.example.org -W %h:%p 26 | * ProxyCommand ssh -l fred2 -i /home/fred/.ssh/rsa_key jumphost.example.org -W %h:%p 27 | * 28 | * @author jjlauer 29 | */ 30 | public class ProxyCommand { 31 | 32 | private final SshCommand sshCommand; 33 | 34 | public ProxyCommand(SshCommand command) { 35 | this.sshCommand = command; 36 | } 37 | 38 | public SshCommand getSshCommand() { 39 | return sshCommand; 40 | } 41 | 42 | static public ProxyCommand parse(String value) { 43 | if (value.startsWith("ssh")) { 44 | SshCommand sshCommand = SshCommand.parse(value); 45 | return new ProxyCommand(sshCommand); 46 | } 47 | 48 | // otherwise we don't support it! 49 | throw new IllegalArgumentException("Unsupported ProxyCommand '" + value + "'"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blaze-ssh/src/main/resources/META-INF/services/com.fizzed.blaze.ssh.SshProvider: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.ssh.impl.JschProvider -------------------------------------------------------------------------------- /blaze-ssh/src/test/java/com/fizzed/blaze/ssh/SshCommandHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | /** 19 | * 20 | * @author joelauer 21 | */ 22 | public interface SshCommandHandler { 23 | 24 | public void handle(SshCommand command); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /blaze-ssh/src/test/java/com/fizzed/blaze/ssh/SshUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import com.jcraft.jsch.JSch; 19 | import com.jcraft.jsch.JSchException; 20 | import com.jcraft.jsch.KeyPair; 21 | import java.nio.file.Path; 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class SshUtils { 28 | 29 | static public String fingerprint(Path privateKey) throws JSchException { 30 | JSch jsch = new JSch(); 31 | KeyPair keypair = KeyPair.load(jsch, privateKey.toString()); 32 | return keypair.getFingerPrint(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /blaze-ssh/src/test/java/com/fizzed/blaze/ssh/TestHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.ssh; 17 | 18 | import com.fizzed.crux.vagrant.VagrantClient; 19 | import com.fizzed.crux.vagrant.VagrantClients; 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | public class TestHelper { 24 | 25 | static public final VagrantClient VAGRANT_CLIENT 26 | = VagrantClients.cachingOrEmptyClient(); 27 | 28 | static public final List VAGRANT_HOSTS 29 | = Arrays.asList("debian8", "ubuntu1404", "centos7", "centos6", "freebsd102"); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/example/lib/lib.txt: -------------------------------------------------------------------------------- 1 | lib1 -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/example/lib/more/more.txt: -------------------------------------------------------------------------------- 1 | more1 -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/example/test1.txt: -------------------------------------------------------------------------------- 1 | test1 -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%-5level] %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/sshd/.ssh/config: -------------------------------------------------------------------------------- 1 | Host thishostnowexists 2 | HostName localhost 3 | User blaze -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/sshd/.ssh/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+/90xyy4YWKsWOOSX/sC3UOCd2ghyLpPfVh6hakwWOQQcFef3od6oHpl4Pd/UP1JxrdJ1mP8022If1AoLjaQCeQXOd6SjW3KEuG0h1OCfucWm152hWfdQKRgGWakPtzVmHjEvASGI/S1Cl6pMRziCoYaMmLir1MO8QnSx42NihNaFdke6vOwmFpw+qMQHKhxoD7gLHMIj91T6n4JS41NogDnaw06vlepDBMIZ2LLJojKh4P0sTHyOGFlWXqqAjG9SIQtNMCnTKKWW41mwr97kIeBlUaxbQsUMwJ5BcRF3McX75n9F8IvPnSZ5jeu475+qqNYZoBPpIrP78/LUVHhAAMgXXdYuuqk44R8BsXsRdPCkltj6OBYBRvIJX2YxoEBwUmP3n4K8dQFW/0bUfvBu2WvIlU/eO/sp4IiLUuWS+HCWQAOaWs/KovGZUmWqG8qcpRnptqZYmbg+jX3w+JLxuUbwFZzdkK5lTdjpYgwPHq6cGe8MJl7mPwFzy9G/VO7OSb0tGPY23MneJVo1iXpWcbb32OQa6qZTQeblPjI+z4CSX4VRziVhcYKx4hzSVA7RnkBWPzw1u3hemXYqsQ8ilRE9WoPWEMOjbS1AFXmQUnGn82yBdwrnTD33p7BRpJs78vJ/UH6s8DI4S6D1OIFfM6fADJj1glNSmGM7f6qKlw== joelauer@sea-joelauer-linux 2 | -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/sshd/public_key/.ssh/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+/90xyy4YWKsWOOSX/sC3UOCd2ghyLpPfVh6hakwWOQQcFef3od6oHpl4Pd/UP1JxrdJ1mP8022If1AoLjaQCeQXOd6SjW3KEuG0h1OCfucWm152hWfdQKRgGWakPtzVmHjEvASGI/S1Cl6pMRziCoYaMmLir1MO8QnSx42NihNaFdke6vOwmFpw+qMQHKhxoD7gLHMIj91T6n4JS41NogDnaw06vlepDBMIZ2LLJojKh4P0sTHyOGFlWXqqAjG9SIQtNMCnTKKWW41mwr97kIeBlUaxbQsUMwJ5BcRF3McX75n9F8IvPnSZ5jeu475+qqNYZoBPpIrP78/LUVHhAAMgXXdYuuqk44R8BsXsRdPCkltj6OBYBRvIJX2YxoEBwUmP3n4K8dQFW/0bUfvBu2WvIlU/eO/sp4IiLUuWS+HCWQAOaWs/KovGZUmWqG8qcpRnptqZYmbg+jX3w+JLxuUbwFZzdkK5lTdjpYgwPHq6cGe8MJl7mPwFzy9G/VO7OSb0tGPY23MneJVo1iXpWcbb32OQa6qZTQeblPjI+z4CSX4VRziVhcYKx4hzSVA7RnkBWPzw1u3hemXYqsQ8ilRE9WoPWEMOjbS1AFXmQUnGn82yBdwrnTD33p7BRpJs78vJ/UH6s8DI4S6D1OIFfM6fADJj1glNSmGM7f6qKlw== joelauer@sea-joelauer-linux 2 | -------------------------------------------------------------------------------- /blaze-ssh/src/test/resources/sshd/ssh-test.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /blaze-vagrant/src/main/java/com/fizzed/blaze/vagrant/VagrantSshProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Fizzed, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.fizzed.blaze.vagrant; 17 | 18 | import com.fizzed.blaze.Context; 19 | import com.fizzed.blaze.ssh.SshConnect; 20 | import com.fizzed.blaze.ssh.SshProvider; 21 | import com.fizzed.blaze.ssh.impl.JschConnect; 22 | import com.fizzed.blaze.util.MutableUri; 23 | import com.fizzed.crux.vagrant.VagrantClient; 24 | import com.fizzed.crux.vagrant.VagrantClients; 25 | import java.nio.file.Path; 26 | import java.util.Arrays; 27 | import java.util.List; 28 | 29 | public class VagrantSshProvider implements SshProvider { 30 | 31 | static public final VagrantClient VAGRANT_CLIENT = VagrantClients.cachingOrEmptyClient(); 32 | public static final List SCHEMES = Arrays.asList("vagrant+ssh"); 33 | 34 | @Override 35 | public List schemes() { 36 | return SCHEMES; 37 | } 38 | 39 | @Override 40 | public SshConnect connect(Context context, MutableUri uri) { 41 | Path sshConfigFile = VAGRANT_CLIENT.sshConfig(uri.getHost()); 42 | return new JschConnect(context, uri).configFile(sshConfigFile); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /blaze-vagrant/src/main/resources/META-INF/services/com.fizzed.blaze.ssh.SshProvider: -------------------------------------------------------------------------------- 1 | com.fizzed.blaze.vagrant.VagrantSshProvider -------------------------------------------------------------------------------- /blaze.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/blaze.jar -------------------------------------------------------------------------------- /buildx-results.txt: -------------------------------------------------------------------------------- 1 | Buildx Results 2 | -------------- 3 | Cross platform tests use the Buildx project: https://github.com/fizzed/buildx 4 | Commit: d63338b7123bfbb3f5e160986dec2f9667583b94 5 | Date: 2025-01-21T21:21:14.509641Z[UTC] 6 | 7 | linux-x64 success 8 | linux-arm64 success 9 | linux_musl-x64 success 10 | macos-x64 success 11 | macos-arm64 success 12 | windows-x64 success 13 | windows-arm64 success 14 | 15 | -------------------------------------------------------------------------------- /docs/DEV.md: -------------------------------------------------------------------------------- 1 | Blaze by Fizzed 2 | ======================================= 3 | 4 | ## Development and testing 5 | 6 | Standard maven goals are used. Compiling: 7 | 8 | mvn compile 9 | 10 | To run the majority of tests 11 | 12 | mvn test 13 | 14 | Since blaze interacts with operating systems, Vagrant helps to test against 15 | real systems (especially for `blaze-ssh`). If vagrant isn't installed or any 16 | instance running, then those unit tests are skipped. However, to make sure 17 | the full suite of unit tests run, its good to init Vagrant. To bring up an 18 | Ubuntu 14.04 instance to be used by additional unit tests. 19 | 20 | vagrant up 21 | mvn test 22 | 23 | Ubuntu 14.04 is the default Vagrant instance, but there are numerous other 24 | operating systems in the `Vagrantfile` to ensure compat with a wider range of 25 | real systems. To test everything: 26 | 27 | vagrant up ubuntu14 ubuntu16 debian8 centos7 centos6 freebsd102 28 | mvn test 29 | -------------------------------------------------------------------------------- /docs/HTTP.md: -------------------------------------------------------------------------------- 1 | Blaze by Fizzed 2 | ======================================= 3 | 4 | ## HTTP 5 | 6 | Add the following to your `blaze.conf` file to include rich support for HTTP -- 7 | much better support than the JDK HttpUrlConnection class. 8 | You do not want to specify a version so Blaze will resolve the identical version 9 | to whatever `blaze-core` you're running with. 10 | 11 | ``` 12 | blaze.dependencies = [ 13 | "com.fizzed:blaze-http" 14 | ] 15 | ``` 16 | 17 | For now this is mostly a "virtual" dependency that will trigger the transitive 18 | dependency of Apache Fluent HttpClient to be downloaded and added to the classpath. 19 | Apache's own transitive dependencies will be correctly excluded to pickup the 20 | right SLF4J bindings. Down the road we may provide additional wrappers to make 21 | working with HTTP via Apache HttpClient even easier -- although it's [own 22 | fluent client](https://hc.apache.org/httpcomponents-client-ga/tutorial/html/fluent.html) isn't awful. 23 | 24 | Checkout [this](../examples/http.java) for an example API get request 25 | -------------------------------------------------------------------------------- /docs/blaze-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fizzed/blaze/43ad21e189f61d6f09316b49dd76e81a53899a7e/docs/blaze-demo.gif -------------------------------------------------------------------------------- /examples/find_java.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:jne:4.1.1" 3 | ] -------------------------------------------------------------------------------- /examples/find_java.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import org.slf4j.Logger; 3 | import com.fizzed.jne.*; 4 | 5 | import java.util.List; 6 | 7 | public class find_java { 8 | 9 | final private Logger log = Contexts.logger(); 10 | 11 | public void main() throws Exception { 12 | log.info("Finding all JVMs on your system..."); 13 | 14 | final List javaHomes = JavaHomes.detect(); 15 | 16 | for (JavaHome javaHome : javaHomes) { 17 | log.info("{}", javaHome); 18 | log.info(" javaExe: {}", javaHome.getJavaExe()); 19 | log.info(" javacExe: {}", javaHome.getJavacExe()); 20 | log.info(" nativeImageExe: {}", javaHome.getNativeImageExe()); 21 | log.info(" imageType: {}", javaHome.getImageType()); 22 | log.info(" version: {}", javaHome.getVersion()); 23 | log.info(" major: {}", javaHome.getVersion().getMajor()); 24 | log.info(" minor: {}", javaHome.getVersion().getMinor()); 25 | log.info(" security: {}", javaHome.getVersion().getSecurity()); 26 | log.info(" os: {}", javaHome.getOperatingSystem()); 27 | log.info(" arch: {}", javaHome.getHardwareArchitecture()); 28 | log.info(" distro: {}", javaHome.getDistribution()); 29 | log.info(" vendor: {}", javaHome.getVendor()); 30 | } 31 | 32 | // now, let's use the JavaHomeFinder to narrow our match to something awesome 33 | final JavaHome jdk = new JavaHomeFinder() 34 | .jdk() 35 | .maxVersion(21) 36 | .minVersion(8) 37 | .preferredDistributions() 38 | .sorted() 39 | .find(); 40 | 41 | log.info("Found JVM {}", jdk); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /examples/git.conf: -------------------------------------------------------------------------------- 1 | blaze.default.task = status 2 | 3 | blaze.dependencies = [ 4 | "org.eclipse.jgit:org.eclipse.jgit:4.1.0.201509280440-r" 5 | ] -------------------------------------------------------------------------------- /examples/git.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import com.fizzed.blaze.Contexts 4 | import org.eclipse.jgit.lib.Repository 5 | import org.eclipse.jgit.storage.file.FileRepositoryBuilder 6 | import org.eclipse.jgit.api.Git 7 | import org.eclipse.jgit.api.LogCommand 8 | import org.eclipse.jgit.api.errors.GitAPIException 9 | import org.eclipse.jgit.lib.Ref 10 | import org.eclipse.jgit.revwalk.RevCommit 11 | 12 | log = Contexts.logger() 13 | 14 | def status() { 15 | repo = new FileRepositoryBuilder() 16 | .readEnvironment() // scan environment GIT_* variables 17 | .findGitDir() // scan up the file system tree 18 | .build(); 19 | 20 | def g = Git.wrap(repo) 21 | try { 22 | status = g.status().call(); 23 | log.info("Added: " + status.getAdded()); 24 | log.info("Changed: " + status.getChanged()); 25 | log.info("Conflicting: " + status.getConflicting()); 26 | log.info("ConflictingStageState: " + status.getConflictingStageState()); 27 | log.info("IgnoredNotInIndex: " + status.getIgnoredNotInIndex()); 28 | log.info("Missing: " + status.getMissing()); 29 | log.info("Modified: " + status.getModified()); 30 | log.info("Removed: " + status.getRemoved()); 31 | log.info("Untracked: " + status.getUntracked()); 32 | log.info("UntrackedFolders: " + status.getUntrackedFolders()) 33 | } finally { 34 | g.close() 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /examples/git.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import org.eclipse.jgit.lib.Repository; 3 | import org.eclipse.jgit.storage.file.FileRepositoryBuilder; 4 | import org.eclipse.jgit.api.Git; 5 | import org.eclipse.jgit.api.Status; 6 | import org.slf4j.Logger; 7 | 8 | public class git { 9 | static final private Logger log = Contexts.logger(); 10 | 11 | public void status() throws Exception { 12 | Repository repo = new FileRepositoryBuilder() 13 | .readEnvironment() // scan environment GIT_* variables 14 | .findGitDir() // scan up the file system tree 15 | .build(); 16 | 17 | try (Git git = new Git(repo)) { 18 | Status status = git.status().call(); 19 | log.info("Added: " + status.getAdded()); 20 | log.info("Changed: " + status.getChanged()); 21 | log.info("Conflicting: " + status.getConflicting()); 22 | log.info("ConflictingStageState: " + status.getConflictingStageState()); 23 | log.info("IgnoredNotInIndex: " + status.getIgnoredNotInIndex()); 24 | log.info("Missing: " + status.getMissing()); 25 | log.info("Modified: " + status.getModified()); 26 | log.info("Removed: " + status.getRemoved()); 27 | log.info("Untracked: " + status.getUntracked()); 28 | log.info("UntrackedFolders: " + status.getUntrackedFolders()); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /examples/git.js: -------------------------------------------------------------------------------- 1 | /* global Packages, Contexts */ 2 | 3 | var Imports = JavaImporter( 4 | Packages.com.fizzed.blaze.Contexts, 5 | Packages.org.eclipse.jgit.lib.Repository, 6 | Packages.org.eclipse.jgit.storage.file.FileRepositoryBuilder, 7 | Packages.org.eclipse.jgit.api.Git, 8 | Packages.org.eclipse.jgit.api.LogCommand, 9 | Packages.org.eclipse.jgit.api.errors.GitAPIException, 10 | Packages.org.eclipse.jgit.lib.Ref, 11 | Packages.org.eclipse.jgit.revwalk.RevCommit); 12 | 13 | with (Imports) { 14 | 15 | var log = Contexts.logger(); 16 | 17 | var status = function() { 18 | repo = new FileRepositoryBuilder() 19 | .readEnvironment() // scan environment GIT_* variables 20 | .findGitDir() // scan up the file system tree 21 | .build(); 22 | 23 | g = new Git(repo); 24 | 25 | status = g.status().call(); 26 | log.info("Added: {}", status.getAdded()); 27 | log.info("Changed: {}", status.getChanged()); 28 | log.info("Conflicting: {}", status.getConflicting()); 29 | log.info("ConflictingStageState: {}", status.getConflictingStageState()); 30 | log.info("IgnoredNotInIndex: {}", status.getIgnoredNotInIndex()); 31 | log.info("Missing: {}", status.getMissing()); 32 | log.info("Modified: {}", status.getModified()); 33 | log.info("Removed: {}", status.getRemoved()); 34 | log.info("Untracked: {}", status.getUntracked()); 35 | log.info("UntrackedFolders: {}", status.getUntrackedFolders()); 36 | }; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /examples/globber.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import org.slf4j.Logger 4 | import com.fizzed.blaze.Contexts 5 | import static com.fizzed.blaze.util.Globber.globber 6 | 7 | log = Contexts.logger() 8 | 9 | def main() { 10 | globber(Contexts.baseDir(), "*.{java,js,groovy,kt,kts}") 11 | .filesOnly() 12 | .visibleOnly() 13 | .scan().stream().forEach { p -> 14 | log.info("{}", p) 15 | } 16 | } -------------------------------------------------------------------------------- /examples/globber.java: -------------------------------------------------------------------------------- 1 | import org.slf4j.Logger; 2 | import com.fizzed.blaze.Contexts; 3 | import static com.fizzed.blaze.util.Globber.globber; 4 | 5 | public class globber { 6 | static private final Logger log = Contexts.logger(); 7 | 8 | public void main() throws Exception { 9 | globber(Contexts.baseDir(), "*.{java,js,groovy,kt,kts}") 10 | .filesOnly() 11 | .visibleOnly() 12 | .scan().stream().forEach((p) -> { 13 | log.info("{}", p); 14 | }); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /examples/globber.js: -------------------------------------------------------------------------------- 1 | /* global Packages, Contexts, Globber */ 2 | 3 | // nashorn recommended method of importing classes 4 | var Imports = new JavaImporter( 5 | Packages.org.slf4j.Logger, 6 | Packages.com.fizzed.blaze.Contexts, 7 | Packages.com.fizzed.blaze.util.Globber); 8 | 9 | with (Imports) { 10 | 11 | var log = Contexts.logger(); 12 | var globber = Globber.globber; 13 | 14 | var main = function() { 15 | globber(Contexts.baseDir(), "*.{java,js,groovy,kt,kts}") 16 | .filesOnly() 17 | .visibleOnly() 18 | .scan().stream().forEach(function(p) { 19 | log.info("{}", p); 20 | }); 21 | }; 22 | 23 | } -------------------------------------------------------------------------------- /examples/globber.kt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import org.slf4j.Logger 4 | import com.fizzed.blaze.Contexts 5 | import com.fizzed.blaze.Contexts.baseDir 6 | import com.fizzed.blaze.util.Globber.globber 7 | 8 | class globber { 9 | val log = Contexts.logger() 10 | 11 | fun main() { 12 | globber(baseDir(), "*.{java,js,groovy,kt,kts}") 13 | .filesOnly() 14 | .visibleOnly() 15 | .scan() 16 | .sorted() 17 | .forEach({ p -> 18 | log.info("{}", p) 19 | }) 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /examples/globber.kts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import org.slf4j.Logger 4 | import com.fizzed.blaze.Contexts 5 | import com.fizzed.blaze.Contexts.baseDir 6 | import com.fizzed.blaze.util.Globber.globber 7 | 8 | val log = Contexts.logger() 9 | 10 | fun main() { 11 | globber(baseDir(), "*.{java,js,groovy,kt,kts}") 12 | .filesOnly() 13 | .visibleOnly() 14 | .scan() 15 | .sorted() 16 | .forEach({ p -> 17 | log.info("{}", p) 18 | }) 19 | } -------------------------------------------------------------------------------- /examples/grep.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "org.unix4j:unix4j-command:0.6" 3 | ] -------------------------------------------------------------------------------- /examples/grep.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import org.unix4j.Unix4j; 3 | import org.slf4j.Logger; 4 | import org.unix4j.unix.Ls; 5 | 6 | public class grep { 7 | static final private Logger log = Contexts.logger(); 8 | 9 | public void main() throws Exception { 10 | log.info("Demo of Unix4j tool for \"grep\" support"); 11 | 12 | Unix4j.cat(Contexts.withBaseDir("../README.md").toFile()).grep("blaze-lite").toLineList().forEach(s -> { 13 | log.info("found: {}", s.toString().trim()); 14 | }); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/guava.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.google.guava:guava:18.0" 3 | ] -------------------------------------------------------------------------------- /examples/guava.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze import com.google.common.base.Joiner def main() { def s = Joiner.on("; ").skipNulls().join("Harry", null, "Ron", "Hermione") println(s) } -------------------------------------------------------------------------------- /examples/guava.java: -------------------------------------------------------------------------------- 1 | import com.google.common.base.Joiner; public class guava { public void main() { String s = Joiner.on("; ").skipNulls().join("Harry", null, "Ron", "Hermione"); System.out.println(s); } } -------------------------------------------------------------------------------- /examples/guava.js: -------------------------------------------------------------------------------- 1 | /* global Packages */ 2 | 3 | var Joiner = Packages.com.google.common.base.Joiner; 4 | 5 | var main = function() { 6 | var s = Joiner.on("; ").skipNulls().join("Harry", null, "Ron", "Hermione"); 7 | print(s); 8 | }; 9 | -------------------------------------------------------------------------------- /examples/hello.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | import com.fizzed.blaze.Task 3 | 4 | @Task(order=2, value="Prints hello world") 5 | def main() { 6 | println("Hello World!") 7 | } 8 | 9 | @Task(order=1, value="Prints java version") 10 | public void version() { 11 | println(System.getProperty("java.version")); 12 | } -------------------------------------------------------------------------------- /examples/hello.java: -------------------------------------------------------------------------------- 1 | 2 | import com.fizzed.blaze.Task; 3 | 4 | public class hello { 5 | 6 | @Task(order=2, value="Prints hello world") 7 | public void main() { 8 | System.out.println("Hello World!"); 9 | } 10 | 11 | @Task(order=1, value="Prints java version") 12 | public void version() { 13 | System.out.println(System.getProperty("java.version")); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /examples/hello.js: -------------------------------------------------------------------------------- 1 | /* global Packages */ 2 | 3 | function main() { 4 | print("Hello World!"); 5 | } 6 | 7 | function version() { 8 | print(Packages.java.lang.System.getProperty("java.version")); 9 | } -------------------------------------------------------------------------------- /examples/hello.kt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import com.fizzed.blaze.Task 4 | 5 | class hello { 6 | 7 | @Task(order=2, value="Prints hello world") 8 | fun main() { 9 | System.out.println("Hello World!"); 10 | } 11 | 12 | @Task(order=1, value="Prints java version") 13 | fun version() { 14 | System.out.println(System.getProperty("java.version")); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /examples/http.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:blaze-http" 3 | ] -------------------------------------------------------------------------------- /examples/http.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import org.slf4j.Logger 4 | import com.fizzed.blaze.Contexts 5 | import com.fizzed.blaze.util.MutableUri 6 | import java.net.URI 7 | import org.apache.http.client.fluent.Request 8 | 9 | def main() { 10 | def log = Contexts.logger() 11 | 12 | def uri = MutableUri.of("http://jsonplaceholder.typicode.com/comments") 13 | .query("postId", 1) 14 | .toURI() 15 | 16 | def output = 17 | Request.Get(uri) 18 | .addHeader("Accept", "application/json") 19 | .execute() 20 | .returnContent() 21 | .toString() 22 | 23 | log.info("Quote of the day JSON is {}", output) 24 | } -------------------------------------------------------------------------------- /examples/http.java: -------------------------------------------------------------------------------- 1 | import org.slf4j.Logger; 2 | import com.fizzed.blaze.Contexts; 3 | import com.fizzed.blaze.util.MutableUri; 4 | import java.net.URI; 5 | import org.apache.http.client.fluent.Request; 6 | 7 | public class http { 8 | static final private Logger log = Contexts.logger(); 9 | 10 | public void main() throws Exception { 11 | URI uri = MutableUri.of("http://jsonplaceholder.typicode.com/comments") 12 | .query("postId", 1) 13 | .toURI(); 14 | 15 | String output = 16 | Request.Get(uri) 17 | .addHeader("Accept", "application/json") 18 | .execute() 19 | .returnContent() 20 | .toString(); 21 | 22 | log.info("Quote of the day JSON is {}", output); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /examples/http.js: -------------------------------------------------------------------------------- 1 | /* global Packages, Contexts, MutableUri, Request */ 2 | 3 | // nashorn recommended method of importing classes 4 | var Imports = new JavaImporter( 5 | Packages.org.slf4j.Logger, 6 | Packages.com.fizzed.blaze.Contexts, 7 | Packages.com.fizzed.blaze.util.MutableUri, 8 | Packages.org.apache.http.client.fluent.Request); 9 | 10 | with (Imports) { 11 | 12 | var log = Contexts.logger(); 13 | 14 | var main = function() { 15 | var uri = MutableUri.of("http://jsonplaceholder.typicode.com/comments") 16 | .query("postId", 1) 17 | .toURI(); 18 | 19 | var output = 20 | Request.Get(uri) 21 | .addHeader("Accept", "application/json") 22 | .execute() 23 | .returnContent() 24 | .toString(); 25 | 26 | log.info("Quote of the day JSON is {}", output); 27 | }; 28 | 29 | } -------------------------------------------------------------------------------- /examples/javac.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import static com.fizzed.blaze.Systems.which 4 | import static com.fizzed.blaze.Systems.exec 5 | import com.fizzed.blaze.Contexts; 6 | 7 | 8 | def main() { 9 | def log = Contexts.logger() 10 | 11 | log.info("Finding javac...") 12 | def javac = which("javac").run() 13 | 14 | log.info("Using javac " + javac) 15 | exec("javac").arg("-version").run() 16 | } 17 | -------------------------------------------------------------------------------- /examples/javac.java: -------------------------------------------------------------------------------- 1 | import org.slf4j.Logger; 2 | import static com.fizzed.blaze.Systems.which; 3 | import static com.fizzed.blaze.Systems.exec; 4 | import com.fizzed.blaze.Contexts; 5 | import java.nio.file.Path; 6 | 7 | public class javac { 8 | static final private Logger log = Contexts.logger(); 9 | 10 | public void main() { 11 | log.info("Finding javac..."); 12 | Path javacFile = which("javac").run(); 13 | 14 | log.info("Using javac {}", javacFile); 15 | exec("javac", "-version").run(); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /examples/javac.js: -------------------------------------------------------------------------------- 1 | /* global Packages */ 2 | 3 | var sys = Packages.com.fizzed.blaze.Systems; 4 | var log = Packages.com.fizzed.blaze.Contexts.logger(); 5 | 6 | var main = function() { 7 | log.info("Finding javac..."); 8 | var javac = sys.which("javac").run(); 9 | 10 | log.info("Using javac {}", javac); 11 | sys.exec("javac").arg("-version").run(); 12 | }; 13 | -------------------------------------------------------------------------------- /examples/ls.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "org.unix4j:unix4j-command:0.6" 3 | ] -------------------------------------------------------------------------------- /examples/ls.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import org.slf4j.Logger; 3 | import org.unix4j.Unix4j; 4 | import org.unix4j.unix.Ls; 5 | 6 | public class ls { 7 | static final private Logger log = Contexts.logger(); 8 | 9 | public void main() throws Exception { 10 | log.info("Demo of Unix4j tool for \"ls\" support"); 11 | 12 | Unix4j.ls(Ls.Options.l.a, Contexts.withBaseDir("../").toAbsolutePath().toFile()).toLineList().forEach(s -> { 13 | log.info("found: {}", s.toString().trim()); 14 | }); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/natives.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:jne:RELEASE" 3 | ] -------------------------------------------------------------------------------- /examples/natives.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Contexts; 2 | import com.fizzed.jne.NativeTarget; 3 | import org.slf4j.Logger; 4 | 5 | public class natives { 6 | static final private Logger log = Contexts.logger(); 7 | 8 | public void main() throws Exception { 9 | final NativeTarget nativeTarget = NativeTarget.detect(); 10 | 11 | log.info("Detected native target:"); 12 | log.info(" os: {}", nativeTarget.getOperatingSystem()); 13 | log.info(" arch: {}", nativeTarget.getHardwareArchitecture()); 14 | log.info(" abi: {}", nativeTarget.getAbi()); 15 | log.info(" jneTarget: {}", nativeTarget.toJneTarget()); 16 | log.info(" rustTarget: {}", nativeTarget.toRustTarget()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/pipeline.java: -------------------------------------------------------------------------------- 1 | import org.slf4j.Logger; 2 | import com.fizzed.blaze.Contexts; 3 | import static com.fizzed.blaze.Contexts.withBaseDir; 4 | import static com.fizzed.blaze.Systems.head; 5 | import static com.fizzed.blaze.Systems.pipeline; 6 | import static com.fizzed.blaze.Systems.tail; 7 | import com.fizzed.blaze.util.CaptureOutput; 8 | import com.fizzed.blaze.util.Streamables; 9 | import java.nio.file.Path; 10 | 11 | public class pipeline { 12 | static final private Logger log = Contexts.logger(); 13 | 14 | public void main() { 15 | Path inputFile = withBaseDir("pipeline.txt"); 16 | log.info("Using input file: {}", inputFile); 17 | 18 | CaptureOutput capture = Streamables.captureOutput(); 19 | 20 | pipeline() 21 | .pipeInput(inputFile) 22 | .add(head(3)) 23 | .add(tail(2)) 24 | .pipeOutput(capture) 25 | .run(); 26 | 27 | log.info("{}", capture); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /examples/pipeline.txt: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | c 4 | d 5 | e -------------------------------------------------------------------------------- /examples/prompt.java: -------------------------------------------------------------------------------- 1 | 2 | import com.fizzed.blaze.Config; 3 | import com.fizzed.blaze.Contexts; 4 | import org.slf4j.Logger; 5 | 6 | public class prompt { 7 | final private Logger log = Contexts.logger(); 8 | final private Config config = Contexts.config(); 9 | 10 | public void main() throws Exception { 11 | 12 | String s = null; 13 | 14 | s = Contexts.prompt() 15 | .options("yes", "no") 16 | .prompt("No default prompt [yes|no]: "); 17 | 18 | log.info("Answer: {}", s); 19 | 20 | s = Contexts.prompt() 21 | .options("yes", "no") 22 | .defaultOption("no") 23 | .prompt("Answer or default no [yes|no]: "); 24 | 25 | log.info("Answer: {}", s); 26 | 27 | s = Contexts.prompt() 28 | .masked(true) 29 | .prompt("Enter a fake password: "); 30 | 31 | log.info("Answer: {}", s); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /examples/sftp.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:blaze-ssh" 3 | ] 4 | -------------------------------------------------------------------------------- /examples/ssh.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "com.fizzed:blaze-ssh", 3 | "com.fizzed:blaze-vagrant" 4 | ] 5 | -------------------------------------------------------------------------------- /examples/undertow.conf: -------------------------------------------------------------------------------- 1 | blaze.dependencies = [ 2 | "io.undertow:undertow-core:1.3.3.Final" 3 | ] 4 | 5 | undertow.port = 9000 6 | undertow.host = "localhost" -------------------------------------------------------------------------------- /examples/undertow.groovy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env blaze 2 | 3 | import com.fizzed.blaze.Contexts 4 | import io.undertow.Undertow 5 | import io.undertow.server.HttpHandler 6 | import io.undertow.server.HttpServerExchange 7 | import io.undertow.util.Headers 8 | import io.undertow.server.handlers.resource.PathResourceManager 9 | import java.nio.file.Paths 10 | import static io.undertow.Handlers.resource 11 | 12 | def main() { 13 | def dir = Contexts.baseDir() 14 | def log = Contexts.logger() 15 | def config = Contexts.config() 16 | 17 | def host = config.value("undertow.host").get() 18 | def port = config.value("undertow.port", Integer.class).get() 19 | def in_try_all_example = config.value("examples.try_all", Boolean.class).getOr(false) 20 | 21 | def undertow = Undertow.builder() 22 | .addHttpListener(port, host) 23 | .setHandler(resource(new PathResourceManager(dir, 100)).setDirectoryListingEnabled(true)) 24 | .build() 25 | 26 | undertow.start() 27 | 28 | log.info("Open browser to http://{}:{}", host, port) 29 | 30 | if (in_try_all_example) { 31 | // simply for stopping server if we're in try_all example 32 | undertow.stop(); 33 | } else { 34 | synchronized (undertow) { 35 | undertow.wait(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /examples/undertow.java: -------------------------------------------------------------------------------- 1 | import com.fizzed.blaze.Config; 2 | import com.fizzed.blaze.Contexts; 3 | import io.undertow.Undertow; 4 | import io.undertow.server.HttpHandler; 5 | import io.undertow.server.HttpServerExchange; 6 | import io.undertow.util.Headers; 7 | import io.undertow.server.handlers.resource.PathResourceManager; 8 | import static io.undertow.Handlers.resource; 9 | import java.nio.file.Path; 10 | import org.slf4j.Logger; 11 | 12 | public class undertow { 13 | 14 | public void main() throws Exception { 15 | Path dir = Contexts.baseDir(); 16 | Logger log = Contexts.logger(); 17 | Config config = Contexts.config(); 18 | 19 | String host = config.value("undertow.host").get(); 20 | int port = config.value("undertow.port", int.class).get(); 21 | boolean in_try_all_example = config.value("examples.try_all", Boolean.class).getOr(false); 22 | 23 | Undertow undertow = Undertow.builder() 24 | .addHttpListener(port, host) 25 | .setHandler(resource(new PathResourceManager(dir, 100)).setDirectoryListingEnabled(true)) 26 | .build(); 27 | 28 | undertow.start(); 29 | 30 | log.info("Open browser to http://{}:{}", host, port); 31 | 32 | if (in_try_all_example) { 33 | // simply for stopping server if we're in try_all example 34 | undertow.stop(); 35 | } else { 36 | synchronized (undertow) { 37 | undertow.wait(); 38 | } 39 | } 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /examples/undertow.js: -------------------------------------------------------------------------------- 1 | /* global java, Packages, Contexts, Undertow, Handlers, undertow, int */ 2 | 3 | // nashorn recommended method of importing classes 4 | var Imports = new JavaImporter( 5 | java.nio.file.Path, 6 | java.lang.Integer, 7 | java.lang.Boolean, 8 | java.lang.Thread, 9 | Packages.com.fizzed.blaze.Contexts, 10 | Packages.io.undertow.Undertow, 11 | Packages.io.undertow.server.HttpHandler, 12 | Packages.io.undertow.server.HttpServerExchange, 13 | Packages.io.undertow.util.Headers, 14 | Packages.io.undertow.server.handlers.resource.PathResourceManager, 15 | Packages.io.undertow.Handlers); 16 | 17 | with (Imports) { 18 | 19 | var main = function() { 20 | var dir = Contexts.baseDir(); 21 | var log = Contexts.logger(); 22 | var config = Contexts.config(); 23 | 24 | var host = config.value("undertow.host").get(); 25 | var port = config.value("undertow.port", Integer.class).get(); 26 | var in_try_all_example = config.value("examples.try_all").getOr("false"); 27 | 28 | var undertow = Undertow.builder() 29 | .addHttpListener(port, host) 30 | .setHandler(Handlers.resource(new PathResourceManager(dir, 100)).setDirectoryListingEnabled(true)) 31 | .build(); 32 | 33 | undertow.start(); 34 | 35 | log.info("Open browser to http://{}:{}", host, port); 36 | 37 | if (in_try_all_example.equals("true")) { 38 | // simply for stopping server if we're in try_all example 39 | undertow.stop(); 40 | } else { 41 | // hack to wait 42 | Thread.sleep(10000000); 43 | } 44 | }; 45 | 46 | } --------------------------------------------------------------------------------