!1 package init

Merge pull request !1 from maminjie/master
This commit is contained in:
openeuler-ci-bot 2020-08-31 15:59:34 +08:00 committed by Gitee
commit 27508db6a5
5 changed files with 206 additions and 0 deletions

View File

@ -0,0 +1,107 @@
From d33893c3e3ea8f4be7636439a8f9011bb179a8e9 Mon Sep 17 00:00:00 2001
Date: Mon, 13 Jun 2016 13:14:03 +0200
Subject: [PATCH] Set location for pomless models
Core Maven model reader sets location and some tools depend on these
values. These tools won't work with tycho-pomless unless it also sets
the location.
Change-Id: I4da47c995c1333db0bb0ddb31f7309b08bf5ff39
---
diff --git a/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java b/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
index 349c776..e8a4f92 100644
--- a/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
+++ b/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
@@ -26,6 +26,8 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.maven.model.InputLocation;
+import org.apache.maven.model.InputSource;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
@@ -90,6 +92,7 @@
String bundleVersion = getRequiredHeaderValue("Bundle-Version", headers, manifestFile);
model.setVersion(getPomVersion(bundleVersion));
model.setPackaging(getPackagingType(bundleSymbolicName));
+ setLocation(model, manifestFile);
return model;
}
@@ -150,6 +153,7 @@
}
model.setVersion(getPomVersion(versionNode.getValue()));
// groupId is inherited from parent pom
+ setLocation(model, xmlFile);
return model;
}
@@ -247,4 +251,11 @@
parentReference.setVersion(version);
return parentReference;
}
+
+ private void setLocation(Model model, File modelSource) {
+ InputSource inputSource = new InputSource();
+ inputSource.setLocation(modelSource.toString());
+ inputSource.setModelId(model.getParent().getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion());
+ model.setLocation("", new InputLocation(0, 0, inputSource));
+ }
}
diff --git a/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java b/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
index 05cf0c2..a40e738 100644
--- a/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
+++ b/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
@@ -19,6 +19,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.maven.model.InputLocation;
+import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.building.ModelProcessor;
@@ -45,6 +47,7 @@
assertEquals("0.1.0-SNAPSHOT", model.getVersion());
assertEquals("eclipse-plugin", model.getPackaging());
assertParent(model.getParent());
+ assertLocation("bundle1/META-INF/MANIFEST.MF", model.getLocation(""));
}
@Test
@@ -55,6 +58,7 @@
assertEquals("1.0.1", model.getVersion());
assertEquals("eclipse-test-plugin", model.getPackaging());
assertParent(model.getParent());
+ assertLocation("bundle1.tests/META-INF/MANIFEST.MF", model.getLocation(""));
}
@Test
@@ -65,6 +69,7 @@
assertEquals("1.0.0-SNAPSHOT", model.getVersion());
assertEquals("eclipse-feature", model.getPackaging());
assertParent(model.getParent());
+ assertLocation("feature/feature.xml", model.getLocation(""));
}
@Test
@@ -204,6 +209,17 @@
assertEquals("0.0.1-SNAPSHOT", parent.getVersion());
}
+ private void assertLocation(String expectedLocation, InputLocation location) {
+ assertNotNull(location);
+ assertEquals(0, location.getLineNumber());
+ assertEquals(0, location.getColumnNumber());
+ InputSource source = location.getSource();
+ assertNotNull(source);
+ assertEquals(new File(getPolyglotTestDir(), expectedLocation).toString(), source.getLocation());
+ assertNotNull(source.getModelId());
+ assertTrue(source.getModelId().matches("^testParent.groupId:.*:.*"));
+ }
+
private Map<String, String> createReaderOptions(File buildProperties) {
Map<String, String> options = new HashMap<>();
options.put(ModelProcessor.SOURCE, buildProperties.getAbsolutePath());

Binary file not shown.

View File

@ -0,0 +1,31 @@
diff --git a/tycho-source-feature-plugin/src/main/java/org/eclipse/tycho/extras/sourcefeature/SourceFeatureMojo.java b/tycho-source-feature-plugin/src/main/java/org/eclipse/tycho/extras/sourcefeature/SourceFeatureMojo.java
index 05baf87..2c62fb0 100644
--- a/tycho-source-feature-plugin/src/main/java/org/eclipse/tycho/extras/sourcefeature/SourceFeatureMojo.java
+++ b/tycho-source-feature-plugin/src/main/java/org/eclipse/tycho/extras/sourcefeature/SourceFeatureMojo.java
@@ -549,15 +549,19 @@ public class SourceFeatureMojo extends AbstractMojo {
}
private String getAttribute(PlexusConfiguration dom, String attrName) {
- String attr = dom.getAttribute(attrName);
- if (attr == null) {
- return null;
- }
- attr = attr.trim();
- if (attr.length() == 0) {
+ try {
+ String attr = dom.getAttribute(attrName);
+ if (attr == null) {
+ return null;
+ }
+ attr = attr.trim();
+ if (attr.length() == 0) {
+ return null;
+ }
+ return attr;
+ } catch (Exception e) {
return null;
}
- return attr;
}
}

64
tycho-extras.spec Normal file
View File

@ -0,0 +1,64 @@
%global xmvn_libdir %(realpath $(dirname $(readlink -f $(which xmvn)))/../lib)
Name: tycho-extras
Version: 1.3.0
Release: 1
Summary: Additional plugins for Tycho
License: EPL-1.0
URL: http://eclipse.org/tycho/
Source0: http://git.eclipse.org/c/tycho/org.eclipse.tycho.extras.git/snapshot/org.eclipse.tycho.extras-tycho-extras-%{version}.tar.xz
Patch0: %{name}-fix-build.patch
Patch1: fix-xmvn-pomless-builddep.patch
BuildArch: noarch
ExcludeArch: s390 %{arm} %{ix86}
BuildRequires: maven-local mvn(io.takari.polyglot:polyglot-common)
BuildRequires: mvn(org.apache.commons:commons-lang3) mvn(org.apache.maven:maven-archiver)
BuildRequires: mvn(org.apache.maven:maven-core) mvn(org.apache.maven:maven-model)
BuildRequires: mvn(org.apache.maven:maven-model-builder)
BuildRequires: mvn(org.apache.maven:maven-plugin-api)
BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-source-plugin)
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations)
BuildRequires: mvn(org.codehaus.plexus:plexus-component-metadata)
BuildRequires: mvn(org.eclipse.jgit:org.eclipse.jgit)
BuildRequires: mvn(org.eclipse.sisu:org.eclipse.sisu.plexus)
BuildRequires: mvn(org.eclipse.tycho:org.eclipse.tycho.core.shared)
BuildRequires: mvn(org.eclipse.tycho:org.eclipse.tycho.p2.resolver.shared)
BuildRequires: mvn(org.eclipse.tycho:sisu-equinox-launching) mvn(org.eclipse.tycho:tycho-core)
BuildRequires: mvn(org.eclipse.tycho:tycho-p2-facade)
BuildRequires: mvn(org.eclipse.tycho:tycho-packaging-plugin)
%description
A small set of plugins that work with Tycho to provide additional functionality
when building projects of an OSGi nature.
%package javadoc
Summary: Java docs for %{name}
%description javadoc
This package contains the API documentation for %{name}.
%prep
%setup -q -n org.eclipse.tycho.extras-tycho-extras-%{version}
%patch0 -p1
%patch1 -p1
%pom_remove_plugin :maven-site-plugin
%pom_remove_plugin org.eclipse.m2e:lifecycle-mapping
%pom_remove_plugin org.sonatype.plugins:maven-properties-plugin tycho-p2-extras-plugin
%pom_remove_dep org.apache.maven:apache-maven tycho-p2-extras-plugin
%mvn_alias :{*} org.eclipse.tycho:@1
%build
%mvn_build -f
%install
%mvn_install
install -d -m 755 %{buildroot}%{xmvn_libdir}/ext/
ln -s %{_javadir}/%{name}/tycho-pomless.jar %{buildroot}%{xmvn_libdir}/ext/
ln -s %{_javadir}/tesla-polyglot/polyglot-common.jar %{buildroot}%{xmvn_libdir}/ext/
%files -f .mfiles
%{xmvn_libdir}/ext/*
%files javadoc -f .mfiles-javadoc
%changelog
* Wed Aug 19 2020 maminjie <maminjie1@huawei.com> - 1.3.0-1
- package init

4
tycho-extras.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: eclipse/tycho.extras
tag_prefix: "tycho-extras-"
seperator: "."