I have a apache_mod.c which is supposed to be updated for continuous integration
I would like to use Maven to compile this module for generating apache_mod.so
Then packaging it in .jar
I can't find how to compile the apache_mod.c with Maven to get apache_mod.so because it seems that an Apache2 module needs to be compiled with apxs2 command which already put the *.so file in /usr/lib/apache2/modules.
So, do you have any idea how to compile apache_mod.c with Maven in order to get apache_mod.so to package it?
I don't think that putting *.so (shared object) into jar archive is correct solution, but to answer your question how to compile native c or c++ files using maven, you can use the native plugin http://mojo.codehaus.org/maven-native/native-maven-plugin/. Also, the apxs2 is just wrapper around gcc, so you don't have to use apxs2 to build apache module. You can just use gcc.
Seems I tried to do two things in one.
Generating *.so and packaging it are two different things.
So here is the process :
Having a Maven project compiling and generating *.so
Having a Maven Assembly to package *.so and others files and *.war
Seems Boris has been definitly right. Using Maven native plugin allow to compile *.c in *.so then Maven assembly plugin is used to package it.
Thanks for all.
Related
I am distributing a Java package via git for other people to use. I am currently supplying a jar file to go with the source. This way, the user only needs to clone the project once into Intellij IDEA. Projects using the package can then follow this procedure
Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project
to use the package.
This works, but distributing a jar does not feel nice security-wise. On the other hand, this discussion
IntelliJ IDEA - adding .java file to project dependencies
suggests that to use the source code, you need to copy it into your src folder.
Is there a way to distribute source code (java files) only so that if multiple projects use the same package
the package only needs to be downloaded once
the package can be kept up to date with git pull?
I would really recommend not include jar or any binaries in a Git repo and the best approach to keep these dependencies in a local Nexus repository and use maven or Gradle as your dependency management tool.
I found a working solution:
Supply an Ant build file with the package. The build file compiles classes and packages them into a jar file. The default target is building the jar, which depends on compiling the classes.
Provide users with instructions on how to set the given Ant build file as a build file in Intellij IDEA and build the default target.
Then instruct them to follow the steps in the first link above to add the jar as a dependency.
I have an android project where we just upgraded to gradle wrapper 4.9-all and using gradle tools plugin com.android.tools.build:gradle:3.3.0-alpha04. I have different build variants. The build types using proguard and minifyEnabled=true are failing because they can't find the /libs folder:
Caused by: com.android.tools.r8.utils.AbortException: Error: /Users/username/projects/projectA/path-to-project/libs, java.io.FileNotFoundException:/Users/username/projects/projectA/path-to-project/libs (Is a directory)
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:116)
at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:74)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:119)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)
at com.android.tools.r8.R8.run(R8.java:251)
at com.android.tools.r8.R8.run(R8.java:229)
at com.android.tools.r8.R8.lambda$run$0(R8.java:134)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:55)
If i set minifyEnabled=false, then the build completes successfully.
I have googled and haven't found anything specific to this issue. Is anyone else running into this?
[SOLVED] It was a proguard issue. In my proguard-rules.pro file, there was a setting of
-injars libs
The intent was to apply to all jars in the libs folder.
Well...somewhere between upgrading to gradle-wrapper 4.9
the behavior with proguard changed. Now I have to explicitly specify the
jar files.
-injars libs/a.jar
-injars libs/b.jar
-injars libs/c.jar
etc...
I'm developping application with JOGL2 and my favorite IDE Eclipse, also I want to use Maven2 for this purpose. Unfortunately, JOGL2 has no artifact yet. Also, I plan to deploy it as a runnable jar file.
So I want to install JOGL artifact locally : so i'll use the install:install-file command.
But I want to group several jars to make several artifacts, that is :
gluegen-rt.jar and jogl.all.jar as a single artifact named jogl.core
gluegen-rt-natives-linux-i586.jar and jogl.all-natives-linux-i586.jar as a single jar named jogl-natives-linux-i586
and so on
Is it possible ? (The official documentation does not mention the possibility or unpossibility to do so).
Thanks in advance
Install all files as usual like file:jar:version. Than create pom with pom packaging and use gluegen-rt.jar and jogl.all.jar as dependencies in it (they must be already installed). After that use new pom as dependency in your project.
maven doesn't have support for that. You would have to unpack these JAR files and repackage them together.
maven does have support for merging JAR with dependencies (http://stackoverflow.com/questions/574594) - and it's done the way I mentioned above. But you are asking about merging two arbitrary JARs, which is not possible in maven.
I have a RCP project where I cannot fix a NoClassDefFoundError: One plugin depends on another plugin. The plugin-dependencies are set in the manifest, packages exported, and there is no error at compile time. Both plugins are in the product dependencies and visible in the installation details of the product.
But when I run the application I get a java.lang.NoClassDefFoundError when the one plugin wants to use a class from the other plugin.
Any hints how to find the reason for this are greatly appreciated.
Thanks,
Michael
I found the problem: I created the plugin which could not be loaded from an existing Java project. And somehow I deleted the "." in the entry Bundle-classpath in the plugin manifest (the plugin has some jars which -> so lib/xyz.jar was in the Bundle-classpath entry but not the ".").
For the class-loader of the bundle the "." means to search for classes from the root path of the bundle (or something like that), so it could not find the classes. However, there were no errors in the IDE so it was hard to find.
Is the configuration for running the application correct i.e. all dependencies are also put in the running configuration?
Summary: I'm looking for a way to instruct maven to search for dependencies in target/classes instead of jar in the local repository
Say I have 2 modules, A and B where A depends on B. Both are listed in a module S. Normally I need to run 'mvn install' in S. I'm looking for a way to run 'mvn compile' so that when A is compiled its classpath will contain ../B/target/classes instead of ~/.m2/repository/com/company/b/1.0/b-1.0.jar.
(my reason is so that i can have continous compilation without the need to go through packaing and installation, or, more exactly, use 'mvn scala:cc' on multiple modules)
I don't think that this is possible without horrible hacking, this is just not how maven works. Maven uses binary dependencies and needs a local repository to resolve them. So, the maven way to handle this is to launch a reactor build on all modules. Just in case, have a look at Maven Tips and Tricks: Advanced Reactor Options.
But, during development, can't you just import all your projects in your IDE and use "project references" (i.e. configure your projects to depend on source code instead of a JAR) like most Java developers are doing? This is the common approach to avoid having to install an artifact to "see" the modifications.
If this is not possible and if you really don't want to install artifacts into your local repository, then you'll have to move your code into a unique module.
i know this is annoying. which helped me here is definitely IDE support. eclipse and IntelliJ are clever to collect all dependencies once a maven-project import is done. even cross module dependencies are compiled live.