simple-maven-file-filtering

Basic support for file-filtering (ie replacing variables in text files) for maven plugins.

Лицензия

Лицензия

Категории

Категории

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

Группа

com.github.fracpete
Идентификатор

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

simple-maven-file-filtering
Последняя версия

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

0.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

simple-maven-file-filtering
Basic support for file-filtering (ie replacing variables in text files) for maven plugins.
Организация-разработчик

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

University of Waikato, Hamilton, NZ
Система контроля версий

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

https://github.com/fracpete/simple-maven-file-filtering

Скачать simple-maven-file-filtering

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

<!-- https://jarcasting.com/artifacts/com.github.fracpete/simple-maven-file-filtering/ -->
<dependency>
    <groupId>com.github.fracpete</groupId>
    <artifactId>simple-maven-file-filtering</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.fracpete/simple-maven-file-filtering/
implementation 'com.github.fracpete:simple-maven-file-filtering:0.0.2'
// https://jarcasting.com/artifacts/com.github.fracpete/simple-maven-file-filtering/
implementation ("com.github.fracpete:simple-maven-file-filtering:0.0.2")
'com.github.fracpete:simple-maven-file-filtering:jar:0.0.2'
<dependency org="com.github.fracpete" name="simple-maven-file-filtering" rev="0.0.2">
  <artifact name="simple-maven-file-filtering" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.fracpete', module='simple-maven-file-filtering', version='0.0.2')
)
libraryDependencies += "com.github.fracpete" % "simple-maven-file-filtering" % "0.0.2"
[com.github.fracpete/simple-maven-file-filtering "0.0.2"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.apache.maven : maven-plugin-api jar 3.2.5

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 3.8.2
org.codehaus.plexus : plexus-component-api jar 1.0-alpha-33

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

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

simple-maven-file-filtering

Library for applying simple file filtering (ie expanding of variables) in text files to be used with maven plugins.

Examples

Use the following call of FilterUtils.filterFile to expand only project-related variables (like ${project.name} or ${project.version}):

import com.github.fracpete.simplemavenfilefiltering.FilterUtils;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.logging.Log;
import java.nio.file.Path;

Model model = ...;  // the Maven model that your plugin has access to 
Log log = ...;      // the log instance from your plugin
Path source = ...;  // the source file with the variables unexpanded
Path target = ...;  // the target file to write with the variables expanded   

FilterUtils.filterFile(log, source, target, model);

If you want to replace other variables, e.g., parameters form your own plugin, then you can supply a map of variables:

import com.github.fracpete.simplemavenfilefiltering.FilterUtils;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.logging.Log;
import java.nio.file.Path;
import java.utils.Map;
import java.utils.HashMap;

Model model = ...;  // the Maven model that your plugin has access to 
Log log = ...;      // the log instance from your plugin
Path source = ...;  // the source file with the variables unexpanded
Path target = ...;  // the target file to write with the variables expanded   
Map<String, String> vars = new HashMap<>();
vars.put("myvar1", "some_value");
vars.put("something", "else");

FilterUtils.filterFile(log, source, target, model, vars);

If you have to use a variable prefix/suffix pair other than the default ${ and }, you can supply these using the following methods:

  • filterFile(Log log, Path input, Path output, Model model, String varPrefix, String varSuffix)
  • filterFile(Log log, Path input, Path output, Model model, Map<String, String> additional, String varPrefix, String varSuffix)

Maven

Use the following dependency to include the library in your Maven plugin:

    <dependency>
      <groupId>com.github.fracpete</groupId>
      <artifactId>simple-maven-file-filtering</artifactId>
      <version>0.0.1</version>
    </dependency>

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

Версия
0.0.2
0.0.1