question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating temporary library JAR directory fails if it already exists

See original GitHub issue

Hi,

I’m using the plugin with the

<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>

option because of a large classpath. When running mvn proguard:proguard and when not having run mvn clean beforehand the temporary library directory (‘tempLibraryjars’) may already exist. If that’s the case then the following call to mkdir() will return false and the proguard plugin will throw an exception:

https://github.com/wvengen/proguard-maven-plugin/blob/master/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java#L580

Can you please ignore the return value of mkdir() and instead check for the existence of the directory after the call to mkdir(), followed by cleaning it?

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FibreFoXcommented, Jun 7, 2016

https://github.com/FibreFoX/proguard-maven-plugin/commit/9df7725b1141475bc21e32291d9ced8e42b3c76a

Will make another commit for deleting the contents first 😃 there should be some PR tomorrow

1reaction
snooper77commented, Jun 7, 2016

Thanks, but I can’t do it from my work place and I don’t have maven/git set up at home. The change is trivial and looks like this:

Replace lines 580-582 in ProGuardMojo:

            if (!tempLibraryjarsDir.mkdir()) {
                throw new MojoFailureException("Can't create temporary libraryJars directory: " + tempLibraryjarsDir.getAbsolutePath());
            }

by:

            tempLibraryjarsDir.mkdir();
            if (!tempLibraryjarsDir.exists()) {
                throw new MojoFailureException("Can't create temporary libraryJars directory: " + tempLibraryjarsDir.getAbsolutePath());
            }

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a temporary directory/folder in Java?
If you are using JDK 7 use the new Files.createTempDirectory class to create the temporary directory. Path tempDirWithPrefix = Files.
Read more >
How to create directory in Java
In Java, we can use the NIO `Files.createDirectories` to create a directory including all nonexistent parent directories.
Read more >
FIO03-J. Remove temporary files before termination
There is no surefire method that can guarantee the removal of orphaned files in the case of abnormal termination, even in the presence...
Read more >
Files (Java Platform SE 8 )
Creates a new and empty file, failing if the file already exists. ... Creates a new directory in the default temporary-file directory, using...
Read more >
What is a "failed to create a symbolic link: file exists" error?
Fool-proof way to create symbolic links. First go into the directory where you want to create the link cd ~/Documents/saga. Then create the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found