Accepting request 671927 from Java:packages

cleanup

OBS-URL: https://build.opensuse.org/request/show/671927
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/apache-commons-cli?expand=0&rev=11
This commit is contained in:
Stephan Kulow 2019-02-06 13:07:34 +00:00 committed by Git OBS Bridge
commit 27ac5bbbcf
4 changed files with 135 additions and 48 deletions

96
CLI-253-workaround.patch Normal file
View File

@ -0,0 +1,96 @@
commit 77218790904f40395304669f5d79740f459c0a90 (HEAD -> cli-253, origin/cli-253)
Author: Michal Srb <msrb@redhat.com>
AuthorDate: Mon Jun 22 15:01:30 2015 +0200
Commit: Michal Srb <msrb@redhat.com>
CommitDate: Mon Jun 22 15:04:05 2015 +0200
[CLI-253] Prevent "Unrecognized option: --null" when handling long opts in PosixParser
diff --git a/src/main/java/org/apache/commons/cli/Options.java b/src/main/java/org/apache/commons/cli/Options.java
index 0ee4eea..1c38194 100644
--- a/src/main/java/org/apache/commons/cli/Options.java
+++ b/src/main/java/org/apache/commons/cli/Options.java
@@ -224,6 +224,20 @@ public class Options implements Serializable
}
/**
+ * Retrieve the {@link Option} matching the long name specified.
+ * The leading hyphens in the name are ignored (up to 2).
+ *
+ * @param opt long name of the {@link Option}
+ * @return the option represented by opt
+ */
+ Option getLongOption(String opt)
+ {
+ opt = Util.stripLeadingHyphens(opt);
+
+ return longOpts.get(opt);
+ }
+
+ /**
* Returns the options with a long name starting with the name specified.
*
* @param opt the partial name of the option
diff --git a/src/main/java/org/apache/commons/cli/PosixParser.java b/src/main/java/org/apache/commons/cli/PosixParser.java
index c13a65e..14d2936 100644
--- a/src/main/java/org/apache/commons/cli/PosixParser.java
+++ b/src/main/java/org/apache/commons/cli/PosixParser.java
@@ -131,7 +131,7 @@ public class PosixParser extends Parser
}
else
{
- currentOption = options.getOption(matchingOpts.get(0));
+ currentOption = options.getLongOption(matchingOpts.get(0));
tokens.add("--" + currentOption.getLongOpt());
if (pos != -1)
diff --git a/src/test/java/org/apache/commons/cli/bug/BugCLI253Test.java b/src/test/java/org/apache/commons/cli/bug/BugCLI253Test.java
new file mode 100644
index 0000000..e37b7bc
--- /dev/null
+++ b/src/test/java/org/apache/commons/cli/bug/BugCLI253Test.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+package org.apache.commons.cli.bug;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.junit.Test;
+
+@SuppressWarnings("deprecation") // tests some deprecated classes
+public class BugCLI253Test {
+
+ @Test
+ public void testGroovyUseCase() throws ParseException {
+ CommandLine cli = new PosixParser().parse(getOptions(), new String[] { "--classpath" });
+ assertTrue(cli.hasOption("--classpath"));
+ }
+
+ private Options getOptions() {
+ Options options = new Options();
+ options.addOption(Option.builder("classpath").build());
+ options.addOption(Option.builder("cp").longOpt("classpath").build());
+ return options;
+ }
+}

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Tue Feb 5 13:30:36 UTC 2019 - Jan Engelhardt <jengelh@inai.de>
- Trim bias from description; update RPM groups.
-------------------------------------------------------------------
Tue Feb 5 12:10:09 UTC 2019 - Fridrich Strba <fstrba@suse.com>
- Clean-up the spec file
- Removed patch:
* commons-cli-1.4-jdk9.patch
+ not needed since we are not building with maven
- Added patch:
* CLI-253-workaround.patch
+ [CLI-253] Prevent "Unrecognized option: --null" when handling
long opts in PosixParser
-------------------------------------------------------------------
Tue Oct 23 17:55:39 UTC 2018 - Fridrich Strba <fstrba@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package apache-commons-cli
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -24,30 +24,30 @@ Release: 0
Summary: Command Line Interface Library for Java
License: Apache-2.0
Group: Development/Libraries/Java
Url: http://commons.apache.org/%{base_name}/
URL: http://commons.apache.org/%{base_name}/
Source0: http://www.apache.org/dist/commons/%{base_name}/source/%{short_name}-%{version}-src.tar.gz
Source1: build.xml.tar.bz2
Patch0: commons-cli-1.4-jdk9.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
Patch0: CLI-253-workaround.patch
BuildRequires: ant
BuildRequires: apache-commons-parent
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
BuildRequires: javapackages-local
BuildRequires: javapackages-tools
Requires: apache-commons-parent
Requires: java >= 1.8
Provides: jakarta-%{short_name} = %{version}-%{release}
Obsoletes: jakarta-%{short_name} < %{version}
Provides: apache-cli = %{version}
Obsoletes: apache-cli < %{version}
BuildArch: noarch
%description
The CLI library provides a simple and easy to use API for working with the
The CLI library provides an API for working with the
command line arguments and options.
%package javadoc
Summary: Javadoc for %{name}
Group: Development/Libraries/Java
Group: Documentation/HTML
Provides: jakarta-%{short_name}-javadoc = %{version}
Obsoletes: jakarta-%{short_name}-javadoc < %{version}
@ -59,45 +59,32 @@ This package contains the API documentation for %{name}.
%patch0 -p1
%build
export CLASSPATH=$(build-classpath \
plexus/ \
maven/ \
):target/classes:target/test-classes
ant -Dmaven.mode.offline=true package javadoc \
-Dmaven.test.skip=true \
-lib /usr/share/java
-lib %{_datadir}/java
%install
# jars
install -Dpm 644 target/%{short_name}-%{version}.jar %{buildroot}%{_javadir}/%{short_name}-%{version}.jar
(cd %{buildroot}%{_javadir} && for jar in *-%{version}*.jar; do ln -sf ${jar} apache-${jar}; done)
(cd %{buildroot}%{_javadir} && for jar in *-%{version}*.jar; do ln -sf ${jar} `echo $jar| sed "s|-%{version}||g"`; done)
install -Dpm 644 target/%{short_name}-%{version}.jar %{buildroot}%{_javadir}/%{short_name}.jar
ln -sf %{short_name}.jar %{buildroot}%{_javadir}/%{name}.jar
# pom
install -d -m 755 %{buildroot}%{_mavenpomdir}
install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/%{short_name}-%{version}.pom
%add_maven_depmap %{short_name}-%{version}.pom %{short_name}-%{version}.jar -a "org.apache.commons:%{short_name}"
install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/%{short_name}.pom
%add_maven_depmap %{short_name}.pom %{short_name}.jar -a "org.apache.commons:%{short_name}"
# javadoc
install -d -m 0755 %{buildroot}%{_javadocdir}/%{name}-%{version}
cp -pr target/site/api*/* %{buildroot}%{_javadocdir}/%{name}-%{version}/
%fdupes -s %{buildroot}%{_javadocdir}/%{name}-%{version}/
ln -s %{name}-%{version} %{buildroot}%{_javadocdir}/%{name}
install -d -m 0755 %{buildroot}%{_javadocdir}/%{name}
cp -pr target/site/api*/* %{buildroot}%{_javadocdir}/%{name}
%fdupes -s %{buildroot}%{_javadocdir}/%{name}
%files
%defattr(-,root,root)
%doc LICENSE.txt NOTICE.txt README.md RELEASE-NOTES.txt CONTRIBUTING.md
%{_javadir}/*
%{_mavenpomdir}/*
%if %{defined _maven_repository}
%config(noreplace) %{_mavendepmapfragdir}/%{name}
%else
%{_datadir}/maven-metadata/%{name}.xml
%endif
%files -f .mfiles
%license LICENSE.txt NOTICE.txt
%doc README.md RELEASE-NOTES.txt
%{_javadir}/%{name}.jar
%files javadoc
%defattr(-,root,root)
%doc LICENSE.txt
%{_javadocdir}/*
%license LICENSE.txt
%{_javadocdir}/%{name}
%changelog

View File

@ -1,13 +0,0 @@
--- commons-cli-1.4-src/pom.xml 2017-03-09 13:59:23.000000000 +0100
+++ commons-cli-1.4-src/pom.xml 2018-10-23 19:42:13.605822641 +0200
@@ -163,8 +163,8 @@
</dependencies>
<properties>
- <maven.compiler.source>1.5</maven.compiler.source>
- <maven.compiler.target>1.5</maven.compiler.target>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
<commons.componentid>cli</commons.componentid>
<commons.release.version>1.4</commons.release.version>
<commons.release.name>commons-cli-${commons.release.version}</commons.release.name>