Показаны сообщения с ярлыком setup. Показать все сообщения
Показаны сообщения с ярлыком setup. Показать все сообщения

среда, 17 марта 2010 г.

Maven для Erlang

Maven 2 - это система сборки изначально ориентированная на Java приложения.
Однако благодаря системе плагинов Maven способен работать с любым языком и на любой платформе (где запустится Java). Именно это делает Maven весьма интересным кандидатом на роль основной системы сборки при старте мультиязычного проекта или нескольких связанных проектов на разных языка программирования.
К достоинствам Maven так же можно понятие репозитария артефактов - хранилища в котором можно разместить что угодно. Все что доступно в хранилище, легко подключается к проекту.
К тому же для многих Continuous Integration серверов уже есть готовые плагины/расширения для взаимодействия с Maven.
Подробности установки Maven доступны на официальном сайте - здесь.

А краткая инструкция выглядит так:
  1. Установить JDK
  2. Скачать и распаковать архив Maven
  3. Создать или обновить системные переменные так, чтобы JAVA_HOME указывал на JDK и PATH включал в себя путь к директории /bin распакованного Maven.


Nexus - это одна из реализаций хранилища артефактов. Nexus доступен в двух версиях - Open Source и Professional. Подробное сравнение этих версий доступно здесь. Впрочем даже Nexus Open Source способен проксировать удаленные и хостить местные хранилища.
Подробности установки и настройки Nexus превосходно описаны в Nexus Book.

Краткая инструкция для Nexus Open Source:
  1. Установить Tomcat
  2. Скачать последнюю версию Nexus в виде war
  3. Переименовать nexus-webapp-x.x.x.war в nexus.war
  4. Задеплоить nexus.war используя менеджер Tomcat

После этого необходимо настроить Maven на его использование. Это делается добавлением в ~/.m2/settings.xml следующих строк:





nexus
*
http://beast-server/nexus/content/groups/public




nexus




central
http://central
true
true




central
http://central
true
true






nexus



releases
deployment
deployment123


snapshots
deployment
deployment123




Более подробно это описано в Nexus Book.

Теперь можно приступить к Erlang. Для взаимодействия с Erlang у Maven есть плагин - Erlang Maven Plugin
Его нет в публичных хранилищах, так что надо будет собрать его из исходников:

$ svn co https://maven-erlang.svn.sourceforge.net/svnroot/maven-erlang maven-erlang

Чтобы не повторять эти операции на каждом хосте который будет использовать этот плагин, его необходимо задеплоить в хранилище. Для этого необходимо добавить в pom.xml информацию о нашем хранилище в секцию distributionManagement:

$ cd ./maven-erlang/maven-erlang/trunk/
$ vim ./pom.xml



releases
http://beast-server/nexus/content/repositories/releases


snapshots
http://beast-server/nexus/content/repositories/snapshots


Теперь необходимо запустить

$ mvn deploy -Dmaven.test.skip=true

-Dmaven.test.skip=true необходим поскольку некоторые юнит тесты не проходят с последними версиями Erlang. В качестве альтернативы можно прописать версии kernel, stdlib и mnesia из вашего екземпляра Erlang в erlang-plugin/trunk/src/test/resources/mojo-test-release-1/src/main/erlang/release_name.rel и использовать

$ mvn deploy


Итог:
  • Установлен Maven
  • Развернуто хранилище артефактов
  • В хранилище добавлен Erlang Maven Plugin

понедельник, 15 марта 2010 г.

Faxien/Sinan для Erlang

Для удобной разработки приложений Erlang существуют следующие инструменты:
  • Faxien - система управления пакетами Erlang/OTP
  • Sinan - система сборки


Сначала надо получить faxien-launcher-universal-x.x.x.py c http://code.google.com/p/faxien/

И запустить его:
$ python ./faxien-launcher-universal-0.3.5.py
После установки можно посмотреть справку:
$ ~/lib/erlang/bin/faxien help

Faxien is a powerful package manager for the Erlang language. This
message is the gateway into further Faxien help.

Usage:
faxien help
faxien version
faxien [options|arguments...]

More Help:
faxien help commands: Lists all faxien commands
faxien help <command>: Gives help on an individual command
faxien help examples: Lists example usages of faxien
faxien alias: lists faxien command aliases

Short Examples:
faxien install-release sinan
faxien search yaws
faxien help search
ok

$ ~/lib/erlang/bin/faxien help commands

Commands:
help print help information
search search for remote packages
installed list the packages installed on the local system
describe-app print more information about a specific
application package
install-release install a release package
fetch-release fetch a release package into the specified
directory
install-app install an application package
fetch-app fetch an application package into the specified
directory
publish publish a package to remote repositories
remove-release uninstall a release package
remove-app uninstall an application package
upgrade-release upgrade a release package installed on the
local system
upgrade-all-releases upgrade all the release packages installed on
the local system
upgrade-app upgrade an application package installed on the
local system
upgrade-all-apps upgrade all the application packages installed
on the local system
translate-version translate one version type to another such as
an erts version to an erlang release version
version display the current Faxien version installed on
the local system
diff-config diff the configuration between two installed
versions of a release

Configuration Management Commands:
environment display information about the current Faxien
environment settings.
add-repo add a repo to search for packages in
remove-repo remove one of the repos Faxien is set to search
for packages in
show-repos display the repos Faxien is set to search for
packages in
add-publish-repo add a repo to publish packages to
remove-publish-repo remove one of the repos Faxien is set to
publish to
show-publish-repos display the repos Faxien is set to publish to
set-request-timeout set the timeout faxien uses for requests to
remote repositories
show-request-timeout display the timeout faxien uses for requests to
remote repositories
set-preferred-erts-vsn set the erts vsn faxien will search first
show-preferred-erts-vsn display the erts vsn faxien will search first
ok
Теперь можно поставить Erlang:
$ ~/lib/erlang/bin/faxien ir erl
ir - это install-release

И проверить его:
$ ~/lib/erlang/bin/erl
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:4:4]
[rq:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5 (abort with ^G)
1> q().
ok
2>
Теперь необходимо установить Sinan:
$ ~/lib/erlang/bin/faxien ir sinan
И проверить:
$ ~/lib/erlang/bin/sinan help
starting server now.
Unable to connect after 0 seconds. Waiting 1 second(s)
Describing tasks ...
release
Creates the *.rel, *.boot and *.script into the <build-area>/realeases/<vsn>
directory. It also builds up a release tar bal into the <build-area>/tar/ directory
depends on: build


clean
Removes the build area and everything underneath
depends on:


shell
Starts an erlang shell with all of the correct paths preset so the developer
can noodle with the code to his hearts content
depends on: build


gen
Generates a buildable default project layout
depends on:


build
Compiles all of the compilable files in the project
depends on: depends


version
Provides sinan server version information
depends on:


test
Runs all of the existing eunit unit tests in the project
depends on: build


dist
Creates an tarball of the distribution including release information.
Check documentation for the dist task for configuration information
depends on: release


depends
Analyzes all of the dependencies in the project and pulls down those that
arn't curently available locally
depends on:


doc
Runs edoc across all sources in the project and outputs it into the build area
depends on: build


help
Provides help information for the available tasks
depends on:


[help] stop


Итог:

Установлены Erlang, Faxien - система управления пакетам и Sinan - система сборки.