Fix MANIFEST generation
[gpl/argeo-slc.git] / org.argeo.slc.repo / src / org / argeo / slc / repo / maven / MavenConventionsUtils.java
index 09827885cc271cc4f2fbbfaebb33f6f1f91d7d02..f3e359fc9eae761046b3de4019c91f3d05158a0f 100644 (file)
@@ -1,43 +1,17 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.slc.repo.maven;
 
 import java.io.File;
-import java.util.Properties;
 import java.util.Set;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.aether.AetherTemplate;
+import org.argeo.api.cms.CmsLog;
 import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 
 /**
  * Static utilities around Maven which are NOT using the Maven APIs (conventions
  * based).
  */
 public class MavenConventionsUtils {
-       private final static Log log = LogFactory.getLog(MavenConventionsUtils.class);
+       private final static CmsLog log = CmsLog.getLog(MavenConventionsUtils.class);
 
        /**
         * Path to the file identified by this artifact <b>without</b> using Maven
@@ -162,66 +136,66 @@ public class MavenConventionsUtils {
                return p.toString();
        }
 
-       /**
-        * Directly parses Maven POM XML format in order to find all artifacts
-        * references under the dependency and dependencyManagement tags. This is
-        * meant to migrate existing pom registering a lot of artifacts, not to
-        * replace Maven resolving.
-        */
-       public static void gatherPomDependencies(AetherTemplate aetherTemplate, Set<Artifact> artifacts,
-                       Artifact pomArtifact) {
-               if (log.isDebugEnabled())
-                       log.debug("Gather dependencies for " + pomArtifact);
-
-               try {
-                       File file = aetherTemplate.getResolvedFile(pomArtifact);
-                       DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-                       Document doc = documentBuilder.parse(file);
-
-                       // properties
-                       Properties props = new Properties();
-                       props.setProperty("project.version", pomArtifact.getBaseVersion());
-                       NodeList properties = doc.getElementsByTagName("properties");
-                       if (properties.getLength() > 0) {
-                               NodeList propertiesElems = properties.item(0).getChildNodes();
-                               for (int i = 0; i < propertiesElems.getLength(); i++) {
-                                       if (propertiesElems.item(i) instanceof Element) {
-                                               Element property = (Element) propertiesElems.item(i);
-                                               props.put(property.getNodeName(), property.getTextContent());
-                                       }
-                               }
-                       }
-
-                       // dependencies (direct and dependencyManagement)
-                       NodeList dependencies = doc.getElementsByTagName("dependency");
-                       for (int i = 0; i < dependencies.getLength(); i++) {
-                               Element dependency = (Element) dependencies.item(i);
-                               String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent().trim();
-                               String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent().trim();
-                               String version = dependency.getElementsByTagName("version").item(0).getTextContent().trim();
-                               if (version.startsWith("${")) {
-                                       String versionKey = version.substring(0, version.length() - 1).substring(2);
-                                       if (!props.containsKey(versionKey))
-                                               throw new SlcException("Cannot interpret version " + version);
-                                       version = props.getProperty(versionKey);
-                               }
-                               NodeList scopes = dependency.getElementsByTagName("scope");
-                               if (scopes.getLength() > 0 && scopes.item(0).getTextContent().equals("import")) {
-                                       // recurse
-                                       gatherPomDependencies(aetherTemplate, artifacts,
-                                                       new DefaultArtifact(groupId, artifactId, "pom", version));
-                               } else {
-                                       // TODO: deal with scope?
-                                       // TODO: deal with type
-                                       String type = "jar";
-                                       Artifact artifact = new DefaultArtifact(groupId, artifactId, type, version);
-                                       artifacts.add(artifact);
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot process " + pomArtifact, e);
-               }
-       }
+//     /**
+//      * Directly parses Maven POM XML format in order to find all artifacts
+//      * references under the dependency and dependencyManagement tags. This is
+//      * meant to migrate existing pom registering a lot of artifacts, not to
+//      * replace Maven resolving.
+//      */
+//     public static void gatherPomDependencies(AetherTemplate aetherTemplate, Set<Artifact> artifacts,
+//                     Artifact pomArtifact) {
+//             if (log.isDebugEnabled())
+//                     log.debug("Gather dependencies for " + pomArtifact);
+//
+//             try {
+//                     File file = aetherTemplate.getResolvedFile(pomArtifact);
+//                     DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+//                     Document doc = documentBuilder.parse(file);
+//
+//                     // properties
+//                     Properties props = new Properties();
+//                     props.setProperty("project.version", pomArtifact.getBaseVersion());
+//                     NodeList properties = doc.getElementsByTagName("properties");
+//                     if (properties.getLength() > 0) {
+//                             NodeList propertiesElems = properties.item(0).getChildNodes();
+//                             for (int i = 0; i < propertiesElems.getLength(); i++) {
+//                                     if (propertiesElems.item(i) instanceof Element) {
+//                                             Element property = (Element) propertiesElems.item(i);
+//                                             props.put(property.getNodeName(), property.getTextContent());
+//                                     }
+//                             }
+//                     }
+//
+//                     // dependencies (direct and dependencyManagement)
+//                     NodeList dependencies = doc.getElementsByTagName("dependency");
+//                     for (int i = 0; i < dependencies.getLength(); i++) {
+//                             Element dependency = (Element) dependencies.item(i);
+//                             String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent().trim();
+//                             String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent().trim();
+//                             String version = dependency.getElementsByTagName("version").item(0).getTextContent().trim();
+//                             if (version.startsWith("${")) {
+//                                     String versionKey = version.substring(0, version.length() - 1).substring(2);
+//                                     if (!props.containsKey(versionKey))
+//                                             throw new SlcException("Cannot interpret version " + version);
+//                                     version = props.getProperty(versionKey);
+//                             }
+//                             NodeList scopes = dependency.getElementsByTagName("scope");
+//                             if (scopes.getLength() > 0 && scopes.item(0).getTextContent().equals("import")) {
+//                                     // recurse
+//                                     gatherPomDependencies(aetherTemplate, artifacts,
+//                                                     new DefaultArtifact(groupId, artifactId, "pom", version));
+//                             } else {
+//                                     // TODO: deal with scope?
+//                                     // TODO: deal with type
+//                                     String type = "jar";
+//                                     Artifact artifact = new DefaultArtifact(groupId, artifactId, type, version);
+//                                     artifacts.add(artifact);
+//                             }
+//                     }
+//             } catch (Exception e) {
+//                     throw new SlcException("Cannot process " + pomArtifact, e);
+//             }
+//     }
 
        /** Prevent instantiation */
        private MavenConventionsUtils() {