JavaPackager icon indicating copy to clipboard operation
JavaPackager copied to clipboard

`${name}-${version}-runnable.jar` is not found in deployment directory

Open fvarrui opened this issue 2 years ago • 27 comments

There is now a new issue. The ${name}-${version}-runnable.jar is not found in deployment directory. In the deployement directory i find ${name}.jar without version and 'runnable'.

Am i missing some configuration details that i have to consider in the new Version?

The very last step during packaging seems to rename the build artifact jar file. This is the message:

Concatenating files [/target/deploy/linux/assets/startup.sh,/target/deploy/linux/name-version-runnable.jar] into file [/target/deploy/linux/<name>.jar]

best, Kia

Originally posted by @kia in https://github.com/fvarrui/JavaPackager/issues/335#issuecomment-1677088268

fvarrui avatar Aug 16 '23 08:08 fvarrui

@kia

There is now a new issue. The ${name}-${version}-runnable.jar is not found in deployment directory. In the deployement directory i find ${name}.jar without version and 'runnable'.

As I'm seeing in your output, the runnable JAR should be in target/deploy/linux, as you are setting outputDirectory option pointing to this directory. The runnable JAR file is not there?

Am i missing some configuration details that i have to consider in the new Version?

I think nothing has been changed.

The very last step during packaging seems to rename the build artifact jar file. This is the message:

Concatenating files [/target/deploy/linux/assets/startup.sh,/target/deploy/linux/name-version-runnable.jar] into file [/target/deploy/linux/<name>.jar]

The runnable JAR is concatenated to the BASH script in order to create the executable.

I guess you made a mistake here: Concatenating files [/target/deploy/linux/assets/startup.sh,/target/deploy/linux/name-version-runnable.jar] into file [/target/deploy/linux/<name>] ... the destination of concat is not a JAR file, right?

fvarrui avatar Aug 17 '23 10:08 fvarrui

Hi @fvarrui

I didn't change the configuration in our pom.xml . The only thing i changed was the version number of the java packager from 1.7.2 to 1.7.3 and suddenly this error occurred. When i go back to the older version of the javapackager then it works again.

But to answer your last question: the destination of concat is an executable on linux. But then there is a <name>-runnable.jar in that directory instead of a <name>-<version>-runnable.jar

kia avatar Aug 17 '23 13:08 kia

In git i found that in 1.7.3 in the class io.github.fvarrui.javapackager.maven.CreateRunnableJar the line (number 91) element("finalName", name + "-" + version) is removed in the new Version. This could be the cause of the problem. I added this line again rebuild the JavaPackager and the issue is gone.

kia avatar Aug 18 '23 09:08 kia

WoW!! 😮 Yes, you are right. This change was made to avoid a warning message, since new versions of maven-jar-plugin set finalName option as deprecated. If you are sure this fixes the problem, I'm going to revert this change and released a patch as 1.7.4

fvarrui avatar Aug 18 '23 10:08 fvarrui

Hi @fvarrui, I see the change in maven-jar-plugin. Here is explained how to define the finalName in the correct way and if I define the finalName in our pom.xml as ${name}-${version} then every thing works again without adding the deprecated parameter in io.github.fvarrui.javapackager.maven.CreateRunnableJar. If i leave it as ${name} then the problem occur.

I think the real issue is here: File finalJarFile = new File(outputDirectory, name + "-" + version + "-" + classifier + ".jar"); where you create the fineJarFile. May be the finalJarFile should be new File(outputDirectory, finalName + "-" + classifier + ".jar");

Best, Kia

kia avatar Aug 18 '23 12:08 kia

Are you setting finalName in your POM? I mean ... maybe this was causing this issue by modifying maven-jar-plugin behaviour, since CreateRunnableJar expects a different JAR filename.

fvarrui avatar Aug 21 '23 15:08 fvarrui

May be the finalJarFile should be new File(outputDirectory, finalName + "-" + classifier + ".jar");

Good point! I'll do some research about this

fvarrui avatar Aug 21 '23 16:08 fvarrui

Are you setting finalName in your POM? I mean ... maybe this was causing this issue by modifying maven-jar-plugin behaviour, since CreateRunnableJar expects a different JAR filename.

yes. exactly. As soon as i set the finalName as ${name}-${version} everything is fine. But I would like to set the finalName as ${name}. Then there is the mismatch and the issue occur.

kia avatar Aug 21 '23 16:08 kia

yes. exactly. As soon as i set the finalName as ${name}-${version} everything is fine. But I would like to set the finalName as ${name}. Then there is the mismatch and the issue occur.

Ok, I guessed so ... I'm working right now on this issue. I just found how to get finalName programatically, so we can determine the right name of the generated runnable JAR file

fvarrui avatar Aug 21 '23 16:08 fvarrui

Just patched in branch issue-355.

Try snapshot version 1.7.4-20230821.162917-2 and give some feedback, please.

fvarrui avatar Aug 21 '23 16:08 fvarrui

Hi @fvarrui . I tested the snapshot 1.7.4-20230821.162917-2 and it works. I even changed the finalName and the JavaPackager can deal with it. Best, Kia

kia avatar Aug 22 '23 08:08 kia

Branch issue-355 merged into devel, ready to be released in v1.7.4

fvarrui avatar Aug 22 '23 15:08 fvarrui

1.7.4 released to Maven Central

fvarrui avatar Aug 30 '23 13:08 fvarrui

Hi @fvarrui .

the issue is unfortunately still there in the case of mvn clean install . I tested the snapshot version with your fix with mvn clean package where it is working also in the case of 1.7.4.

The error message i got now is the following:

Failed to install artifact <artifact-name>:jar:runnable:<version>: <path>/target/deploy/linux/<finalName>-runnable.jar (No such file or directory) where <finalName> = ${name}

Again if i take <finalName>=${name}-${version} there is no error message and the artifact is installed.

kia avatar Aug 31 '23 13:08 kia

Hi @kia! I've just tested it and can't reproduce issue with 1.7.4:

pom.xml:

	<build>
		<finalName>ohlala</finalName>
		<plugins>
			<plugin>
				<groupId>io.github.fvarrui</groupId>
				<artifactId>javapackager</artifactId>
				<version>1.7.4</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>package</goal>
						</goals>
						<configuration>
							<platform>windows</platform>
							<bundleJre>false</bundleJre>
							<copyDependencies>true</copyDependencies>
							<generateInstaller>false</generateInstaller>
							<outputDirectory>target/windows</outputDirectory>
							<additionalResources>
								<additionalResource>src/main/resources/info.txt</additionalResource>
								<additionalResource>HelloWorldMaven.l4j.ini</additionalResource>
							</additionalResources>
							<vmArgs>
								<vmArg>-Dcustom.variable="Hi!"</vmArg>
								<vmArg>-Dother.custom.variable="Bye!"</vmArg>
							</vmArgs>
							<fileAssociations>
								<fileAssociation>
									<description>HelloWorld File</description>
									<extension>hello</extension>
									<mimeType>application/hello</mimeType>
								</fileAssociation>
							</fileAssociations>
							<winConfig>
								<headerType>console</headerType>
								<icoFile>src/main/resources/HelloWorldMaven.ico</icoFile>
							</winConfig>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

mvn clean package output:

[INFO]     Creating runnable JAR...
[INFO] Building jar: C:\Users\fvarrui\GitHub\HelloWorldMaven\target\windows\ohlala-runnable.jar
[INFO]         Renaming file [C:\Users\fvarrui\GitHub\HelloWorldMaven\target\windows\ohlala-runnable.jar] to [HelloWorldMaven-1.0.0-runnable.jar]
[INFO]     Runnable jar created in C:\Users\fvarrui\GitHub\HelloWorldMaven\target\windows\HelloWorldMaven-1.0.0-runnable.jar!

Am I missing anything?

fvarrui avatar Aug 31 '23 13:08 fvarrui

Did you try mvn clean install ? with mvn clean package is everything fine.

kia avatar Aug 31 '23 13:08 kia

Did you try mvn clean install ? with mvn clean package is everything fine.

Oh! 😓 sorry, I didn't read well your message, I see ... JP is renaming the runnable JAR to {name}-{version}-runnable.jar, so it fails when trying to install the original JAR into the local Maven repo

fvarrui avatar Aug 31 '23 14:08 fvarrui

Ok, I've coded a patch, merged it into devel branch, and publish as a snapshot: 1.7.5-20230831.204758-1

Now JP keeps the name of the runnable JAR. I could't test it exhaustively, so, please, test it and give me some feedback. Could you test it on all platforms?

fvarrui avatar Aug 31 '23 20:08 fvarrui

Hi @fvarrui Now it seems that every thin is fine.

I tested both mvn clean package and mvn clean install on linux, mac and windows platforms with the snapshot version 1.7.5-20230831.204758-1.

best, Kia

kia avatar Sep 01 '23 09:09 kia

JP is renaming the runnable JAR to {name}-{version}-runnable.jar, so it fails when trying to install the original JAR into the local Maven repo

Great!!! And sorry, I didn't realize about this behaviour. I'm going to release JP 1.7.5 with this patch ASAP

fvarrui avatar Sep 01 '23 14:09 fvarrui

Thank you very much for your quick responses and fixes.

kia avatar Sep 01 '23 19:09 kia

Hi @fvarrui At which time are you going to release 1.7.5 ?

best, Kia

kia avatar Sep 18 '23 13:09 kia

Sorry, I read your comment but forgot it. I'm going to release 1.7.5 this evening

fvarrui avatar Sep 25 '23 12:09 fvarrui

Thank you! :+1:

kia avatar Sep 25 '23 13:09 kia

I've just released 1.7.5 to Maven Central. I hope it works fine this time 😅 and sorry for the delay

fvarrui avatar Sep 25 '23 23:09 fvarrui

Thank you @fvarrui I will test it as soon as it is available in maven central and let you know.

kia avatar Sep 26 '23 08:09 kia

Hi @fvarrui the 1.7.5 version works. Thank you and best regards, Kia

kia avatar Sep 28 '23 09:09 kia