1

I adapted some code from the Apache Ant project in my work. The part I used is really small: ~70 lines, ~2000 characters. Adding dependency to ant to use that a single method seemed like an overkill.

The project I work on is internal to the company, so I initially included a javadoc like

    @see <a href="...">original source</a>

for my colleagues to know the code wasn't mine.

Then I encountered this summary at tldrlegal which states that this is not enough, and to do this properly I have to do much more:

  • Include Copyright
  • Include License: Including the full text of license in modified software.
  • State Changes: Stating significant changes made to software.
  • Include Notice: If the library has a "NOTICE" file with attribution notes, you must include that NOTICE when you distribute. You may append to this NOTICE file.

From this I deduce that I actually have to include NOTICE file from ant (it's like 10 lines), somehow redistribute Apache 2 license text with the project, and include a monster comment like this before the function body or before the beginning of my class:

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Is there a more compact but still correct way to do it, or is there no other way? Introducing lots of changes because I only use a minuscule part of the project (namely, a single ~70-line method) will negatively impact code-review quality and maintainability of the final code.

P.S. I don't seek professional law advice, just some common-sense-based guidelines for this situation, preferrably with examples from other open-source projects.

  • So, a bit of common sense. You can't simply steal a muffin and pass it off as “yeah, I took it from the stand over there, I hope no one minds”. Especially since there was a sign next to the muffins saying “blood donor reward muffins”. And you are selling that one small muffin through your catering service. That doesn't seem right, and trying to justifying it by “but it was only one tiny muffin in comparison to my vast buffet” doesn't make it right either. You want something from someone? For free? Play by their rules. – amon Dec 1 '14 at 21:33
  • Clarifying: I asked for a most compact way to do this correctly (=playing by their rules). Not to avoid the rules. – nvamelichev Dec 1 '14 at 21:36
  • And the product being developed is not for sale, or any kind of distribution really; it's only for internal use. – nvamelichev Dec 1 '14 at 21:47
3

The easiest way to get around it is to document what you need the function to do, and then give that specification to your coworker and ask them to re-write it. Seventy lines isn't a ton to rewrite, but if you were to rewrite it right now you'd know how Apache did it and possibly (unintentionally) copy their code or way of doing it. If you think the Apache code is so great that you would rather have their code, you have to play by the full set of rules you already outlined - there's not really a way around it.

  • I considered doing this. But the function deals with command line parsing, which is tricky, and a rewrite can introduce subtle errors. The Apache Ant code was in production use for 10+ years without any problem. So the question is: how to comply with Apache 2.0 license with minimal changes of the code base. – nvamelichev Dec 1 '14 at 22:14
  • If you need command-line parsing, why not use a library such as JCommander? – user22815 Dec 1 '14 at 22:20
  • We already use JCommander to parse command line arguments. Ant's method is used to parse a supplied command line String (e.g. bash -c 'echo "do_it"') into array of command line arguments (e.g. ["bash", "-c", "echo \"do_it\""]). – nvamelichev Dec 1 '14 at 22:23
  • Accepted this answer because it led me to reconsider requirements (don't rewrite; reuse!) and come up with an easier solution (add library as a dependency). – nvamelichev Dec 2 '14 at 17:03
0

I ultimately chose to add Ant (org.apache.ant:ant) as dependency and pack it into uberjar with maven-shade-plugin. This way original code is re-used (which was my goal), and license-maven-plugin can download all project dependencies' licenses automatically. There is a small drawback of increased uberjar size, but it is negligible (~2 Mb for ant 1.9.4).

Some comments on my original approach:

  • As per point 4 of the Apache 2.0 license, a copy of the license must be included. NOTICE file must be added as well, because ant already has it. So there is no "more compact but correct way" that I searched for.
  • Copying the original Commandline class verbatim, or adding Commandline class with appropriate license comment and only the methods I used offers better readability than adding license comment above the copied method's body.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.