Author: rmannibucau
Date: Thu Mar 14 23:28:43 2013
New Revision: 1456717
URL: http://svn.apache.org/r1456717
Log:
TOMEE-797 adding jars.txt mvn plugin
Added:
tomee/tomee/trunk/maven/jarstxt-maven-plugin/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/pom.xml
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/jarstxt/
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/jarstxt/JarsTxtMojo.java
Modified:
tomee/tomee/trunk/maven/pom.xml
Added: tomee/tomee/trunk/maven/jarstxt-maven-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/jarstxt-maven-plugin/pom.xml?rev=1456717&view=auto
==============================================================================
--- tomee/tomee/trunk/maven/jarstxt-maven-plugin/pom.xml (added)
+++ tomee/tomee/trunk/maven/jarstxt-maven-plugin/pom.xml Thu Mar 14 23:28:43
2013
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<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">
+ <parent>
+ <artifactId>maven</artifactId>
+ <groupId>org.apache.openejb.maven</groupId>
+ <version>1.0.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>jarstxt-maven-plugin</artifactId>
+ <version>4.6.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+ <name>OpenEJB :: Maven Plugins :: jars.txt Maven Plugin</name>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <maven-plugin.prefix>jarstxt</maven-plugin.prefix>
+ </properties>
+</project>
Added:
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/jarstxt/JarsTxtMojo.java
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/jarstxt/JarsTxtMojo.java?rev=1456717&view=auto
==============================================================================
---
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/jarstxt/JarsTxtMojo.java
(added)
+++
tomee/tomee/trunk/maven/jarstxt-maven-plugin/src/main/java/org/apache/openejb/maven/jarstxt/JarsTxtMojo.java
Thu Mar 14 23:28:43 2013
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.apache.openejb.maven.jarstxt;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Set;
+
+@Mojo(name = "generate", threadSafe = true,
+ requiresDependencyResolution = ResolutionScope.COMPILE, defaultPhase =
LifecyclePhase.COMPILE)
+public class JarsTxtMojo extends AbstractMojo {
+ @Component
+ protected MavenProject project;
+
+ @Parameter(property = "outputFile", defaultValue =
"${project.build.directory}/${project.build.finalName}/WEB-INF/jars.txt" )
+ protected File outputFile;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (!outputFile.getParentFile().exists()) {
+ FileUtils.mkdir(outputFile.getParentFile().getAbsolutePath());
+ }
+
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(outputFile);
+
+ for (final Artifact a : (Set<Artifact>) project.getArtifacts()) {
+ if (!acceptScope(a.getScope()) || !acceptType(a.getType())) {
+ continue;
+ }
+
+ writer.write("mvn:" + a.getGroupId() + "/" + a.getArtifactId()
+ "/" + a.getVersion());
+ writer.write("\n");
+ }
+
+ writer.flush();
+ } catch (IOException e) {
+ getLog().error(e.getMessage(), e);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (IOException e) {
+ // no-op
+ }
+ }
+ }
+ }
+
+ private boolean acceptType(final String type) {
+ return "jar".equals(type) || "zip".equals(type);
+ }
+
+ private boolean acceptScope(final String scope) {
+ return Artifact.SCOPE_COMPILE.equals(scope) ||
Artifact.SCOPE_RUNTIME.equals(scope);
+ }
+}
Modified: tomee/tomee/trunk/maven/pom.xml
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/maven/pom.xml?rev=1456717&r1=1456716&r2=1456717&view=diff
==============================================================================
--- tomee/tomee/trunk/maven/pom.xml (original)
+++ tomee/tomee/trunk/maven/pom.xml Thu Mar 14 23:28:43 2013
@@ -38,6 +38,7 @@
<module>openejb-embedded-maven-plugin</module>
<module>maven-util</module>
<module>tomee-webapp-archetype</module>
+ <module>jarstxt-maven-plugin</module>
</modules>
<dependencyManagement>