通过UI将Sources.jar存档部署到Artifactory

时间:2021-04-11 13:28:42

We are using a third party library that doesn't exist in Maven Central Repository and we wan't to deploy this archive as an artifact to Artifactory. We are trying to do that via Artifactory UI and we successfully deployed both archive.jar and archive-sources.jar. The problem occurs when we add this dependency through Gradle to our build.gradle script. Archive.jar is fetched from our repository but archive-sources.jar is not fetched. We are developing with Eclipse and you can see the problem through screenshot.

我们正在使用Maven Central Repository中不存在的第三方库,我们不会将此存档作为工件部署到Artifactory。我们正试图通过Artifactory UI来实现这一点,并且我们成功部署了archive.jar和archive-sources.jar。当我们通过Gradle将此依赖项添加到build.gradle脚本时,会出现问题。 Archive.jar是从我们的存储库中获取的,但是不提取archive-sources.jar。我们正在使用Eclipse进行开发,您可以通过屏幕截图查看问题。

通过UI将Sources.jar存档部署到Artifactory

We tried several things including defining classifier in Artifactory UI, editing pom with Artifactory POM Editor, publishing pom file manually and nothing worked. Whatever we do we couldn't get the source of this archive. Any kind of help would save a lot of time and effort. Thanks!

我们尝试了几个方面,包括在Artifactory UI中定义分类器,使用Artifactory POM编辑器编辑pom,手动发布pom文件,没有任何工作。无论我们做什么,我们都无法获得此档案的来源。任何形式的帮助都可以节省大量的时间和精力。谢谢!

Screenshot of Artifactory UI:

Artifactory UI的屏幕截图:

通过UI将Sources.jar存档部署到Artifactory

2 个解决方案

#1


0  

We have solved the issue but it was a little bit complicated. There are many steps to apply the solution:

我们已经解决了这个问题,但它有点复杂。应用该解决方案有许多步骤:

In the case of jain-sdp archive, here are the steps:

在jain-sdp存档的情况下,以下是步骤:

1- Deploy jain-sdp sources artifact with classifier "sources" as it is shown in the screenshot.

1-使用分类器“sources”部署jain-sdp sources工件,如屏幕截图所示。

2- Manually upload jain-sdp.pom file with including the "sourceDirectory" tag:

2-手动上传包含“sourceDirectory”标记的jain-sdp.pom文件:

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>javax.sip</groupId>
    <version>1.2</version>
    <artifactId>jain-sip</artifactId>
  </parent>
  <groupId>javax.sdp</groupId>
  <artifactId>jain-sdp</artifactId>
  <version>1.0.1111</version>
  <packaging>jar</packaging>
  <name>jain-sdp</name>
  <url>http://jain-sip.dev.java.net</url>
   <build>
    <sourceDirectory>../../src/javax/</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <includes>
                    <include>**/sdp/**</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>target/javax/</directory>
            <includes>
                <include>sdp/**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>    
   </build>

</project>

3- Manually create the below files.

3-手动创建以下文件。

pom.xml:

pom.xml中:

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>javax.sip</groupId>
    <version>1.2</version>
    <artifactId>jain-sip</artifactId>
  </parent>
  <groupId>javax.sdp</groupId>
  <artifactId>jain-sdp</artifactId>
  <version>1.0.1111</version>
  <packaging>jar</packaging>
  <name>jain-sdp</name>
  <url>http://jain-sip.dev.java.net</url>
   <build>
    <sourceDirectory>../../src/javax/</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <includes>
                    <include>**/sdp/**</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>target/javax/</directory>
            <includes>
                <include>sdp/**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>    
   </build>

</project>

pom.properties:

pom.properties:

#Generated by Maven
#Tue Feb 05 21:33:14 CET 2008
version=1.2
groupId=javax.sdp
artifactId=jain-sdp

4- Include the files that have been created in Step 3 to the below path in the archive:

4-将步骤3中创建的文件包含在存档中的以下路径中:

META-INF/maven/javax.sdp/jain-sdp/pom.properties META-INF/maven/javax.sdp/jain-sdp/pom.xml

META-INF / maven / javax.sdp / jain-sdp / pom.properties META-INF / maven / javax.sdp / jain-sdp / pom.xml

Note that these files should be added to jain-sdp.jar, not jain-sdp-sources.jar

请注意,这些文件应该添加到jain-sdp.jar,而不是jain-sdp-sources.jar

5- Upload jain-sdp.jar to the Artifactory through UI

5-通过UI将jain-sdp.jar上传到Artifactory

I think that these steps should be done manually. There is no other way to solve this problem that I can think of. sourceDirectories should be included manually to pom files and archives manually.

我认为这些步骤应该手动完成。没有其他方法可以解决我能想到的这个问题。应手动将sourceDirectories包含在pom文件和归档中。

#2


0  

Add your Source files into your jar, observing the same directory structure as for the class file contents.

将源文件添加到jar中,观察与类文件内容相同的目录结构。

This means you don't need to manage another artifact and don't need to update your pom.xml

这意味着您无需管理其他工件,也无需更新pom.xml

Simplest steps to perform this addition is on the CLI: change into your source directory and "update" the jar. Doing it with this specific current working directory which will preserve the correct relative filenames.

在CLI上执行此添加的最简单步骤是:切换到源目录并“更新”jar。使用此特定的当前工作目录执行此操作,该目录将保留正确的相对文件名。

For example, I have directory structure:

例如,我有目录结构:

~/project/src/com/mycompany
~/project/target

and have built a jar into ~/project/target named existing.jar

并在〜/ project / target中创建了一个名为existing.jar的jar

$ cd ~/project/src; jar uvf ../target/existing.jar com

$ jar tvf ~/project/target/existing.jar

should show class files and source files in the same tree.

应该在同一个树中显示类文件和源文件。

  ...
  6923 Sun Sep 18 23:19:36 PDT 2016 org/spacehq/reddit/util/http/ResponseType.class
  4676 Sun Sep 18 22:30:38 PDT 2016 org/spacehq/reddit/util/http/ResponseType.groovy
  ...

IntelliJ IDEA detects these source files in the jar and presents them when opening the related class file. I'd assume other full featured IDEs would also.

IntelliJ IDEA在jar中检测这些源文件,并在打开相关的类文件时显示它们。我假设其他功能齐全的IDE也会。

You should of course be able to automate this somehow with Maven, to take out the human step, but this is good for a one-off.

你当然应该能够以某种方式与Maven自动化,以取消人类的步骤,但这对于一次性是好的。

#1


0  

We have solved the issue but it was a little bit complicated. There are many steps to apply the solution:

我们已经解决了这个问题,但它有点复杂。应用该解决方案有许多步骤:

In the case of jain-sdp archive, here are the steps:

在jain-sdp存档的情况下,以下是步骤:

1- Deploy jain-sdp sources artifact with classifier "sources" as it is shown in the screenshot.

1-使用分类器“sources”部署jain-sdp sources工件,如屏幕截图所示。

2- Manually upload jain-sdp.pom file with including the "sourceDirectory" tag:

2-手动上传包含“sourceDirectory”标记的jain-sdp.pom文件:

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>javax.sip</groupId>
    <version>1.2</version>
    <artifactId>jain-sip</artifactId>
  </parent>
  <groupId>javax.sdp</groupId>
  <artifactId>jain-sdp</artifactId>
  <version>1.0.1111</version>
  <packaging>jar</packaging>
  <name>jain-sdp</name>
  <url>http://jain-sip.dev.java.net</url>
   <build>
    <sourceDirectory>../../src/javax/</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <includes>
                    <include>**/sdp/**</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>target/javax/</directory>
            <includes>
                <include>sdp/**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>    
   </build>

</project>

3- Manually create the below files.

3-手动创建以下文件。

pom.xml:

pom.xml中:

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>javax.sip</groupId>
    <version>1.2</version>
    <artifactId>jain-sip</artifactId>
  </parent>
  <groupId>javax.sdp</groupId>
  <artifactId>jain-sdp</artifactId>
  <version>1.0.1111</version>
  <packaging>jar</packaging>
  <name>jain-sdp</name>
  <url>http://jain-sip.dev.java.net</url>
   <build>
    <sourceDirectory>../../src/javax/</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <includes>
                    <include>**/sdp/**</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>target/javax/</directory>
            <includes>
                <include>sdp/**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>    
   </build>

</project>

pom.properties:

pom.properties:

#Generated by Maven
#Tue Feb 05 21:33:14 CET 2008
version=1.2
groupId=javax.sdp
artifactId=jain-sdp

4- Include the files that have been created in Step 3 to the below path in the archive:

4-将步骤3中创建的文件包含在存档中的以下路径中:

META-INF/maven/javax.sdp/jain-sdp/pom.properties META-INF/maven/javax.sdp/jain-sdp/pom.xml

META-INF / maven / javax.sdp / jain-sdp / pom.properties META-INF / maven / javax.sdp / jain-sdp / pom.xml

Note that these files should be added to jain-sdp.jar, not jain-sdp-sources.jar

请注意,这些文件应该添加到jain-sdp.jar,而不是jain-sdp-sources.jar

5- Upload jain-sdp.jar to the Artifactory through UI

5-通过UI将jain-sdp.jar上传到Artifactory

I think that these steps should be done manually. There is no other way to solve this problem that I can think of. sourceDirectories should be included manually to pom files and archives manually.

我认为这些步骤应该手动完成。没有其他方法可以解决我能想到的这个问题。应手动将sourceDirectories包含在pom文件和归档中。

#2


0  

Add your Source files into your jar, observing the same directory structure as for the class file contents.

将源文件添加到jar中,观察与类文件内容相同的目录结构。

This means you don't need to manage another artifact and don't need to update your pom.xml

这意味着您无需管理其他工件,也无需更新pom.xml

Simplest steps to perform this addition is on the CLI: change into your source directory and "update" the jar. Doing it with this specific current working directory which will preserve the correct relative filenames.

在CLI上执行此添加的最简单步骤是:切换到源目录并“更新”jar。使用此特定的当前工作目录执行此操作,该目录将保留正确的相对文件名。

For example, I have directory structure:

例如,我有目录结构:

~/project/src/com/mycompany
~/project/target

and have built a jar into ~/project/target named existing.jar

并在〜/ project / target中创建了一个名为existing.jar的jar

$ cd ~/project/src; jar uvf ../target/existing.jar com

$ jar tvf ~/project/target/existing.jar

should show class files and source files in the same tree.

应该在同一个树中显示类文件和源文件。

  ...
  6923 Sun Sep 18 23:19:36 PDT 2016 org/spacehq/reddit/util/http/ResponseType.class
  4676 Sun Sep 18 22:30:38 PDT 2016 org/spacehq/reddit/util/http/ResponseType.groovy
  ...

IntelliJ IDEA detects these source files in the jar and presents them when opening the related class file. I'd assume other full featured IDEs would also.

IntelliJ IDEA在jar中检测这些源文件,并在打开相关的类文件时显示它们。我假设其他功能齐全的IDE也会。

You should of course be able to automate this somehow with Maven, to take out the human step, but this is good for a one-off.

你当然应该能够以某种方式与Maven自动化,以取消人类的步骤,但这对于一次性是好的。