Joda-Beans Maven plugin

Maven plugin for Joda-Beans

License

License

Categories

Categories

Maven Build Tools Joda-Beans Application Layer Libs Code Generators
GroupId

GroupId

org.joda
ArtifactId

ArtifactId

joda-beans-maven-plugin
Last Version

Last Version

1.3.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Joda-Beans Maven plugin
Maven plugin for Joda-Beans
Project URL

Project URL

https://github.com/JodaOrg/joda-beans-maven-plugin
Project Organization

Project Organization

Joda.org
Source Code Management

Source Code Management

https://github.com/JodaOrg/joda-beans-maven-plugin

Download joda-beans-maven-plugin

How to add to project

<plugin>
    <groupId>org.joda</groupId>
    <artifactId>joda-beans-maven-plugin</artifactId>
    <version>1.3.2</version>
</plugin>

Dependencies

compile (7)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5
org.apache.maven : maven-plugin-api jar 3.6.1
org.apache.maven : maven-model jar 3.6.1
org.apache.maven : maven-artifact jar 3.6.1
org.apache.maven : maven-core jar 3.6.1
org.sonatype.plexus : plexus-build-api jar 0.0.7
org.codehaus.plexus : plexus-utils jar 3.0.24

test (2)

Group / Artifact Type Version
junit : junit jar 4.13.1
com.tngtech.java : junit-dataprovider jar 1.13.1

Project Modules

There are no modules declared in this project.

Joda-Beans plugin for Maven

This project provides a Maven plugin for Joda-Beans.

Goals

This plugin has two goals - validate and generate.

Validate

The validate goal is used to check that no Joda-Beans need regeneration. It can be used from the command line as mvn joda-beans:validate.

This goal has the following optional configuration items:

  • indent - as per the command line, the amount of indentation used, either the word "tab", or a number, such as "2" or "4". Default is "4". Property is ${joda.beans.indent}.
  • prefix - as per the command line, the prefix used by fields. Default is "". Property is ${joda.beans.prefix}.
  • config - as per the command line, the config to use, "jdk" or "guava". Default is "guava". Property is ${joda.beans.config}.
  • generatedAnnotation - set to "true" to add @Generated annotations. Property is ${joda.beans.generatedAnnotation}.
  • verbose - as per the command line, a number from "0" (quiet) to "3" (verbose). Property is ${joda.beans.verbose}.
  • stopOnError - whether the build should continue when an error is found. Default is "true". Property is ${joda.beans.stopOnError}.
  • skip - skips the plugin

The goal is bound to the process-sources phase of the lifecycle by default.

Generate

The generate goal is used to generate or regenerate any Joda-Beans in the project source directory. It can be used from the command line as mvn joda-beans:generate.

This goal has the following optional configuration items:

  • indent - as per the command line, the amount of indentation used, either the word "tab", or a number, such as "2" or "4". Default is "4". Property is ${joda.beans.indent}.
  • prefix - as per the command line, the prefix used by fields. Default is "". Property is ${joda.beans.prefix}.
  • eol - as per the command line, the line separator used to write generated files, either "lf", "crlf", or "cr". Default is System.lineSeparator. Property is ${joda.beans.eol}.
  • config - as per the command line, the config to use, "jdk6" pr "guava". Default is "guava". Property is ${joda.beans.config}.
  • generatedAnnotation - set to "true" to add @Generated annotations. Property is ${joda.beans.generatedAnnotation}.
  • verbose - as per the command line, a number from "0" (quiet) to "3" (verbose). Property is ${joda.beans.verbose}.
  • skip - skips the plugin

The goal is bound to the process-sources phase of the lifecycle by default.

Setting up the pom

This section outlines the changes required in the pom for the plugin.

Declaration

The plugin will need to be declared in the pom to be used from the command line. One way to achieve this is using <pluginManagement>:

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.joda</groupId>
          <artifactId>joda-beans-maven-plugin</artifactId>
          <version>1.3.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

Configuration

It is recommended that any configuration should be set using properties. Note that in many cases, the default values of the properties (4 spaces and no prefix) will be fine.

If you do need to configure the plugin, your properties might look like this:

  <properties>
    <joda.beans.indent>2</joda.beans.indent>
    <joda.beans.prefix>_</joda.beans.prefix>
    ...
  </properties>

If you do not want to use properties, then a <configuration> block can be used instead. However, in most cases, properties are easier to manage and clutter up your pom less.

Running as part of the main build

The following XML configuration will configure the plugin to run the validate goal during the Maven lifecycle, ensuring that the Joda-Beans are up to date. If they are not, the user would be expected to run mvn joda-beans:generate from the command line:

  <build>
    <plugins>
      <plugin>
        <groupId>org.joda</groupId>
        <artifactId>joda-beans-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <id>joda-beans-validate</id>
            <goals>
              <goal>validate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

To generate the sources as part of the build, rather than validating them, use this configuration:

  <build>
    <plugins>
      <plugin>
        <groupId>org.joda</groupId>
        <artifactId>joda-beans-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <id>joda-beans-generate</id>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Running with Eclipse and M2E

Joda-Beans can be used within Eclipse using Maven and M2E. Version 1.0 and later of this plugin contains an additional XML configuration file for the M2E plugin. This avoids the need for an additional M2E connector.

To get an even better integration, use Joda-Beans v1.5 or later and add the following to your project pom:

  <profiles>
    <profile>
      <id>joda-beans-eclipse</id>
      <activation>
        <property>
          <name>eclipse.buildId</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.joda</groupId>
            <artifactId>joda-beans-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-sources</phase>
                <goals>
                  <goal>generate-no-resolve</goal>
                </goals>
                <configuration>
                  <eclipse>true</eclipse>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

This profile only activates when running in Eclipse IDE. It causes the generate-no-resolve goal to be executed using the special "eclipse=true" mode. This mode means that when a bean is edited, the Joda-Beans source generator is triggered, and the file recompiled. Note that the processing in Eclipse takes a few seconds to refresh properly.

(generate-no-resolve is a special mode from v1.2.0 that avoids resolving the classpath, which can give Eclipse problems)

Joda-Beans version

Version 0.7.3 and beyond of the plugin generates code using the Joda-Beans version in the project classpath. If the project does not have the dependency available then generation is skipped.

Version 1.2.0 and beyond offers a goal generate-no-resolve that reads the property joda.beans.version and resolves the dependency in the local repository. The version is defaulted to v2.5.0 of Joda-Beans.

Version 1.3.0 and beyond supports the property joda.beans.generatedAnnotation. The Joda-Beans version is defaulted to v2.7.0 of Joda-Beans.

Version 1.3.2 and beyond supports the property joda.beans.eol. The Joda-Beans version is defaulted to v2.8.1 of Joda-Beans.

Release process

  • Update version (README.md, not pom.xml)
  • Commit and push
  • mvn clean release:clean release:prepare release:perform
org.joda

Joda.org

Versions

Version
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1
1.0
0.7.3
0.7.2