Skip to content

Commit

Permalink
move to maven3 annotation plugin instead of jefrog anno mojo
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Dec 11, 2012
1 parent 4a76e8d commit 9637fdf
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 72 deletions.
92 changes: 49 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,62 +23,67 @@
</scm>

<dependencies>

<!-- Maven classes maintained as compatibility layer for tools done with Maven 2. -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.jfrog.maven.annomojo</groupId>
<artifactId>maven-plugin-tools-anno</artifactId>
<version>1.4.1</version>
<scope>runtime</scope>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.1</version>
</dependency>


<dependency>
<groupId>org.jfrog.maven.annomojo</groupId>
<artifactId>maven-plugin-anno</artifactId>
<version>1.4.1</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.1</version>
</dependency>


<!-- dependencies to annotations -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.1</version>
</dependency>
<!-- generated help mojo has a dependency to plexus-utils -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.1</version>
</dependency>


</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.9</version>
<dependencies>

<dependency>
<groupId>org.jfrog.maven.annomojo</groupId>
<artifactId>maven-plugin-tools-anno</artifactId>
<version>1.4.1</version>
<scope>runtime</scope>
</dependency>

</dependencies>

<configuration>
<extractors>
<extractor>javaanno</extractor>
</extractors>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.1</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>


</plugin>

<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<!-- if you want to generate help goal -->
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -93,7 +98,7 @@

</build>


<!--
<repositories>
<repository>
<id>jfrog</id>
Expand All @@ -108,6 +113,7 @@
<url>http://repo.jfrog.org/artifactory/plugins-releases</url>
</pluginRepository>
</pluginRepositories>
-->

<distributionManagement>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.jfrog.maven.annomojo.annotations.MojoParameter;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;

/**
*
Expand All @@ -18,13 +19,15 @@ public abstract class AbstractDeployMojo extends AbstractMojo
/**
*
*/
@MojoParameter(expression="${component.org.apache.maven.artifact.deployer.ArtifactDeployer}",required=true,readonly=true)
@Component(role = org.apache.maven.artifact.deployer.ArtifactDeployer.class)
//@MojoParameter(expression="${component.org.apache.maven.artifact.deployer.ArtifactDeployer}",required=true,readonly=true)
private ArtifactDeployer deployer;

/**
*
*/
@MojoParameter(expression="${localRepository}",required=true,readonly=true)
@Parameter(property = "localRepository", required=true,readonly=true)
//@MojoParameter(expression="${localRepository}",required=true,readonly=true)
private ArtifactRepository localRepository;

public abstract void execute() throws MojoExecutionException, MojoFailureException;
Expand Down
73 changes: 47 additions & 26 deletions src/main/java/org/bsc/maven/plugin/libutils/DeployFolderMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,154 +18,175 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.WriterFactory;
import org.jfrog.maven.annomojo.annotations.MojoComponent;
import org.jfrog.maven.annomojo.annotations.MojoGoal;
import org.jfrog.maven.annomojo.annotations.MojoParameter;
import org.jfrog.maven.annomojo.annotations.MojoRequiresProject;

/**
* Installs artifacts from folder to remote repository.
*
*/
@MojoRequiresProject(false)
@MojoGoal("deploy-folder")
@Mojo( name = "deploy-folder",
requiresProject = true)
//@MojoRequiresProject(false)
//@MojoGoal("deploy-folder")
public class DeployFolderMojo extends AbstractDeployMojo
{
/**
* preview mode
*/
@MojoParameter(defaultValue="false")
@Parameter(defaultValue = "false")
//@MojoParameter(defaultValue="false")
private boolean preview;

/**
*
*/
@MojoParameter
@Parameter()
//@MojoParameter
private String includes[] = new String[0];

/**
*
*/
@MojoParameter
@Parameter()
//@MojoParameter
private String excludes[] = new String[0];

/**
* GroupId of the artifact to be deployed. Retrieved from POM file if specified.
*
*/
@MojoParameter(expression="${groupId}")
@Parameter(property="groupId")
//@MojoParameter(expression="${groupId}")
private String groupId;

/**
* ArtifactId prefix of the artifacts to be deployed. Retrieved from POM file if specified.
*
*/
@MojoParameter( expression="${artifactId-prefix}",defaultValue="")
@Parameter(property="artifactId-prefix", defaultValue="")
//@MojoParameter( expression="${artifactId-prefix}",defaultValue="")
private String artifactIdPrefix = "";

/**
* ArtifactId postfix of the artifacts to be deployed. Retrieved from POM file if specified.
*
*/
@MojoParameter( expression="${artifactId-postfix}",defaultValue="")
@Parameter(property="artifactId-postfix", defaultValue="")
//@MojoParameter( expression="${artifactId-postfix}",defaultValue="")
private String artifactIdPostfix = "";

/**
* Version of the artifact to be deployed. Retrieved from POM file if specified.
*
* @parameter expression="${version}"
*/
@MojoParameter(expression="${version}")
@Parameter(property="version")
//@MojoParameter(expression="${version}")
private String version;

@MojoParameter(expression="${filePattern}",required=false,description="reg-ex pattern. If it matchs then group(1) will be artifactId and group(2) will be version")
/**
* reg-ex pattern. If it matchs then group(1) will be artifactId and group(2) will be version
*/
@Parameter(property="filePattern",required=false)
//@MojoParameter(expression="${filePattern}",required=false,description="reg-ex pattern. If it matchs then group(1) will be artifactId and group(2) will be version")
private String filePattern = null;

/**
* Description passed to a generated POM file (in case of generatePom=true)
*
* @parameter expression="${generatePom.description}"
*/
@Parameter(property="generatePom.description")
private String description;

/**
* Folder to be deployed.
*
*/
@MojoParameter(expression="${project.build.directory}",required=true)
@Parameter(property="project.build.directory",required=true)
//@MojoParameter(expression="${project.build.directory}",required=true)
private File outputFolder;

/**
* Folder to be deployed.
*
*/
@MojoParameter(expression="${sourceFolder}",required=true)
@Parameter(property="sourceFolder",required=true)
//@MojoParameter(expression="${sourceFolder}",required=true)
private File sourceFolder;

/**
* Server Id to map on the &lt;id&gt; under &lt;server&gt; section of settings.xml
* In most cases, this parameter will be required for authentication.
*
*/
@MojoParameter(expression="${repositoryId}", defaultValue="remote-repository")
@Parameter(property="repositoryId", defaultValue="remote-repository")
//@MojoParameter(expression="${repositoryId}", defaultValue="remote-repository")
private String repositoryId;

/**
* The type of remote repository layout to deploy to. Try <i>legacy</i> for
* a Maven 1.x-style repository layout.
*
*/
@MojoParameter(expression="${repositoryLayout}", defaultValue="default",required=true)
@Parameter(property="repositoryLayout", defaultValue="default",required=true)
//@MojoParameter(expression="${repositoryLayout}", defaultValue="default",required=true)
private String repositoryLayout;

/**
* Map that contains the layouts
*
*/
@MojoComponent(role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout")
@Component(role=org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout.class)
//@MojoComponent(role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout")
private Map<String,ArtifactRepositoryLayout> repositoryLayouts;

/**
* URL where the artifact will be deployed. <br/>
* ie ( file://C:\m2-repo or scp://host.com/path/to/repo )
*
*/
@MojoParameter(expression="${url}",required=true)
@Parameter(property="url",required=true)
//@MojoParameter(expression="${url}",required=true)
private String url;

/**
* Component used to create an artifact
*
*/
@MojoComponent
@Component
//@MojoComponent
private ArtifactFactory artifactFactory;

/**
* Component used to create a repository
*
*/
@MojoComponent
@Component
//@MojoComponent
private ArtifactRepositoryFactory repositoryFactory;

/**
* Upload a POM for this artifact. Will generate a default POM if none is
* supplied with the pomFile argument.
*
*/
@MojoParameter(expression="${generatePom}",defaultValue="true")
@Parameter(property="generatePom",defaultValue="true")
//@MojoParameter(expression="${generatePom}",defaultValue="true")
private boolean generatePom;

/**
* Whether to deploy snapshots with a unique version or not.
*
* @parameter expression="${uniqueVersion}" default-value="true"
*/
@MojoParameter(expression="${uniqueVersion}", defaultValue="true")
@Parameter(property="uniqueVersion", defaultValue="true")
//@MojoParameter(expression="${uniqueVersion}", defaultValue="true")
private boolean uniqueVersion;

/**
Expand Down

0 comments on commit 9637fdf

Please sign in to comment.