Skip to content

Customize generated code annotations#280

Merged
dmdashenkov merged 22 commits into
masterfrom
customize-Internal
Jan 8, 2019
Merged

Customize generated code annotations#280
dmdashenkov merged 22 commits into
masterfrom
customize-Internal

Conversation

@dmdashenkov

@dmdashenkov dmdashenkov commented Jan 4, 2019

Copy link
Copy Markdown
Contributor

Code generation annotations

In this PR we enable customization for annotations used for code generation.

If a Protobuf definition uses one of the API options (see options.proto), the resulting Java code is post-processed by adding respective API annotations.
Before this PR, the annotations were hard-coded:

  • io.spine.annotation.Beta;
  • io.spine.annotation.Experimental;
  • io.spine.annotation.Internal;
  • io.spine.annotation.SPI.

Starting from now, the annotation types may be specified with a Gradle extension:

modelCompiler {
    generateAnnotations {
        internal = 'foo.bar.MyInternal'
        beta = 'com.google.common.annotations.Beta'
        // ...
    }
}

Other significant changes:

  • (SPI) field option is deleted, since there are no obvious cases for such an option;
  • EnumAnnotator class is deleted, since it was never used;
  • new smoke tests module annotator-tests is added in order to verify the annotator plugin behaviour in cases when custom annotations are specified.

@dmdashenkov dmdashenkov added enhancement /Compiler WIP This work is still in progress. labels Jan 4, 2019
@dmdashenkov dmdashenkov self-assigned this Jan 4, 2019
@codecov

codecov Bot commented Jan 7, 2019

Copy link
Copy Markdown

Codecov Report

Merging #280 into master will decrease coverage by 0.83%.
The diff coverage is 14.63%.

@@             Coverage Diff              @@
##             master     #280      +/-   ##
============================================
- Coverage     76.12%   75.28%   -0.84%     
+ Complexity      769      760       -9     
============================================
  Files           322      324       +2     
  Lines          8494     8555      +61     
  Branches        549      552       +3     
============================================
- Hits           6466     6441      -25     
- Misses         1894     1981      +87     
+ Partials        134      133       -1

@dmdashenkov dmdashenkov removed the WIP This work is still in progress. label Jan 7, 2019
@dmdashenkov dmdashenkov requested a review from armiol January 7, 2019 15:30
@dmdashenkov

Copy link
Copy Markdown
Contributor Author

@armiol, PTAL.

@armiol armiol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmdashenkov LGTM with a tiny comment to address.


@CheckReturnValue
@ParametersAreNonnullByDefault
package io.spine.gradle.compiler;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the package purpose. I understand this is a test-source package, but still, let's have at least a couple of words.

@dmdashenkov dmdashenkov merged commit 2830975 into master Jan 8, 2019
@dmdashenkov dmdashenkov deleted the customize-Internal branch January 8, 2019 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants