Profile Activator Extension

Provide flexible Maven profile activation via script

Лицензия

Лицензия

Apache-2.0
Категории

Категории

Maven Компиляция и сборка
Группа

Группа

com.carrotgarden.maven
Идентификатор

Идентификатор

profile-activator-extension
Последняя версия

Последняя версия

1.3.20190513180922
Дата

Дата

Тип

Тип

jar
Описание

Описание

Profile Activator Extension
Provide flexible Maven profile activation via script
Ссылка на сайт

Ссылка на сайт

https://github.com/random-maven/profile-activator-extension
Организация-разработчик

Организация-разработчик

CarrotGarden
Система контроля версий

Система контроля версий

https://github.com/random-maven/profile-activator-extension

Скачать profile-activator-extension

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.carrotgarden.maven/profile-activator-extension/ -->
<dependency>
    <groupId>com.carrotgarden.maven</groupId>
    <artifactId>profile-activator-extension</artifactId>
    <version>1.3.20190513180922</version>
</dependency>
// https://jarcasting.com/artifacts/com.carrotgarden.maven/profile-activator-extension/
implementation 'com.carrotgarden.maven:profile-activator-extension:1.3.20190513180922'
// https://jarcasting.com/artifacts/com.carrotgarden.maven/profile-activator-extension/
implementation ("com.carrotgarden.maven:profile-activator-extension:1.3.20190513180922")
'com.carrotgarden.maven:profile-activator-extension:jar:1.3.20190513180922'
<dependency org="com.carrotgarden.maven" name="profile-activator-extension" rev="1.3.20190513180922">
  <artifact name="profile-activator-extension" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.carrotgarden.maven', module='profile-activator-extension', version='1.3.20190513180922')
)
libraryDependencies += "com.carrotgarden.maven" % "profile-activator-extension" % "1.3.20190513180922"
[com.carrotgarden.maven/profile-activator-extension "1.3.20190513180922"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
org.scala-lang : scala-compiler jar 2.12.8
org.mvel : mvel2 jar 2.4.4.Final
org.codehaus.groovy : groovy-jsr223 jar 2.5.7
cat.inspiracio : rhino-js-engine jar 1.7.10

provided (2)

Идентификатор библиотеки Тип Версия
org.apache.maven : maven-core jar 3.5.2
org.codehaus.plexus : plexus-component-annotations jar 1.7.1

Модули Проекта

Данный проект не имеет модулей.

Profile Activator Extension

Provide flexible Maven profile activation via script.

Reference feature implementation, vote for MNG-6345.

Apache License, Version 2.0, January 2004 Travis Status

Install Production Release Development Release
Artifact Central Bintray

Similar extensions

Extension features

Usage Examples:

Profile activator is configured in two steps:

  1. Register project extension
${project.basedir}/.mvn/extensions.xml
<extension>
   <groupId>com.carrotgarden.maven</groupId>
   <artifactId>profile-activator-extension</artifactId>
</extension>
  1. Provide activation script inside the magic property
<profile>
   <activation>
      <property>
         <name>[ACTIVATOR:MVELSCRIPT]</name>
         <value>
<![CDATA[
   isdef property1 && isdef property2 && property1 == "hello-maven" && project.packaging == "bundle" 
]]>
         </value>
       </property>
   </activation>
</profile>

Script variables

Tip: check examples first.

Activator script has access to

Merged Properties

Activator script has ordered and merged view of

  • project properties: pom.xml/<properties>
  • system properties form: System.getProperties()
  • user properties from user-provided command line -D options

Merged properties scopes

  • properties are injected in the default script variable scope (for scripting engines that have such)
  • there is also an extension-provided map value, which contains a copy of the default scope
  • use value map to access variables with dot in the name or when there is no default scope

Example default scope access syntax: the following expression extracts the value of pom.xml/<properties>/<property1>

  • Groovy syntax: not available, use value["property1"]
  • JavaScript syntax: property1 (same result as value["property1"])
  • MVEL Script syntax: property1 (same result as value["property1"])

Example value map access syntax: the following expression extracts the value of user.name which originally comes from a system property, and which is considered "invalid name" in the default scope:

  • Groovy syntax: value["user.name"]
  • JavaScript syntax: value["user.name"]
  • MVEL Script syntax: value["user.name"]

Resolved Project Model

Resolved interpolated project descriptor is exposed in the form of project model bean .

Activator script has access to the project model as an object named project.

Example project object access syntax: the following expression extracts the value of pom.xml/<packaging> which is available as public String getPackaging()

  • Groovy syntax: project.packaging (same result as project.getPackaging())
  • JavaScript syntax: project.packaging (same result as project.getPackaging())
  • MVEL Script syntax: project.packaging (same result as project.getPackaging())

Variable existence check

Normally, scripting engine will throw an error when trying to access a variable which is not defined.

Example variable existence check syntax:

  • Groovy syntax: not available, use null-test: if ( value["property1"] ) { ... }
  • JavaScript syntax: if ( typeof property1 !== 'undefined' ) { ... }
  • MVEL Script syntax: if ( isdef property1 ) { ... }

In practice, null-test is sufficient in most cases

  • if ( value["property1"] ) { ... }

Project model members are always defined, but can return null.

Build yourself

cd /tmp
git clone git@github.com:random-maven/profile-activator-extension.git
cd profile-activator-extension
./mvnw.sh clean install -B -P skip-test
com.carrotgarden.maven

Версии библиотеки

Версия
1.3.20190513180922
1.2.20180119141943
1.1.20180118221118