1

I'm trying to repackage log4j so I can use it with Android. In order to do so, I have to use openbeans library and replace each java.beans with com.googlecode.openbeans.

Obviously this is not sufficient, since before repacking the through maven log4j I've to include openbeans-1.0.jar in the project.

So I've found this method.

I've installed openbeans through the following command:

mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true

I've checked that the correct execution of the command checking if the .jar exists in the following path (and it does):

~/.m2/repository/com/googlecode/openbeans/1.0/openbeans-1.0.jar

Then I edited the pom.xml file adding:

<dependency>
  <groupId>com.googlecode</groupId>
  <artifactId>openbeans</artifactId>
  <version>1.0</version>
</dependency>

But if I try mvn package then this error is returned:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run (rmdir_tests_output) on project log4j: Execution rmdir_tests_output of goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its dependencies could not be resolved: Failure to find com.googlecode:openbeans:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

Like the install-file didn't worked.

I've tried also with this method, using the following code (obviously I copied the .jar in the project root dir):

<dependency>
  <groupId>com.googlecode</groupId>
  <artifactId>openbeans</artifactId>
  <version>1.0</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/openbeans-1.0.jar</systemPath>
</dependency>

And here the error returned is:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project log4j: Compilation failure
[ERROR] /home/luca/apache-log4j-1.2.17/src/main/java/org/apache/log4j/config/PropertyGetter.java:[31,21] error: package com.googlecode does not exist

What is wrong in what I'm doing?

Community
  • 1
  • 1
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
  • the install file method should work, use it again and try clearing the project. If a `mvn clean package` from the command line still fails, please post the full output of this command. –  Mar 20 '16 at 17:34
  • Question updated with the 2 errors returned – justHelloWorld Mar 20 '16 at 17:51
  • my guess would be the openbeans jar doesn't contains what you think it does. I would unzip it to check (or use you IDE) and make sure there is a com/googlecode inside it. –  Mar 20 '16 at 18:18
  • No, executing `jar -tf openbeans-1.0.jar` the class `com/googlecode/openbeans/Introspector.class` is just one of the many returned. – justHelloWorld Mar 20 '16 at 18:28
  • You could try to install the dependency through maven-install-plugin, directly in your pom.xml, during the clean phase, and then using 'mvn clean install' command. Take a look here (the third option): https://goo.gl/vuPfNa – bruno.zambiazi Mar 20 '16 at 19:05
  • Still not working. Except for the fact that the third solution is equal to the `install-file` one, with the only exception that it's executed at every `clean` – justHelloWorld Mar 20 '16 at 19:16
  • Look at my answer and try to help why this happened! – justHelloWorld Mar 20 '16 at 19:29

1 Answers1

3

Even if I still don't understand why, I found out that executing:

mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode.openbeans -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true

And using in pom:

<dependency>
  <groupId>com.googlecode.openbeans</groupId>
  <artifactId>openbeans</artifactId>
  <version>1.0</version>
</dependency>

The code is compiled without error. But as I said, still wondering why.

justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
  • Hypothesis: you had some bad jar for com.googlecode / openbeans and when you change the groupId, the destination directory change and it works. You could check what you have in `${home]/.m2/repository/com/googlecode/1.0` –  Mar 20 '16 at 19:31
  • Thanks for your reply. I already thought about this problem, and `rm -rf ~/.m2` should had overkill the problem, but it the error was still there even after it. Wow. – justHelloWorld Mar 20 '16 at 19:44
  • beware if you delete the .m2 and don't install-file again. The fact is the groupId is whatever you want it to be –  Mar 20 '16 at 19:46