Skip to content

Instantly share code, notes, and snippets.

View gonaumov's full-sized avatar
💭
a status

George Naumov gonaumov

💭
a status
View GitHub Profile
@gonaumov
gonaumov / mvnInstaller.sh
Last active September 18, 2022 10:23
Bash script for installation of latest maven.
#!/bin/bash
set -x
declare -r apacheMavenDownloadUrl="http://apache.cbox.biz/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz"
declare -r directoryName="mvn/"
if [[ $apacheMavenDownloadUrl =~ ([^/]+)\-bin\.tar\.gz$ ]]
then
declare -r resultFileName=$BASH_REMATCH
declare -r resultDirectoryName=${BASH_REMATCH[1]}
#!/bin/bash
# A little practice with sed from Georgi Naumov
stringToAppend="# we want to add this string\n"
filePath="apache2.conf"
# This will add bellow commend before the first occurence
# of LogFormat
# -r extended regular expression
# -i - in place
georginaumov@georgi:~/Documents/hello$ sbt
[info] Loading project definition from /home/georginaumov/Documents/hello/project
[info] Set current project to hello (in build file:/home/georginaumov/Documents/hello/)
> baseDirectory
[info] /home/georginaumov/Documents/hello
>
> inspect baseDirectory
[info] Setting: java.io.File = /home/georginaumov/Documents/hello
[info] Description:
[info] The base directory. Depending on the scope, this is the base directory for the build, project, configuration, or task.
[info] Provided by:
[info] {file:/home/georginaumov/Documents/hello/}root/*:baseDirectory
[info] Defined at:
[info] (sbt.Defaults) Defaults.scala:177
[info] Dependencies:
[info] *:thisProject
printBaseDirectory <<= streams map Tasks.printBaseDirectory(baseDirectory)
def printBaseDirectory(baseDir: sbt.File)(streams: TaskStreams): Unit = {
streams.log.info("Here I want to print value of baseDirectory")
}
error: type mismatch;
[error] Type error in expression
found : sbt.SettingKey[java.io.File]
required: sbt.File
(which expands to) java.io.File
printBaseDirectory <<= streams map Tasks.printBaseDirectory(baseDirectory.value)
import sbt.Keys.TaskStreams
import sbt._
object Tasks {
def printBaseDirectory(streams: TaskStreams, dir: File): Unit = {
streams.log.info(dir.getAbsolutePath)
}
}
lazy val printBaseDirectory: TaskKey[Unit] = TaskKey[Unit]("printBaseDirectory", "Print baseDirectory for the project", KeyRanks.ATask)
printBaseDirectory <<= (streams, baseDirectory) map Tasks.printBaseDirectory