CMake package (Cpack) - automatically adding dependencies - deployment

I am using the install command in cmake to install a target, and while the target it is indeed copied, none of its dependencies are (I am talking about the build-time dependencies, like projects added with ExternalProject_Add). How do I automatically include these as well?

CMake does not count "dependencies" when do install. Dependencies are considered only at build time (w/ target_link_libraries). So, to include dependencies (whatever they are) into a package/distribution you ought to add install calls (some way or another) for them as well. And there is no way to do it "automatically" %)

Related

Is there a way to build Scala 2.10.3 from source code?

I know it's a very old thing now, but I need it.
I download scala-sources from the link, unpacking on Ubuntu 20.04. Also I download Ant 1.7.0 and install it. Also I download Apache maven 2.2.1 (or I tried maven 3.5.0) and install it.I also use jdk1.8.0.
I am trying to run "ant" or "ant build" from the scala directory, and something happens, but the build failed for the following reasons:
failed to create task or type scalacfork
Build failed
The following messages also appear at the top:
[taskdef] java.util.zip.ZipException: zip file is empty
(several times)
...
[WARNING] POM for 'biz.aQute:bndlib:pom:1.43.0:compile' is invalid.
...
[taskdef] Could not load definitions from resource scala/tools/ant/sabbus/antlib.xml. It could not be found.
I understand that many things are no longer available now and are definitely not supported, but maybe someone will tell me a way to get the result.
Maybe I can download the necessary data and manually build scala? I'm new to this and don't quite understand what and where I can change. And I can't use a newer version of scala because of work.
I hope for any help. Thank you in advance.
Yes, it is possible. Although it requires some patches in the build process and a few workarounds.
Read the README.rst, it contains some information on how builds are structured
Run git init, git add ., git commit as the build uses some git info (commit hash, etc) during build. It may be not needed for release, but I have not tried.
You need either JDK 1.6 or JDK 1.7. It can't be built on the 1.8 JDK (compilation fails if you remove checks from build.xml). And on 1.7 it says it can't build swing library so you won't be able to build distribution.
Fix the tools/binary-repo-lib.sh and change URLs to https otherwise fetching artifacts will fail. Maybe you have to remove some of the curl arguments to see what happens, maybe it won't be required.
Run pull-binary-libs.sh
Fix build.xml to use https protocol. This is based on the Official usage documentation. You have to define repository before the first artifact:dependencies task in the file (I did that in the same block).
<artifact:remoteRepository id="central" url="https://repo1.maven.org/maven2" />
Then you have to tell every artifact:dependency task to use that repo by adding the remoteRepository element, the tasks should look like
<artifact:dependencies pathId="extra.tasks.classpath" filesetId="extra.tasks.fileset">
<dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/>
<remoteRepository refid="central"/>
</artifact:dependencies>
I think this was enough for me to build it using ant build on JDK 1.7 (apparently, swing libs were not built).
But probably the easier way would be to just download prebuild Scala version or tell your build tool to use the Scala version you want.

importing an autotools project in eclipse doesn't find all includes, breaks autocomplete

I have an autotools project that references an external directory containing build output of a different project (headers, libs, etc...). configuring and building via command line works fine. After importing via eclipse as an existing autotools project, none of the headers/references in that second project are found by eclipse.
Eclipse also fails to find a few libraries/headers that are in non-standard system locations like /opt, etc... Thus, autocomplete, ctrl+click, etc... doesn't work on a lot of things.
Both the second project and the non-standard libraries are correctly referenced when building/compiling and are found properly by configure
I'm able to manually add the necessary paths in the C/C++ build settings to get all of the includes resolved, but I was under the impression that importing an autotools project should automatically find these references. Am I incorrect in that assumption?
An additional note, our configure script requires the use of --prefix to know where to find the second project. when importing the project the first time, it of course tries to autoconf everything without --prefix set and subsequently fails. I then go back in and modify eclipse to use the appropriate prefix OR manually re-run autogen and configure with --prefix=/some/path. Then re-index the project. so everything should be setup fine at this point.
The actual question seems to be this:
I'm able to manually add the necessary paths in the C/C++ build
settings to get all of the includes resolved, but I was under the
impression that importing an autotools project should automatically
find these references. Am I incorrect in that assumption?
Your own experience tells you otherwise, notwithstanding your prior expectation.
In an Eclipse Autotools project, an Autotools build system is used to (configure and) build the project instead of any of Eclipse's built-in builders. To the extent that there is a data flow between components, it is from Eclipse to the project, not the other way around. The distributed Autotools artifacts (Makefile.am, configure.ac, etc.) are opaque to Eclipse, except inasmuch as it has content highlighting for those file types (IIRC). Artifacts built by configuring the project are not only opaque, but also ignored by policy.

The best practice to use Tycho/Maven to remove jars dependencies in Eclipse RCP?

I'm working one an Eclipse RCP project. Currently we create a dependencies plug-in project and put all jars libraries into that project and export all packages. This method will give a huge repo, thus we want to use Tycho/Maven and let it figure out the dependencies for us.
The first approach is removing dependenciec project and use p2-maven-pluging to transform existing jars libraries to p2 format repo. Install all libraries from p2 repos and add required bundle in Require-Bundle section in each MANIFEST.MF. This is a little bit tedious since in every project having dependencies in Require-Bundle, I have to manually replace it to corresponding bundle names. And in the end, the project build using Tycho could successfully run, but in Eclipse it gives me java.lan.NoClassDefFoundError: Could not initialize class X.
I think there are few configuration files, where Tycho depends on some of them and Eclipse depends on the rest, but I'm not sure what it is.
The second approach is removing all jars in dependencies project but adding them in Require-Bundle or Import-Package. However, both won't work since in Export-Package section Eclipse will complain these packages are not existed. Thus other projects depends on this dependencies project won't find those packages they need, which causing more errors in Eclipse.
Does anyone know the best practice to deal with this issue?
Update:
I'm using basically the first approach, but add dependencies in Import-Package in each project instead of Require-Bundle. This would eliminate the need to specify the specific bundle version, as long as they provide the same API and they are compatible, your application would work. So everytimes I update private p2 repository, I don't need to change MANIFEST.MF in each project.
The only MANIFEST.MF I need to manually add dependencies in Require-Bundle is a library developed by our self. Without it, Tycho won't fetch required dependencies from private p2 repository. If still get NoClassDefFoundError, try adding all plugins in Run -> Run Configuration .. -> plug-ins, it may help.
I definitely not apply your approach 1, with the mega-plugin of exports. There's a related discussion here: Handling non-OSGi dependencies when integrating Maven, Tycho and Eclipse
As a rule, use Import-Package instead of Require-Bundle.
To get bundles will appear in the Export-Package section Eclipse:
if they are non-Eclipse (maven libraries), then build the project and reference the libraries in the Eclipse runtime section.
if they are Eclipse dependences, they should be in your workspace or Target Platform.
More generally, it may help for you to define a Target Platform. You can build/deploy all of your locally created plugins into a local p2 repository (see http://www.sonatype.org/nexus/). Then add that p2 site to your Target Platform.

Installing Java libraries

As I'm quite new to Java, I would like to know the proper procedure of installing new libraries (those that are no available in my linux dist repositories).
Where should I place them? and how to install them?
For instance, I downloaded openCsv (http://opencsv.sourceforge.net/), and I have no idea how to install it.
Java libraries don't really need to be 'installed' like other applications. All you need to do is put the jar file in a specific location, and add the jar file to your classpath. How you do that depends on the linux distro you are using. If you are making a web application in eclipse, you can drop the .jar file in the WebRoot/web-inf/lib folder, and it will be bundled in with your project.
Be sure that the path, which you place the libaries at, is set in the $CLASSPATH Environment Variable.
For Eclipse: Project -> Properties -> Java Build Path -> Add JARs...
It's up to you really - I use /opt/javalib, but you might consider a directory in /usr/local as well.
You can store them wherever you wish. You can store them within the JRE distribution directories, but I wouldn't recommend that.
Instead I would store them per-project (so you can have different versions for each project easily - some libraries have different names for each version, some don't) and adopt a standard such as a lib/ directory. That way you can have standard build scripts (Ant etc.) that can operate in the same way (if you're using Maven, then there's a standard place per-project - src/main/resources)
You could use Maven to manage any dependencies to those libraries.
Maven will automatically download all needed JAR files and put them in a local repository (the location is configurable).
This makes upgrading to new versions of various libraries very easy as you just declare the version you want and Maven does the rest.
Beware: Maven is something to get used to and the initial learning curve is steep.
The rewards come if you have everything set up properly and maven takes care of compiling, packaging, distribution, site creation, release management etc. etc. etc.

What's the best way to manage dependencies with CounterClockwise/Eclipse?

I have a dependency on clj-record in my CounterClockwise project. What's the best way to manage this? Copy the source code or compile to a JAR and add it as a referenced library?
There are tools to help you:
http://github.com/technomancy/leiningen <- project based
http://github.com/liebke/cljr <- dependencies not project based
http://github.com/ninjudd/cake <- alternative build tool
Assuming your dependencies are available in a Maven repo (like central or clojars), you have a couple of options.
First, if you're using Leiningen, there is an eclipse plugin for it now that will manage project dependencies for you, based on the dependencies you define in your project.clj file. The plugin is in beta now, but has been working great for me so far. (Note that it uses Leiningen 2.0 under the covers, though that detail won't matter for many (most?) simple cases.)
If you're using Maven, the m2eclipse plugin makes it so that the dependencies you declare in your Maven pom.xml are automatically added to your eclipse project's build path, and are therefore available in CCW REPLs and such.
there seems to be no pattern for specifying dependencies apart from hacking the code into your project or building a jar externally.
Of course you can, just as with any java project. While dependency resolution isn't tied into eclipse (yet), once you retrieve the deps (via one of the command line tools nickik listed), you can specify which jars are to be included in the java build path of your eclipse project:
Retrieve the deps via cake, leiningen, etc.
Refresh the eclipse project so you see the deps (usually in the lib directory)
Highlight the jars you want eclipse to know about
Right-click, select Build Path > Add to Build Path
That's it. You can fiddle with the build path by going to the Java Build Path section of the project's properties window.