We're using the maven license plugin (third-party-aggregate goal) to produce a list of third party project dependencies - this is good and we've got it working. I would like to extend that to include the licenses for our resources (i.e. not just code/dependencies), but don't know where to start - could anyone provide an example of what I need to do to make this work?
An example of what we've got: In a maven modules resources folder we hold a copy of the UK Postcode dataset (as a json file) so that we can use it offline. The file is licensed under Ordnance Survey OpenData license so we've put a LICENSE.txt file in the same directory that states this.
The result I want: "Ordnance Survey OpenData license" to appear in my THIRD-PARTY.txt file.
Some questions to help answer:
Can I specify the resource licenses directly in a pom.xml so that I don't have to keep the LICENSE.txt file we've created?
Can license-maven-plugin read LICENSE.txt files like the one we're using at the moment?
If 2=yes, do I need to specify the format of the text so that license-maven-plugin picks up the license?
Do I need to add tags with the license so that license-maven-plugin picks up these licenses?
Thanks for any help.
I'm using the Maven License plugin (with the add-third-party goal) to produce the THIRD-PARTY.txt report for all my Maven modules. I'm not sure this plugin can scan the ressource licenses.
One solution should be to package your json file into a small Maven project. It will produce an artefact and will store it into your binary repository (Artifactory, Nexus, ...).
Next, add a new dependency in your Maven project and the UK Postcode dataset will appear in your THIRD-PARTY.txt report.
Related
I'm new to working with Java and have questions regarding the Maven Central Repository. I am much more familiar with Python and PyPI, so I will provide the equivalent in PyPI that I would like to find in Maven.
How can I find the source code for the artifacts in Maven Central? Typically, I see the JAR file and prefer not to decompile these files. Typically, PyPI packages have the source file type in the "Download files" tab.
How can I find the associated project URL to a maven artifact? In PyPI, the package page has a set of project links and generally provides a repository link (e.g., Github, Bitbucket)
How can I identify open-source projects in the Maven central repository? The license for PyPI projects is tagged directly in the meta-reference on the sidebar of a project page.
I appreciate any insight into these questions. Thanks!
When a distributor decides to provide them, you can find -sources.jar and a -javadoc.jar files in the artifacts folder. (common IDE's are aware of that&provide buttons/menus, "Maven>Download XXX";)
like e.g. here
Artifact javadoc (for the sophisticated ones, javadoc and sources refers to the (common) "classifier" of the artifact)
how (easy) to produce them
In the pom:
project.url tag provides:
The project's home page.
project.scm element provides (should provide!) "source control" related (multiple) urls (read-only, contributer, public-browsing).
besides that many other things(and sub-things) can have url in a maven project/pom (distributionManagement(i.e repository), organisation, developer,...).
project.licenses element!
You can be sure to find all of these three (- four) in all (at least latest) artifacts in maven central, due to:
Their Publishing Requirements!;
I am a beginner with gradle and i need help please.
If i want my own libs and extern libs (vendor) where shoud i put these libs (extern and personnal)?
thank you for helping !
(example: a screenshot of my current dir structure)
Gradle gives you a few different options for this.
In all cases, there is no fixed folder structure for local file dependencies, and you are free to chose what you like. libs seems fine to me.
All examples below are in Groovy DSL. Refer to the Gradle user guide for the Kotlin DSL variants.
File dependencies
To add dependencies from a local folder, you can use the Project.file() or Project.fileTree() methods. Both take a path that is resolved relative to the project directory.
dependencies {
implementation files('libs/a.jar') // Single file
implementation files('libs/b.jar', 'libs/c.jar') // Multiple files
implementation fileTree('libs') // All files in a folder
implementation fileTree('libs') { include '*.jar' } // All jar files in a folder
}
See File dependencies in the user guide for more information.
Flat directory repository
You can also declare a flat directory repository. Here the path is relative to where you invoke Gradle from, so to make it consistent, you should make it absolute (using projectDir or rootDir).
repositories {
flatDir name: 'local-libs', dirs: "$projectDir/libs" // The name is optional
}
You can then declare dependencies using the normal format with a group, name and version. However, as group is ignored so you can either write whatever you like, or just leave it out:
dependencies {
implementation 'mysql:mysql-connector-java:5.1.49' // Real Maven coordinates
implementation ':mysql-connector-java:5.1.49' // Short-hand for local coordinates
}
See this section for more information.
Maven repositories and separate Gradle projects
Because the above two methods do not include module metadata, meaning you have to define and include all transitive dependencies manually, it can quickly get hairy to maintain.
If possible, try and use Maven repositories. Especially for third-party dependencies. You can even define a local repository to take advantage of metadata files (e.g. .pom files or .module) if you can't use remote ones like Maven Central or JCenter.
When depending on other Gradle projects, if they are related, you could possibly structure them as a multi-projects instead of building and putting them into a "libs" folder.
If they are not related, you could also publish them to a Maven repository (either local or remote), or you could look into composite builds, though this is a bit of an advanced topic.
A note on the MySQL Connector software license
Lastly, in case you are not aware, the community edition of MySQL Connector/J version 5.x is licensed under GPL v2. It means your own application also needs to be licensed under GPL v2.
Later versions like 8.x (I am unsure about 6 and 7) are licensed dually under GPL v2, but has a provision called The Universal FOSS Exception that allows you to link and use the library in your own application without affecting your own license.
If this is just a hobby project, no one will come knowing on your door if you breach the license. But if it is for a company, be careful or you might bring it into legal trouble. Oracle does audits from time to time and they are not known to let an opportunity slide for slapping you in the face with a big license fee.
I am using alfresco 4.1.3 having following project structure.
I am using the ant script to build project.
Now I want to convert this project into maven based alfresco5.
I have configured alfresco5 using all-in-one archetype and I am able to run it successfully. My questions are:
How can I convert my alfresco ant based project in alfresco5 maven based?
Do I need to add src files in repo or repo-amp?
Do I need to copy all share related files in share or share-amp?
Any help would be greatly appreciated!!!
Thanks in Advance.!!
That totally depends on the ant build setup. But one good guess is that you will have to put the files residing in the "Alfresco" folder of your old project into different subfolders of the repo-amp, and the same way around with the "Share" folder. Most files will go into those folders, you have to study the SDK-docs carefully to know into which folders the files will go. Depending of the nature of your extensions some files could go into the Share and Alfresco war-structure as well (additions to web.xml for example).
There are no "Swiss army knife" for that works for all cases here.
Good luck
Do the following things:
Create new project as maven project and provide group id (it's yours) artifact id as alfresco5 and version (ex:43.0.1-SNAPSHOT)
With this it creates maven based folder structure
src/main/java -> replace it with your src folder
3.src/main/resources ->add your Share, reference and Alfresco folders.
look at you lib directory..what ever .jar will be there you need to define it in dependencies under pom.xml
compile the whole project..if there are compilation errors then add required dependencies in pom.xml
I have a maven project and respective pom.xml files. it is just a ear file, which is getting generated with my proejct name. but i want it dyanmic with projectname_datetime.ear file using pom.xml. Can you please give me a static example which will create a ear file with current dateand time of build number with major_minor or something link that.
Thanks in Advance.
Nilesh
See this answer: https://stackoverflow.com/a/2077869/116509. You'll also need to add
<build>
<finalName>${project.artifactId}-${project.version}-${maven.build.timestamp}
</finalName>
However you should use probably be using -SNAPSHOT version numbers during development. If you want to be able to a refer to a definitive version, you can release that version. It's also possible to refer to a specific snapshot, see http://mojo.codehaus.org/versions-maven-plugin/examples/lock-snapshots.html.
If you are using svn for your source code management, Codehaus' buildnumber-maven-plugin may be used to put the svn revision number into the manifest of any artifact you build, including snapshots. The plugin has a goal to format timestamps too, if you need it.
My need is pretty basic but I could not find any clean answer to it: I simply need to be able to distribute a resource in a multi-module project.
Let us consider for example the LICENSE file, which I hereby assume to be the same for all modules. I prefer not to manually copy it into each and every module because the file could change over time. I also prefer not to statically link to resources (even if using relative paths) outside the project folder, because the modular structure can possibly change too.
Is there any plugin that can be used to robustly guarantee that each module is given the required file? It would be equally acceptable for such copy to be obtained by exploiting the POM of the parent project or directly performed by the super project in the modular hierarchy.
you could use the assembly and the dependency plugins.. did you stumble over that link?
http://www.sonatype.com/people/2008/04/how-to-share-resources-across-projects-in-maven/
it describes that option ..its from 2008, but maven is around for quite some time.. so I guess its more or less up to date
edit regarding comment
Another option is the maven-remote-resources-plugin.
For a more detailed example see:
http://maven.apache.org/plugins/maven-remote-resources-plugin/examples/sharing-resources.html
Since their intro speaks actually for itself, I quote (maven.apache.org)
This plugin is used to retrieve JARs of resources from remote repositories, process those resources, and incorporate them into JARs you build with Maven. A very common use-case is the need to package certain resources in a consistent way across your organization: at Apache it is required that every JAR produced contains a copy of the Apache license and a notice file that references all used software in a given project.