1

I use external program,that creates jar. The code for this operation follows:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <configuration>
                        <tasks>
                            <property environment="env" />
                            <property name="appname" value="hellojavaworld" />
                            <echoproperties />
                            <exec dir="" executable="respawn.exe" searchpath="true">
                                <arg value="${basedir}\src\main\java\${appname}.app" />
                            </exec>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

The created jar is produced by respawn.exe which is later on used in a building process. I wanted to use the most proper way which is to install 3rd party jar to local maven repository. For this purpose it is used the command:

mvn install:install-file -Dfile...

This works as designed. I wanted to create pom.xml file that will be used during the building (parent-child), so the created jar will be copied to local maven repository. I am not able to do it, because maven creates own jar that is copied to local repository. Question is how to change maven to use different jar? I do not want to copy jar that creates maven,because it is different than the jar created by respawn.exe.

Jar comparison This link depicts the difference of these jars. You can see that jar on the right side (maven local repository) misses the abc folder with the appropriate classes.

Question is why?

Michal
  • 610
  • 10
  • 24
  • you are already in the Meta-Inf folder in one of your jars. What is outside of that meta-inf? – Christian Oct 12 '15 at 08:24
  • Possible duplicate of [How to manually install an artifact in Maven 2?](http://stackoverflow.com/questions/442230/how-to-manually-install-an-artifact-in-maven-2) – Joe Oct 12 '15 at 08:24
  • Well, If I go to the maven created jar, it contains just folder META-INF, but the original jar contains one more folder with classes. This is right missing in the maven jar. What is that? – Michal Oct 12 '15 at 11:18

1 Answers1

0

Maven will compile the Java source files (*.java) from src/main/java into target/classes. These classes will be packaged into the jar, by Maven.

PS Here just the Maven default locations are shown.

Looking at your question, it seems, you have no Java source files.

Verhagen
  • 3,885
  • 26
  • 36
  • That is true. But, on the other hand, I was able to install 3rd party jar to local repository through mvn install above command. So probably this works. I would like to call external exe using ant run plugin and that created jar installed to maven local repository. I was not able to figure out how to do it. Any comment? – Michal Oct 13 '15 at 06:49
  • The Maven command `mvn install:install-file` is used for uploading (deploying) a jar to a local Maven repository. It will not change the content of a jar! – Verhagen Oct 13 '15 at 06:58
  • Questions is: How was the jar (zip) on the left created and how was the jar (zip) on right created? Looks like the one on the right was created with Maven, as the archive contains a maven directory. The one on the left was created without Maven, as it does not have that container. – Verhagen Oct 13 '15 at 07:01
  • The point is that jar on the left side is created using the maven-antrun-plugin specified in pom.xml. Problem is,that jar is generated by external exe program,not by maven. Maven just use antrun plugin to call external exe. If I do mvn install for this pom.xml, it just creates jar on the right side without structure (abc,..). It works as designed. But if I do mvn install:installfile and path to this jar (earlier created by exe pgm), it is correct. Question is how to install jar through pom.xml which uses antrun plugin calling external exe program producing not maven jar? – Michal Oct 13 '15 at 08:00
  • Ok, this makes the set-up and question a lot clearer. Point why create an jar with Ant calling Ant from Maven? And then deploy the create jar, by Maven to the Maven repository? Why not call `mvn install:install-file` from Ant Task Exec (https://ant.apache.org/manual/Tasks/exec.html) or Ant Task Java (https://ant.apache.org/manual/Tasks/java.html). – Verhagen Oct 13 '15 at 08:10
  • Or switch completely to Maven, let it compile the sources, create the jar, and let it deploy the jar to the Maven repository. – Verhagen Oct 13 '15 at 08:12
  • I have just edited my question. Well I did not know about install-file from Ant. There might be also another way,but for self-learner it can be difficult. Let me try this solution. – Michal Oct 13 '15 at 08:13
  • To @Verhagen. I do not know how to switch to Maven, without using Ant. I need to call respawn.exe to produce jar. It uses file.app which is compiled by respawn.exe and output is the jar. If you know how to do it in Maven,please give us your idea. – Michal Oct 13 '15 at 08:14
  • @Michal what kind of developer environment are you using? Does not sound like Eclipse, or IntelliJ... – Verhagen Oct 13 '15 at 08:17
  • We use Aion with JNI interface. This is not just Java itself. I use Eclipse. – Michal Oct 13 '15 at 08:18
  • Ok, I see (never heard of Aion). The `respawn.exe` is also part of Aion, I guess? What does it do? Where do you need it for? Converting a Ant project to a Maven project is (most of the time) straightforward. As both tools do the same thing. Only Maven is based on defaults, where Ant Tasks, need all the details all the time. – Verhagen Oct 13 '15 at 08:48
  • I was able to use mvn install command from Maven AntRun Plugin. It would be possible solution. Is it possible to do it just in Maven, without using AntRun plugin? The point is that respawn.exe has to be executed to produce jar. – Michal Oct 13 '15 at 08:55
  • What does `respawn.exe` exactly do? What makes it so special? What is in the jar? If it are just the compiled java classes, any tool can create the jar (Ant, Maven, Gradle, etc) – Verhagen Oct 13 '15 at 09:00
  • It compiles app file that is written in Aion language. The output of this is jar. I cannot compile this app with standard compilers (C,C++,Java,etc.). I think Maven cannot do it itself. The only way is to use antrun plugin. There is also possibility to call jar file with parameter of app file which produces the same result (jar file),but it still leads me to use Ant script with exec. – Michal Oct 13 '15 at 11:16
  • Ok, hope you have anough background now, for what you try to accomplish. – Verhagen Oct 13 '15 at 12:25