Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.9
    • Fix Version/s: 3.5.2
    • Component/s: core
    • Labels:
      None

      Description

      JSR330 ( @Named, @Singeton, etc) currently supported for plugin development.

      Would like to see JSR250 as well(@PostConstruct, etc)

      Detail discussion is at http://maven.40175.n5.nabble.com/Maven-Plugin-and-JSR330-td5879508.html

        Issue Links

          Activity

          Hide
          mcculls Stuart McCulloch added a comment -

          Support for JSR250 lifecycle annotations can be enabled in the ContainerConfiguration, configured in
          maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:

          ContainerConfiguration cc = new DefaultContainerConfiguration()
              .setClassWorld( cliRequest.classWorld )
              .setRealm( containerRealm )
              .setClassPathScanning( PlexusConstants.SCANNING_INDEX )
              .setAutoWiring( true )
              .setJSR250Lifecycle( true )        // <--- enable support for @PostConstruct and @PreDestroy
              .setName( "maven" );
          

          You may also want to add javax.annotation to the list of packages exported to plugins from Maven core, defined in
          maven-core/src/main/resources/META-INF/maven/extension.xml:

          <!-- javax.annotation (JSR-250) -->
          <exportedPackage>javax.annotation.*</exportedPackage>
          

          otherwise it will use the package from the current JRE, which might not have it (ie. Java 7 and earlier) or might hide it by default (Jigsaw)

          Show
          mcculls Stuart McCulloch added a comment - Support for JSR250 lifecycle annotations can be enabled in the ContainerConfiguration , configured in maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java : ContainerConfiguration cc = new DefaultContainerConfiguration() .setClassWorld( cliRequest.classWorld ) .setRealm( containerRealm ) .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) .setAutoWiring( true ) .setJSR250Lifecycle( true ) // <--- enable support for @PostConstruct and @PreDestroy .setName( "maven" ); You may also want to add javax.annotation to the list of packages exported to plugins from Maven core, defined in maven-core/src/main/resources/META-INF/maven/extension.xml : <!-- javax.annotation (JSR-250) --> <exportedPackage>javax.annotation.*</exportedPackage> otherwise it will use the package from the current JRE, which might not have it (ie. Java 7 and earlier) or might hide it by default (Jigsaw)
          Hide
          mcculls Stuart McCulloch added a comment -

          Note: any mojos which have @PreDestroy methods will be disposed as soon as they're done (Maven tells the container about this explicitly in DefaultMavenPluginManager.java line 759) whereas leftover components which have @PreDestroy methods will be disposed at the end of the build. (The next container release should be more aggressive about disposing of non-mojo components.)

          Show
          mcculls Stuart McCulloch added a comment - Note: any mojos which have @PreDestroy methods will be disposed as soon as they're done (Maven tells the container about this explicitly in DefaultMavenPluginManager.java line 759) whereas leftover components which have @PreDestroy methods will be disposed at the end of the build. (The next container release should be more aggressive about disposing of non-mojo components.)
          Hide
          dantran Dan Tran added a comment -

          @Stuart, could you elaborate on 'next container release'? where is it? Can we file a JIRA as a reminder?

          Show
          dantran Dan Tran added a comment - @Stuart, could you elaborate on 'next container release'? where is it? Can we file a JIRA as a reminder?
          Hide
          dantran Dan Tran added a comment -

          Commit suggested changes at https://github.com/dantran/maven.git

          with a test case at https://github.com/dantran/maven-integration-testing.git

          so far my local test does not see PostConstruct working yet

          Show
          dantran Dan Tran added a comment - Commit suggested changes at https://github.com/dantran/maven.git with a test case at https://github.com/dantran/maven-integration-testing.git so far my local test does not see PostConstruct working yet
          Hide
          dantran Dan Tran added a comment -

          JSR 250 integration tests are now working. the commits are squashed at both maven and maven integration repo

          Show
          dantran Dan Tran added a comment - JSR 250 integration tests are now working. the commits are squashed at both maven and maven integration repo
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user dantran opened a pull request:

          https://github.com/apache/maven/pull/98

          MNG-6084 Support JSR 250 @PreDestory and @PostContruct

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/dantran/maven master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/maven/pull/98.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #98


          commit 582ca6591ee9d2ed1de5ea58d10cba19cb8baf1d
          Author: dantran <dantran@apache.org>
          Date: 2016-09-12T04:07:39Z

          MNG-6084 Support JSR 250 @PreDestory and @PostContruct


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user dantran opened a pull request: https://github.com/apache/maven/pull/98 MNG-6084 Support JSR 250 @PreDestory and @PostContruct You can merge this pull request into a Git repository by running: $ git pull https://github.com/dantran/maven master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven/pull/98.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #98 commit 582ca6591ee9d2ed1de5ea58d10cba19cb8baf1d Author: dantran <dantran@apache.org> Date: 2016-09-12T04:07:39Z MNG-6084 Support JSR 250 @PreDestory and @PostContruct
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user dantran opened a pull request:

          https://github.com/apache/maven-integration-testing/pull/15

          MNG-6084 Add test for JSR250 support

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/dantran/maven-integration-testing master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/maven-integration-testing/pull/15.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #15


          commit 14fe9317814cb922e464b506e4cbf0bb9e0dcc34
          Author: dantran <dantran@apache.org>
          Date: 2016-09-12T06:24:24Z

          MNG-6084 Add test for JSR250 support


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user dantran opened a pull request: https://github.com/apache/maven-integration-testing/pull/15 MNG-6084 Add test for JSR250 support You can merge this pull request into a Git repository by running: $ git pull https://github.com/dantran/maven-integration-testing master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven-integration-testing/pull/15.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #15 commit 14fe9317814cb922e464b506e4cbf0bb9e0dcc34 Author: dantran <dantran@apache.org> Date: 2016-09-12T06:24:24Z MNG-6084 Add test for JSR250 support
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dantran commented on the issue:

          https://github.com/apache/maven/pull/98

          PR for maven-integration-testing https://github.com/apache/maven-integration-testing/pull/15

          Show
          githubbot ASF GitHub Bot added a comment - Github user dantran commented on the issue: https://github.com/apache/maven/pull/98 PR for maven-integration-testing https://github.com/apache/maven-integration-testing/pull/15
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mfriedenhagen commented on a diff in the pull request:

          https://github.com/apache/maven-integration-testing/pull/15#discussion_r88809229

          — Diff: core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6084Jsr250PluginTest.java —
          @@ -0,0 +1,84 @@
          +package org.apache.maven.it;
          +
          +/*
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +
          +import org.apache.maven.it.util.ResourceExtractor;
          +
          +import java.io.File;
          +
          +/**
          + * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6084">MNG-6084</a>.
          + *
          + * @author Jason van Zyl
          — End diff –

          Is Jason really the author

          Show
          githubbot ASF GitHub Bot added a comment - Github user mfriedenhagen commented on a diff in the pull request: https://github.com/apache/maven-integration-testing/pull/15#discussion_r88809229 — Diff: core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6084Jsr250PluginTest.java — @@ -0,0 +1,84 @@ +package org.apache.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; + +/** + * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6084"> MNG-6084 </a>. + * + * @author Jason van Zyl — End diff – Is Jason really the author
          Hide
          rfscholte Robert Scholte added a comment -

          Dan Tran, nice new feature for M3.4.0. You're still a member of the maven team, so you should be able to apply it yourself.

          Show
          rfscholte Robert Scholte added a comment - Dan Tran , nice new feature for M3.4.0. You're still a member of the maven team, so you should be able to apply it yourself.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/maven/pull/98

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/maven/pull/98
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x Jigsaw #21 (See https://builds.apache.org/job/maven-3.x%20Jigsaw/21/)
          MNG-6084 Support JSR 250 @PreDestory and @PostContruct (dan.tran: rev 582ca6591ee9d2ed1de5ea58d10cba19cb8baf1d)

          • (edit) maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
          • (edit) pom.xml
          • (edit) maven-core/src/main/resources/META-INF/maven/extension.xml
          • (edit) maven-embedder/pom.xml
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x Jigsaw #21 (See https://builds.apache.org/job/maven-3.x%20Jigsaw/21/ ) MNG-6084 Support JSR 250 @PreDestory and @PostContruct (dan.tran: rev 582ca6591ee9d2ed1de5ea58d10cba19cb8baf1d) (edit) maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java (edit) pom.xml (edit) maven-core/src/main/resources/META-INF/maven/extension.xml (edit) maven-embedder/pom.xml
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1422 (See https://builds.apache.org/job/maven-3.x/1422/)
          MNG-6084 Support JSR 250 @PreDestory and @PostContruct (dan.tran: rev 582ca6591ee9d2ed1de5ea58d10cba19cb8baf1d)

          • (edit) maven-core/src/main/resources/META-INF/maven/extension.xml
          • (edit) maven-embedder/pom.xml
          • (edit) pom.xml
          • (edit) maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1422 (See https://builds.apache.org/job/maven-3.x/1422/ ) MNG-6084 Support JSR 250 @PreDestory and @PostContruct (dan.tran: rev 582ca6591ee9d2ed1de5ea58d10cba19cb8baf1d) (edit) maven-core/src/main/resources/META-INF/maven/extension.xml (edit) maven-embedder/pom.xml (edit) pom.xml (edit) maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
          Hide
          dantran Dan Tran added a comment -

          Special thanks to Stuart for guiding me thru this enhancement

          Show
          dantran Dan Tran added a comment - Special thanks to Stuart for guiding me thru this enhancement
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the issue:

          https://github.com/apache/maven-integration-testing/pull/15

          @dantran Can you squash? I will have a look and will merge soon.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the issue: https://github.com/apache/maven-integration-testing/pull/15 @dantran Can you squash? I will have a look and will merge soon.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dantran commented on the issue:

          https://github.com/apache/maven-integration-testing/pull/15

          already merged

          Show
          githubbot ASF GitHub Bot added a comment - Github user dantran commented on the issue: https://github.com/apache/maven-integration-testing/pull/15 already merged
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dantran closed the pull request at:

          https://github.com/apache/maven-integration-testing/pull/15

          Show
          githubbot ASF GitHub Bot added a comment - Github user dantran closed the pull request at: https://github.com/apache/maven-integration-testing/pull/15
          Hide
          stephenc Stephen Connolly added a comment -

          Maven 3.4.0 has been dropped. See this thread for more details.

          This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

          Show
          stephenc Stephen Connolly added a comment - Maven 3.4.0 has been dropped. See this thread for more details. This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.
          Hide
          michael-o Michael Osipov added a comment -
          Show
          michael-o Michael Osipov added a comment - Fixed with a7dddcb87626fec256f1b8ccbe957f94cdf401e4 .
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1654 (See https://builds.apache.org/job/maven-3.x/1654/)
          MNG-6084 Support JSR 250 annotations (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=a7dddcb87626fec256f1b8ccbe957f94cdf401e4)

          • (edit) maven-core/src/main/resources/META-INF/maven/extension.xml
          • (edit) maven-embedder/pom.xml
          • (edit) pom.xml
          • (edit) maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1654 (See https://builds.apache.org/job/maven-3.x/1654/ ) MNG-6084 Support JSR 250 annotations (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=a7dddcb87626fec256f1b8ccbe957f94cdf401e4 ) (edit) maven-core/src/main/resources/META-INF/maven/extension.xml (edit) maven-embedder/pom.xml (edit) pom.xml (edit) maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
          Hide
          hudson Hudson added a comment -

          Build unstable in Jenkins: Maven TLP (wip) » maven » pre-reset-master #3

          See https://builds.apache.org/job/maven-wip/job/maven/job/pre-reset-master/3/

          Show
          hudson Hudson added a comment - Build unstable in Jenkins: Maven TLP (wip) » maven » pre-reset-master #3 See https://builds.apache.org/job/maven-wip/job/maven/job/pre-reset-master/3/

            People

            • Assignee:
              dantran Dan Tran
              Reporter:
              dantran Dan Tran
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development