maven assembly plugin: control over directories - maven

I'm trying to convert some groovy (gradle) code to maven. Where possible, we're trying to use off-the-shelf plugins rather than custom ones.
We wanted to use the maven assembly plugin to assemble a tar file that we'll use for deployment. The directory structure is important for our deployment tools, and I seem to be fighting against getting maven to get it to do what I want.
The key problem on the bottom code snippet is the fact that the jar ended up in a target directory in the tar file. My question is: can this be avoided? or should I cut my losses and write a simple custom plugin to do this?
(its possible I'm putting 2 and 2 together and getting 5, but it does seem related to this bug here)
Directory structure (After running the build)
.
└── project1
├── config
│   └── foo.config
├── pom.xml
├── src
│   └── main
│   ├── assembly
│   │   └── assembly.xml
│   └── java
│   └── com
│   └── foo
│   └── bar
│   └── App.java
└── target
├── archive-tmp
├── classes
│   └── App.class
├── maven-archiver
│   └── pom.properties
├── my-static-jar-name-bundle.tar
└── my-static-jar-name.jar
Assembly file
<assembly>
<id>bundle</id>
<formats>
<format>tar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}</directory>
<outputDirectory>/spooge</outputDirectory>
<includes>
<include>**/*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/config</directory>
<outputDirectory>appconfig</outputDirectory>
<includes>
<include>**/*.config</include>
</includes>
</fileSet>
</fileSets>
</assembly>
contents of the tar file when the build has finished (note the jar is in a 'target' subfolder)
tar xvf project1/target/my-static-jar-name-bundle.tar
x spooge/target/my-static-jar-name.jar
x appconfig/foo.config

Try changing the fileset as shown:
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/spooge</outputDirectory>
<includes>
<include>**/*.jar</include>
</includes>
</fileSet>
The way it's currently configured, the assembly plugin is searching project1s entire directory for any jar files. The only one it finds is in the target directory, so Maven happily includes it in the tar. The change I suggest uses project1/target as the starting point, so I think you'll get the result you want.

Related

Sphinx documentation: custom images dir and _static directory for HTML docs

I am a relative beginner developing a Python package. At the root of the repository there are two important directories: images and docs. The former contains some png and svg files I would like to put inside a documentation, the latter is where I run sphinx-quickstart in. I cannot change that layout therefore I have to let Sphinx know to use the top-level images directory while building the docs.
According to what I found over the internet I adjusted the conf.py file to have:
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static', '../images']
And in the index.rst I have to point to the image file itself:
.. image:: ../images/scheme.svg
:width: 500
:alt: schematic
:align: center
Having these two set up I run make html and I do get clean logs but the output directory is a little strange... Once the build is finished i have a docs/_build/html directory which contains _static and _images sub-directories (among many others). What I find strange is that inside docs/_build/html/_static I see all the contents of the root-level images being copied over whereas (at the same time) inside docs/_build/html/_images I only have scheme.svg. So essentially this one file is duplicated into these two subdirectories...
This does not look very clean to me... how should I adjust this setup?
Reply to the comment of bad_coder:
Below I will paste a tree with the dir structure (kept only the relevant elements):
.
├── docs
│   ├── Makefile
│   ├── _build
│   │   └── html
│   │   ├── _images
│   │   │   └── scheme.svg
│   │   ├── _static
│   │   │   ├── scheme.svg
│   ├── conf.py
│   ├── index.html
│   ├── index.rst
├── images
│   ├── scheme.svg

Maven Sonar Scanner Exclude a directory

I am trying to exclude a directory of generated source code files from being analyzed by the Maven Sonar Scanner plugin.
My folder structure looks like this:
├── processors
│   └── src
│   └── main
│   └── java
│   └── org
│   └── protobuf
└── schemas
└── src
└── main
└── java
└── org
└── generated
└── models
└── ModelA.java
└── ModelB.java
I'm trying to exclude everything under schemas.
When I run the command I do the following:
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar
-Dsonar.projectKey=myProjectKey
-Dsonar.projectName=myProjectName
-Dsonar.login=myLoginKey
-Dsonar.password=myPassword
-Dsonar.language=java
-Dsonar.sources=.
-Dsonar.exclusions=schemas/**/*
-Dsonar.junit.reportPaths=target/surefire-reports
-Dsonar.jacoco.reportPaths=target/jacoco-ut.exec
The output says:
[INFO] Excluded sources:
[INFO] schemas/**/*
...
[INFO] 2 files indexed
[INFO] 0 files ignored because of inclusion/exclusion patterns
I'd like to exclude that entire directory, and all of it's contents. How do I get sonar scanner to do this?

copy resources with output path containing part of input path

Say two modules mod1 and mod2 have the following structure:
root
├── mod1/src/main/resources/db-migrations
| ├── v1
| | ├── a.sql
| | └── b.sql
| └── v2
| ├── c.sql
| └── d.sql
|
└── mod2/src/main/resources/db-migrations
├── v1
| ├── e.sql
| └── f.sql
└── v2
├── g.sql
└── h.sql
I want to copy all files from db-migrations into a single top-level directory, but grouped by version first, and by module second. So the output should look like this:
root/all-db-migrations
├── v1
| ├── mod1
| | ├── a.sql
| | └── b.sql
| └── mod2
| ├── e.sql
| └── f.sql
└── v2
├── mod1
| ├── c.sql
| └── d.sql
└── mod2
├── g.sql
└── h.sql
If the directory structure wasn't inversed (module name before version), this is easy with the maven resource plugin by just copying the entire db-migrations directory for each module:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-database-migrations</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../all-db-migrations/${project.artifactId}
</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/db-migrations</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
However, I could not find a solution to do such a copy operation as described above.

Yocto: how to add out-of-tree Device driver?

First of all I should say I am a complete newbie to the Yocto world.
I have a working environment that produces my uboot+kernel+rootfs.
I need to add a (complex) driver I have as a subdirectory.
This driver can be compiled natively in the standard way:
here=$(pwd)
make -C /lib/modules/$(uname -r)/build M=$here/bcmdhd modules CONFIG_BCMDHD_PCIE=y CONFIG_BCMDHD=m CONFIG_BCM4359=y
I have seen Integrate out-of-tree driver in kernel and rebuild yocto project image and I have read Yocto Kernel Development Manual.
I tried to follow directions:
Created a directory in .../recipes-kernel beside linux dir.
Copied the source directory in it.
Created a .bb file.
The resulting source tree is:
recipes-kernel/
├── kernel-modules
│   ├── kernel-module-bcmdhd
│   │   └── bcmdhd
│   │   ├── include
│   │   │   ├── include files
│   │   ├── Kconfig
│   │   ├── Makefile
│   │   └── other source files
│   └── kernel-module-bcmdhd_0.1.bb
└── linux
├── linux-imx-4.1.15
│   └── imx
│   └── defconfig
└── linux-imx_4.1.15.bbappend
My BCM89359-mod_0.1.bb contains:
SUMMARY = "Integration of Cypress BCMDHD external Linux kernel module"
LICENSE = "Proprietary"
inherit module
SRC_URI = "file://bcmdhd"
S = "${WORKDIR}"
Unfortunately this doesn't seem to be enough as running bitbake results in no compilation attempted.
I am quite plainly missing something, but I'm unable to understand what.
Any help welcome.
You should have the following source tree:
recipes-kernel/
├── kernel-modules
│   ├── kernel-module-bcm89359_0.1.bb
│ └── kernel-module-bcm89359
│ └ bcmdhd
│ ├ Kconfig
└── linux
├── ...
(For the record)
You can add your module to MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-bcm89359" to local.conf or machine configuration. Also, you can add KERNEL_MODULE_AUTOLOAD = "bcm89359" to load your module automatically.

Java commands runs on bash, fails on zsh

Consider the following command which runs flawlessly using bash:
java -classpath bin:lib/* FunctionalTests.TestRunner
The classes are in bin, jars are in lib, main() is in bin/FunctionalTests/TestRunner:
.
├── bin
├── lib
│   ├── commons-collections-3.2.1.jar
│   ├── commons-httpclient-3.1.jar
│   ├── commons-io-2.1.jar
│   ├── commons-lang-2.4.jar
│   ├── commons-logging-1.1.1.jar
│   └── ...
└── src
When the same command runs with zsh, the output is:
zsh: no matches found: ./bin:./lib/*
Any ideas?
It boils down to another pair of quotes:
java -classpath "bin:lib/*" FunctionalTests.TestRunner
Hope it helps someone in the future.
Try to use something like this to add every .jar in the classpath:
CP=bin
for i in lib/*.jar
do
CP=$CP:${i}
done
java -classpath $CP FunctionalTests.TestRunner

Resources