Skip to main content

Project archer is a program that allows easy switching between different things such as projects, servers, application servers by changing the current shell.

Installation

pip3 install project-archer

Configuration

In order to define a new type of a resource, let’s say a project, you need first to configure in your .bashrc the following:

eval "$(archer project)"

This defines a new function in the shell called project. 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 -n test

This opens the currently configured editor in the $EDITOR shell variable, and in there define what happens when switching to that project. This file is created in ~/.archer/projects/test.yml

config:
  name: Some descriptive name of your project
  layouts:
  - maven
  exports:
    VAR1: value
  requires:
  - JAVA_HOME
  commands:
    command1: |
      ls -l ...
    command2: |
      # do something else
      pwd
  activate: |
    # 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 common activate, deactivate, exports and commands that are used over multiple projects. By just pointing to the layout all the scripts are being mixed into the current project definition. Having a requires enforces 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 the exports are exported in the current shell.

Each of the commands is wrapped into a shell function and available for execution.

Example Maven Layout

layout:
    name: maven
    requires: [ PROJECT_HOME ]
    exports:
        PROJECT_BUILD_FOLDER: target/
        MAVEN_OPTS: -Xmx2048m
    commands:
        build: |
            CURRENT_FOLDER=$(pwd)
            cd $PROJECT_HOME
            mvn install $@ $EXTRA_MAVEN_PARAMS
            cd $CURRENT_FOLDER
        clean: |
            CURRENT_FOLDER=$(pwd)
            cd $PROJECT_HOME
            mvn clean $@ $EXTRA_MAVEN_PARAMS
            cd $CURRENT_FOLDER
        test: |
            CURRENT_FOLDER=$(pwd)
            cd $PROJECT_HOME
            mvn test $@ $EXTRA_MAVEN_PARAMS
            cd $CURRENT_FOLDER
        cdproj: |
            cd $PROJECT_HOME
        rebuild: |
            clean && build $@

And a sample project let’s say called lic.yml:

config:
  name: Germanium Licenses
  layouts:
    - maven
  exports:
    PROJECT_HOME: /home/raptor/projects/germanium-license
  activate: |
    cdproj

When calling project 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, cdproj and rebuild that execute from any folder we’re in the maven builds.

To have another maven project, means now just having another file pointing to the different PROJECT_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 a server and a project definition and testing two projects against tow application servers becomes:

project A
rebuild
serverstop                              # we stop whatever tomcat my be active
server tomcat7
redeploy && serverstart                 # test on tomcat 7
serverstop                              # we stop the current tomcat
server tomcat8
redeploy && serverstart                 # test on tomcat 8
serverstop                              # we stop the current tomcat
# we go now on testing project B
project B
rebuild
server tomcat7
redeploy && serverstart                 # test on tomcat 7
serverstop                              # we stop the current tomcat
server tomcat8
redeploy && serverstart                 # test on tomcat 8

Whenever in doubt a call to either project or server shows 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 around war files, search for running tomcats, and restarting services manually, cleaning up old things. etc.

Here’s actual layouts that I use for the tomcat-server and the maven project.

Metadata

Release files for project_archer 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for project_archer 0.3.6
File Size Uploaded
project_archer-0.3.6.tar.gz 9.9 kB Details

Release files / project_archer-0.3.6.tar.gz

Download URL project_archer-0.3.6.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9b233cedf3e0a8de6ffbe0240cf539296d54e36b2ae551fa52eb33e823965bcd
BLAKE2b-256 checksum
How to use checksums
2fe4f9100b3710f073a3453c40b70c3ac4b49f247b8b19c086a73fe91b04cb4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.7

Release history Release notifications | RSS feed

This release

0.3.6 This release

1 release file

0.3.5

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page