Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

gradle - FileNotFoundException in exec

This command here is working as I run it in the command line from /home/username/workspaces/meditation-new:

jar -uf server/build/libs/server-*.jar mobile-client/build/BOOT-INF

But running it with gradle:

doFirst {
    exec {
        executable = 'jar'
        args = [
                'uf',
                "server/build/libs/server-*.jar",
                "mobile-client/build/BOOT-INF"
        ]
    }
}

Fails because of

java.io.FileNotFoundException: server/build/libs/server-*.jar (No such file or directory)

Running gradle with the -i switch on shows me however, that the command is correctly exectued:

Starting process 'command 'jar''. Working directory: /home/username/workspaces/meditation-new Command: jar uf server/build/libs/server-*.jar mobile-client/build/BOOT-INF
Successfully started process 'command 'jar''
java.io.FileNotFoundException: server/build/libs/server-*.jar (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at jdk.jartool/sun.tools.jar.Main.run(Main.java:360)
        at jdk.jartool/sun.tools.jar.Main.main(Main.java:1681)
:copyWebApp (Thread[Execution worker for ':',5,main]) completed. Took 0.079 secs.

What is the issue here?

question from:https://stackoverflow.com/questions/65651365/filenotfoundexception-in-exec

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Unix like systems the wildcard * is expanded by the shell, not by the program to run. Either expand the wildcard yourself, or execute the command via the shell.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...