Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么ivy将本地解析的jar放在libs目录的子目录中_Java_Ivy - Fatal编程技术网

Java 为什么ivy将本地解析的jar放在libs目录的子目录中

Java 为什么ivy将本地解析的jar放在libs目录的子目录中,java,ivy,Java,Ivy,我没有常春藤的经验,也不知道如何解决这个问题,这可能是我不了解常春藤造成的 因此,我在ivysettings.xml中使用了这个文件系统来使用本地文件系统repo <ivysettings> <settings defaultResolver="central" /> <resolvers> <ibiblio name="central" m2compatible="true"/> <filesystem

我没有常春藤的经验,也不知道如何解决这个问题,这可能是我不了解常春藤造成的

因此,我在ivysettings.xml中使用了这个文件系统来使用本地文件系统repo

<ivysettings>
   <settings defaultResolver="central" />
   <resolvers>
      <ibiblio name="central" m2compatible="true"/>
      <filesystem name='local'>
        <artifact pattern='/home/tester/JAVA/tester-libs/'/>
      </filesystem>
   </resolvers>
   <modules>
      <module organisation="myorg" resolver="local"/>
   </modules>
</ivysettings>
更新: 下面是build.xml文件,它已更改为使用Mark Hunter提到的常春藤检索模式

<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="Naps" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
    <description>Builds, tests, and runs the project Naps.</description>
    <import file="nbproject/build-impl.xml"/>
    <property name="one-jar.dist.dir" value="/home/tester/JAVA/one-jar-ant"/>
    <import file="${one-jar.dist.dir}/one-jar-ant-task.xml" optional="true"/>

    <target name="-check-for-ivy">
        <available property="have.ivy" resource="fr/jayasoft/ivy/ant/antlib.xml"/>
    </target>
    <target name="-ivy-define" depends="-check-for-ivy" unless="have.ivy">
        <taskdef resource="fr/jayasoft/ivy/ant/antlib.xml" uri="antlib:fr.jayasoft.ivy.ant">
            <classpath>
                <fileset dir="${ivy.home}">
                    <include name="ivy*.jar"/>
                    <include name="lib/*.jar"/>
                </fileset>
            </classpath>
        </taskdef>
    </target>
    <target name="-ivy-retrieve" depends="-ivy-define" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
        <ivy:resolve/> <!-- Tell Ivy to resolve dependencies -->
        <ivy:retrieve conf="napsjar" pattern="lib/[artifact].[ext]"/>
        <pathconvert property="ivy.classpath.computed" dirsep="/" pathsep=":">
            <path>
                <fileset dir="lib" includes="*.jar"/>
            </path>
            <map from="${basedir}${file.separator}" to=""/>
        </pathconvert>
        <propertyfile file="nbproject/project.properties">
            <entry operation="=" key="ivy.classpath" value="${ivy.classpath.computed}"/>
        </propertyfile>
    </target>
    <target name="-pre-compile" depends="-ivy-retrieve"/>
    <target name="-pre-compile-single" depends="-ivy-retrieve"/>
    <target name="-post-clean">
        <delete dir="lib"/>
    </target>

    <!-- fix ivy task -->
    <target name="-pre-jfx-jar">
        <move file="lib/JarL-NA.jar/JarL.jar" todir="lib"/>
        <delete dir="lib/JarL-NA.jar"/>
    </target>

    <!-- one-jar task -->
    <target name="-post-jfx-jar">
        <one-jar destfile="naps-one-jar.jar">
            <manifest>
                <attribute name="One-Jar-Main-Class" value="jarl.Main"/>
            </manifest>
            <main>
                <fileset dir="/home/tester/WORKSPACE/NetBeans/Naps/build/classes"/>
            </main>
            <lib>
                <fileset dir="/home/tester/WORKSPACE/NetBeans/Naps/lib"/>
            </lib>
        </one-jar>
    </target>    
</project>

生成、测试和运行项目NAP。
这里是使用配置的ivy.xml,尽管不确定为什么它会改变任何东西

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="http://www.jayasoft.org/misc/ivy/samples/ivy.xsd"
>
    <info organisation="org.naps" module="naps"/>
    <configurations>
        <conf name="napsjar" description="Jars used by application"/>
    </configurations>
    <dependencies>
        <dependency org="commons-configuration" name="commons-configuration" rev="1.10" conf="napsjar->default"/>
        <dependency org="NA"  name="JarL" rev="NA" conf="napsjar->default"/>
    </dependencies>
</ivy-module>

这些更改导致lib/JarL-NA.jar/JarL-NA.jar成为lib/JarL.jar/JarL.jar,它仍然在lib的子目录中,现在阻止了我的简单重命名步骤表单的工作

其余的依赖项都在lib中,与预期的一样,也与以前一样


另外,这些更改现在阻止了nb解析commons配置,因此源代码无法再导入该类。

以下项目是如何设置和使用ivy任务的示例。您正在使用的构建文件看起来像是生成的,并且遵循一些旧的使用模式

希望能有帮助

例子 此项目已定制为使用“本地libs”目录作为文件存储库。这适用于某些LIB与源代码一起提供的场景,因为它们无法从外部存储库(如Maven Central)获得

├── build.xml
├── ivysettings.xml
├── ivy.xml
├── local-libs
│   └── JarL-1.0.jar
└── target
    ├── dist
    │   └── lib
    │       ├── commons-configuration-1.10.jar
    │       ├── commons-lang-2.6.jar
    │       ├── commons-logging-1.1.1.jar
    │       └── JarL-1.0.jar
    └── ivy-reports
        ├── ivy-report.css
        └── org.naps-naps-napsjar.html
运行构建后,将在“目标”目录下创建两个目录:

  • “dist/lib”:包含由ivy管理的文件。检查“解决”任务的工作方式
  • “ivy报告”:告诉您ivy如何确定依赖关系的HTML报告
  • 应该注意的是,我还提供了一个示例,说明如何创建一个包含由ivy管理的类路径列表的属性

    编译文件 如果生成文件不正确,请注意顶部的命名空间。Ivy不再需要明确的任务定义。还包括一个安装ivy的目标,如果它不在构建服务器上。最后请注意常春藤“解析”、“报告”、“缓存路径”和“检索”任务是如何调用的:

    <project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">
    
        <!--
        ================
        Build properties
        ================
        -->
        <property name="src.dir"          location="src/main/java"/>
        <property name="resources.dir"    location="src/main/resources"/>
        <property name="test.src.dir"     location="src/test/java"/>
        <property name="build.dir"        location="target"/>
        <property name="dist.dir"         location="${build.dir}/dist"/>
    
        <property name="jar.main.class" value="jarl.Main"/>
        <property name="jar.file"       value="${dist.dir}/${ant.project.name}.jar"/>
    
        <available classname="org.apache.ivy.Main" property="ivy.installed"/> 
    
        <!--
        ===========
        Build setup
        ===========
        -->
        <target name="install-ivy" description="Install ivy" unless="ivy.installed">
            <mkdir dir="${user.home}/.ant/lib"/>
            <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
            <fail message="Ivy has been installed. Run the build again"/>
        </target>
    
        <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
            <ivy:resolve/>
    
            <ivy:report todir='${build.dir}/ivy-reports' graph='false' xml='false'/>
    
            <ivy:cachepath pathid="naps.path" conf="napsjar"/>
        </target>
    
        <!--
        =====================
        Build and run targets
        =====================
        -->
    
        <target name="build" depends="resolve" description="Do stuff">
    
            <!-- Populate a lib directory with the ivy resolved files -->
            <ivy:retrieve pattern="${dist.dir}/lib/[artifact]-[revision](-[classifier]).[ext]" conf="napsjar"/>
    
            <!-- Print the classpath managed by ivy -->
            <pathconvert property="naps.path.prop" refid="naps.path"/>
            <echo message="Ivy managed classpath: ${naps.path.prop}"/>
        </target>
    
    
        <!--
        =============
        Clean targets
        =============
        -->
        <target name="clean" description="Cleanup build files">
            <delete dir="${build.dir}"/>
        </target>
    
        <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
            <ivy:cleancache/>
        </target>
    
    </project>
    
    
    
    ivy.xml 注意如何使用特殊组织“NA”引用本地文件

    
    
    ivysettings.xml “模块”部分告诉ivy使用文件系统解析器解析“NA”组织工件。工件模式告诉ivy如何解析本地文件。最好包含一个版本号

    <ivysettings>
       <settings defaultResolver="central" />
       <resolvers>
          <ibiblio name="central" m2compatible="true"/>
          <filesystem name='local'>
            <artifact pattern='${ivy.settings.dir}/local-libs/[artifact]-[revision].[ext]'/>
          </filesystem>
       </resolvers>
       <modules>
          <module organisation="NA" resolver="local"/>
       </modules>
    </ivysettings>
    

    以下项目是如何设置和使用常春藤任务的示例。您正在使用的构建文件看起来像是生成的,并且遵循一些旧的使用模式

    希望能有帮助

    例子 此项目已定制为使用“本地libs”目录作为文件存储库。这适用于某些LIB与源代码一起提供的场景,因为它们无法从外部存储库(如Maven Central)获得

    ├── build.xml
    ├── ivysettings.xml
    ├── ivy.xml
    ├── local-libs
    │   └── JarL-1.0.jar
    └── target
        ├── dist
        │   └── lib
        │       ├── commons-configuration-1.10.jar
        │       ├── commons-lang-2.6.jar
        │       ├── commons-logging-1.1.1.jar
        │       └── JarL-1.0.jar
        └── ivy-reports
            ├── ivy-report.css
            └── org.naps-naps-napsjar.html
    
    运行构建后,将在“目标”目录下创建两个目录:

  • “dist/lib”:包含由ivy管理的文件。检查“解决”任务的工作方式
  • “ivy报告”:告诉您ivy如何确定依赖关系的HTML报告
  • 应该注意的是,我还提供了一个示例,说明如何创建一个包含由ivy管理的类路径列表的属性

    编译文件 如果生成文件不正确,请注意顶部的命名空间。Ivy不再需要明确的任务定义。还包括一个安装ivy的目标,如果它不在构建服务器上。最后请注意常春藤“解析”、“报告”、“缓存路径”和“检索”任务是如何调用的:

    <project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">
    
        <!--
        ================
        Build properties
        ================
        -->
        <property name="src.dir"          location="src/main/java"/>
        <property name="resources.dir"    location="src/main/resources"/>
        <property name="test.src.dir"     location="src/test/java"/>
        <property name="build.dir"        location="target"/>
        <property name="dist.dir"         location="${build.dir}/dist"/>
    
        <property name="jar.main.class" value="jarl.Main"/>
        <property name="jar.file"       value="${dist.dir}/${ant.project.name}.jar"/>
    
        <available classname="org.apache.ivy.Main" property="ivy.installed"/> 
    
        <!--
        ===========
        Build setup
        ===========
        -->
        <target name="install-ivy" description="Install ivy" unless="ivy.installed">
            <mkdir dir="${user.home}/.ant/lib"/>
            <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
            <fail message="Ivy has been installed. Run the build again"/>
        </target>
    
        <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
            <ivy:resolve/>
    
            <ivy:report todir='${build.dir}/ivy-reports' graph='false' xml='false'/>
    
            <ivy:cachepath pathid="naps.path" conf="napsjar"/>
        </target>
    
        <!--
        =====================
        Build and run targets
        =====================
        -->
    
        <target name="build" depends="resolve" description="Do stuff">
    
            <!-- Populate a lib directory with the ivy resolved files -->
            <ivy:retrieve pattern="${dist.dir}/lib/[artifact]-[revision](-[classifier]).[ext]" conf="napsjar"/>
    
            <!-- Print the classpath managed by ivy -->
            <pathconvert property="naps.path.prop" refid="naps.path"/>
            <echo message="Ivy managed classpath: ${naps.path.prop}"/>
        </target>
    
    
        <!--
        =============
        Clean targets
        =============
        -->
        <target name="clean" description="Cleanup build files">
            <delete dir="${build.dir}"/>
        </target>
    
        <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
            <ivy:cleancache/>
        </target>
    
    </project>
    
    
    
    ivy.xml 注意如何使用特殊组织“NA”引用本地文件

    
    
    ivysettings.xml “模块”部分告诉ivy使用文件系统解析器解析“NA”组织工件。工件模式告诉ivy如何解析本地文件。最好包含一个版本号

    <ivysettings>
       <settings defaultResolver="central" />
       <resolvers>
          <ibiblio name="central" m2compatible="true"/>
          <filesystem name='local'>
            <artifact pattern='${ivy.settings.dir}/local-libs/[artifact]-[revision].[ext]'/>
          </filesystem>
       </resolvers>
       <modules>
          <module organisation="NA" resolver="local"/>
       </modules>
    </ivysettings>
    

    以下项目是如何设置和使用常春藤任务的示例。您正在使用的构建文件看起来像是生成的,并且遵循一些旧的使用模式

    希望能有帮助

    例子 此项目已定制为使用“本地libs”目录作为文件存储库。这适用于某些LIB与源代码一起提供的场景,因为它们无法从外部存储库(如Maven Central)获得

    ├── build.xml
    ├── ivysettings.xml
    ├── ivy.xml
    ├── local-libs
    │   └── JarL-1.0.jar
    └── target
        ├── dist
        │   └── lib
        │       ├── commons-configuration-1.10.jar
        │       ├── commons-lang-2.6.jar
        │       ├── commons-logging-1.1.1.jar
        │       └── JarL-1.0.jar
        └── ivy-reports
            ├── ivy-report.css
            └── org.naps-naps-napsjar.html
    
    运行构建后,将在“目标”目录下创建两个目录:

  • “dist/lib”:包含由ivy管理的文件。检查“解决”任务的工作方式
  • “ivy报告”:告诉您ivy如何确定依赖关系的HTML报告
  • 应该注意的是,我
    <ivysettings>
       <settings defaultResolver="central" />
       <resolvers>
          <ibiblio name="central" m2compatible="true"/>
          <filesystem name='local'>
            <artifact pattern='${ivy.settings.dir}/local-libs/[artifact]-[revision].[ext]'/>
          </filesystem>
       </resolvers>
       <modules>
          <module organisation="NA" resolver="local"/>
       </modules>
    </ivysettings>