mirror of https://github.com/apache/maven.git
[MNG-6084] Support JSR 250 annotations
This commit is contained in:
parent
bbae82c882
commit
d6ad86ceb0
|
@ -111,6 +111,7 @@ public class IntegrationTestSuite
|
|||
suite.addTestSuite( MavenITmng6057CheckReactorOrderTest.class );
|
||||
suite.addTestSuite( MavenITmng5895CIFriendlyUsageWithPropertyTest.class );
|
||||
suite.addTestSuite( MavenITmng6090CIFriendlyTest.class );
|
||||
suite.addTestSuite( MavenITmng6084Jsr250PluginTest.class );
|
||||
suite.addTestSuite( MavenITmng6173GetProjectsAndDependencyGraphTest.class );
|
||||
suite.addTestSuite( MavenITmng6173GetAllProjectsInReactorTest.class );
|
||||
suite.addTestSuite( MavenITmng5958LifecyclePhaseBinaryCompat.class );
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
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>.
|
||||
*/
|
||||
public class MavenITmng6084Jsr250PluginTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
private File testDir;
|
||||
|
||||
public MavenITmng6084Jsr250PluginTest()
|
||||
{
|
||||
super( "[3.5.1,)" );
|
||||
}
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6084-jsr250-support" );
|
||||
|
||||
}
|
||||
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testJsr250PluginExecution()
|
||||
throws Exception
|
||||
{
|
||||
//
|
||||
// Build a plugin that uses JSR 250 annotations
|
||||
//
|
||||
Verifier v0 = newVerifier( testDir.getAbsolutePath(), "remote" );
|
||||
v0.setAutoclean( false );
|
||||
v0.deleteDirectory( "target" );
|
||||
v0.deleteArtifacts( "org.apache.maven.its.mng6084" );
|
||||
v0.executeGoal( "install" );
|
||||
v0.verifyErrorFreeLog();
|
||||
v0.resetStreams();
|
||||
|
||||
//
|
||||
// Execute the JSR 250 plugin
|
||||
//
|
||||
Verifier v1 = newVerifier( testDir.getAbsolutePath(), "remote" );
|
||||
v1.setAutoclean( false );
|
||||
v1.executeGoal( "org.apache.maven.its.mng6084:jsr250-maven-plugin:0.0.1-SNAPSHOT:hello" );
|
||||
v1.verifyErrorFreeLog();
|
||||
v1.resetStreams();
|
||||
v1.verifyTextInLog( "Hello! I am a component using JSR 250 with @PostConstruct support" );
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng6084</groupId>
|
||||
<artifactId>jsr250-maven-plugin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>JSR 250 Maven Plugin</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mavenVersion>3.5.0</mavenVersion>
|
||||
<mavenPluginPluginVersion>3.2</mavenPluginPluginVersion>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>jsr250-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>${mavenVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<version>${mavenPluginPluginVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>${mavenPluginPluginVersion}</version>
|
||||
<configuration>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>mojo-descriptor</id>
|
||||
<goals>
|
||||
<goal>descriptor</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>help-goal</id>
|
||||
<goals>
|
||||
<goal>helpmojo</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>sisu-maven-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-index</id>
|
||||
<goals>
|
||||
<goal>main-index</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,60 @@
|
|||
package org.apache.maven.plugins;
|
||||
|
||||
/*
|
||||
* 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 javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@Named
|
||||
@Singleton
|
||||
public class Jsr250Component
|
||||
{
|
||||
|
||||
@PostConstruct
|
||||
public void init()
|
||||
{
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println( "Hello! I am a component using JSR 250 with @PostConstruct support" );
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public void hello()
|
||||
{
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println( "Hello! I am a component that is being used via constructor injection! That's right, I'm a JSR 330 badass." );
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void cleanup()
|
||||
{
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println( "Hello! I am a component using JSR 250 with @PreDestroy support" );
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.apache.maven.plugins;
|
||||
|
||||
/*
|
||||
* 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 javax.inject.Inject;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
|
||||
@Mojo( name = "hello", defaultPhase = LifecyclePhase.VALIDATE, requiresProject = false )
|
||||
public class Jsr250Mojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
private Jsr250Component component;
|
||||
|
||||
@Inject
|
||||
public Jsr250Mojo( Jsr250Component component )
|
||||
{
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
//
|
||||
// Say hello to the world, my little constructor-injected component!
|
||||
//
|
||||
component.hello();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue