package org.apache.maven.repository; /* ==================================================================== * Copyright 2001-2004 The Apache Software Foundation. * * 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. * ==================================================================== */ import org.apache.maven.project.Dependency; import org.apache.maven.project.DependencyWrapper; /** * NativeArtifact represents a native/jni library artifact. * * @author Daniel Marchant * @version 1.0 6:43:32 AM * */ public class NativeArtifact extends GenericArtifact { private static String os = null; private Dependency depend; /** * @param dependency */ public NativeArtifact(Dependency dependency) { super(dependency); depend = new NativeDependency(getDependency()); if(os != null) return; String tempOs = System.getProperty("os.name"); if(tempOs.indexOf("indo") >-1) { os = "win"; } else if(tempOs.indexOf("olari") >-1) { os = "solaris"; } else if(tempOs.indexOf("inux") >-1) { os = "linux"; } else if(tempOs.indexOf("HP") >-1) { os = "hp-ux"; } else { os = tempOs.toLowerCase(); } } /** @see Artifact#generatePath */ public String generatePath() { return fs + getDependency().getArtifactDirectory() + fs + getDependency().getType() + "s" + fs + os + fs + getDependency().getVersion() + fs + getDependency().getArtifact(); } /** @see Artifact#getUrlPath */ public String getUrlPath() { return "/" + getDependency().getArtifactDirectory() + "/" + getDependency().getType() + "s" + "/" + os + "/" + getDependency().getVersion() + "/" + getDependency().getArtifact(); } /** * NativeDependency overrides methods in the dependencywrapper * to support a native dependency. * * @author Daniel Marchant * @version 1.0 7:40:15 AM * */ public class NativeDependency extends DependencyWrapper { /** * @param dependencyIn */ public NativeDependency(Dependency dependencyIn) { super(dependencyIn); } public String getArtifact() { if ( dependency.getJar() != null) { return dependency.getJar(); } return "lib" + getArtifactId() + "." + getExtension(); } /** * Return the extension based on the machine that the project is being built. * * @return extension */ public String getExtension() { return (os.equals("win"))? "dll" : "so"; } } }