Package: project_archer
Project archer is a program that allows easy switching between different
things such as projects, servers, application servers by changing the
current shell.Installationpip3installproject-archerConfigurationIn order to define a new type of a resource, let’s say aproject,
you need first to configure in your.bashrcthe following:eval"$(archerproject)"This defines a new function in the shell calledproject. Using this
command you’re able to manage the projects, as well as changing to the
current one.i.e. on my machine:Available projects:
 - mopyx.yml: mopyx
 - gsb.yml: Germanium Selector Builder
 ...
 - lic.yml: Germanium Licenses
 - gsr.yml: Germanium Star - Runner
Current project: <none>In order to create a new project just run:project-ntestThis opens the currently configured editor in the$EDITORshell
variable, and in there define what happens when switching to that
project. This file is created in~/.archer/projects/test.ymlconfig:name:Some descriptive name of your projectlayouts:-mavenexports:VAR1:valuerequires:-JAVA_HOMEcommands:command1:|ls -l ...command2:|# do something elsepwdactivate:|# this script runs only once after this project is selected..deactivate:|# this script runs when switching to another project..Layouts have the same structure, and hold commonactivate,deactivate,exportsandcommandsthat are used over multiple
projects. By just pointing to thelayoutall the scripts are being
mixed into the current project definition. Having arequiresenforces some environment variables to be present before switching to
the other project.Layouts have the same structure, except they reside in~/.archer/projects/layouts/*.yml.The variables that are exposed into theexportsare exported in the
current shell.Each of thecommandsis wrapped into a shell function and available
for execution.Example Maven Layoutlayout:name:mavenrequires:[PROJECT_HOME]exports:PROJECT_BUILD_FOLDER:target/MAVEN_OPTS:-Xmx2048mcommands:build:|CURRENT_FOLDER=$(pwd)cd $PROJECT_HOMEmvn install $@ $EXTRA_MAVEN_PARAMScd $CURRENT_FOLDERclean:|CURRENT_FOLDER=$(pwd)cd $PROJECT_HOMEmvn clean $@ $EXTRA_MAVEN_PARAMScd $CURRENT_FOLDERtest:|CURRENT_FOLDER=$(pwd)cd $PROJECT_HOMEmvn test $@ $EXTRA_MAVEN_PARAMScd $CURRENT_FOLDERcdproj:|cd $PROJECT_HOMErebuild:|clean && build $@And a sample project let’s say calledlic.yml:config:name:Germanium Licenseslayouts:-mavenexports:PROJECT_HOME:/home/raptor/projects/germanium-licenseactivate:|cdprojWhen callingproject lic, the project gets activated, our current
folder gets automatically changed to/home/raptor/projects/germanium-license, and in the current shell we
have now defined the commands,build,clean,test,cdprojandrebuildthat execute from any folder we’re in the
maven builds.To have another maven project, means now just having another file
pointing to the differentPROJECT_HOME.The commands are defined per domain of a problem, and when switching to
another project, the old commands, and all associated environment
variables are undefined.This also makes sense to start combining them, for example having aserverand aprojectdefinition and testing two projects against
tow application servers becomes:projectArebuildserverstop# we stop whatever tomcat my be activeservertomcat7redeploy&&serverstart# test on tomcat 7serverstop# we stop the current tomcatservertomcat8redeploy&&serverstart# test on tomcat 8serverstop# we stop the current tomcat
# we go now on testing project BprojectBrebuildservertomcat7redeploy&&serverstart# test on tomcat 7serverstop# we stop the current tomcatservertomcat8redeploy&&serverstart# test on tomcat 8Whenever in doubt a call to eitherprojectorservershows the
list of available servers, and projects, and the active server and
project.Note that everything becomes far more easier, since we don’t need to
move aroundwarfiles, search for running tomcats, and restarting
services manually, cleaning up old things. etc.Here’s actual layouts that I use for thetomcat-serverand themaven
project.