This commit is contained in:
parent
104f2988f8
commit
e6ba3ff8d7
96
CLI-253-workaround.patch
Normal file
96
CLI-253-workaround.patch
Normal 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;
|
||||
+ }
|
||||
+}
|
@ -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,22 +24,22 @@ 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
|
||||
@ -59,24 +59,19 @@ 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}
|
||||
@ -84,20 +79,13 @@ cp -pr target/site/api*/* %{buildroot}%{_javadocdir}/%{name}-%{version}/
|
||||
%fdupes -s %{buildroot}%{_javadocdir}/%{name}-%{version}/
|
||||
ln -s %{name}-%{version} %{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
|
||||
%license LICENSE.txt
|
||||
%{_javadocdir}/*
|
||||
|
||||
%changelog
|
||||
|
Loading…
x
Reference in New Issue
Block a user