-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better detection for Enso's NI when launching Language Server #12034
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
Apache Tika core | ||
Copyright 2007-2022 The Apache Software Foundation | ||
|
||
This product includes software developed at | ||
The Apache Software Foundation (http://www.apache.org/). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Information about rights held in and over the resource. Typically, | ||
* a Rights element will contain a rights management statement for | ||
* the resource, or reference a service providing such information. | ||
* Rights information often encompasses Intellectual Property Rights | ||
* (IPR), Copyright, and various Property Rights. If the Rights element | ||
* is absent, no assumptions can be made about the status of these and | ||
* other rights with respect to the resource. | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
Apache Tika core | ||
Copyright 2007-2022 The Apache Software Foundation | ||
|
||
This product includes software developed at | ||
The Apache Software Foundation (http://www.apache.org/). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Information about rights held in and over the resource. Typically, | ||
* a Rights element will contain a rights management statement for | ||
* the resource, or reference a service providing such information. | ||
* Rights information often encompasses Intellectual Property Rights | ||
* (IPR), Copyright, and various Property Rights. If the Rights element | ||
* is absent, no assumptions can be made about the status of these and | ||
* other rights with respect to the resource. | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ import org.enso.cli.OS | |
import org.enso.distribution.{DistributionManager, Environment} | ||
import org.enso.runtimeversionmanager.components.Engine | ||
|
||
import org.apache.tika.config.TikaConfig | ||
import org.apache.tika.Tika | ||
|
||
import java.nio.file.Path | ||
|
||
case class NativeExecCommand(executablePath: Path) extends ExecCommand { | ||
|
@@ -26,7 +29,22 @@ object NativeExecCommand { | |
val fullExecPath = | ||
dm.paths.engines.resolve(version).resolve("bin").resolve(execName) | ||
|
||
if (fullExecPath.toFile.exists()) Some(NativeExecCommand(fullExecPath)) | ||
else None | ||
if (fullExecPath.toFile.exists() && isBinary(fullExecPath)) { | ||
Some(NativeExecCommand(fullExecPath)) | ||
} else None | ||
} | ||
|
||
private def isBinary(path: Path): Boolean = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternative check would be:
that is a common prefix of most of the shell scripts. However we'd have to add such header to our shell script: enso$ git diff
diff --git distribution/bin/enso distribution/bin/enso
index 1939fc99dc..93a45f4a6e 100755
--- distribution/bin/enso
+++ distribution/bin/enso
@@ -1,3 +1,5 @@
+#!/bin/sh
+
COMP_PATH=$(dirname "$0")/../component
JAVA_OPTS="--add-opens=java.base/java.nio=ALL-UNNAMED $JAVA_OPTS" but as you say, Tika was already available as it is used somewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That wouldn't work on Windows There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But on windows the difference is in extension:
We only need the content file check for Unixes. |
||
try { | ||
val config = TikaConfig.getDefaultConfig() | ||
val tika = new Tika(config) | ||
val mimeTypes = config.getMimeRepository | ||
val mime = tika.detect(path); | ||
val tpe = mimeTypes.forName(mime).getType.getType | ||
tpe != null && tpe == "application" | ||
} catch { | ||
case _: Throwable => | ||
false | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
6EB80DB9BFB5BAC58FFE8EAB48A509A40EAC27733FCD0F46BC5FC3FDDB82339C | ||
1C7BD42739A2FD536962BEEA3DC052C025F06FFA1E25E9D7BA0D41E9714BCD24 | ||
29565A85352D2C3F92648DF46C368298D320747F00AE06FD83197DD6E4CC1DF7 | ||
0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"The copyright information." | ||
ARTWORK_OR_OBJECT_DETAIL_COPYRIGHT_NOTICE, ARTWORK_OR_OBJECT_DETAIL_CREATOR, | ||
COPYRIGHT_OWNER_ID, COPYRIGHT_OWNER_NAME, IMAGE_CREATOR_ID, IMAGE_CREATOR_NAME, | ||
Contains any necessary copyright notice for claiming the intellectual | ||
Copyright 2016 Norconex Inc. | ||
Copyright Owner, Image Supplier and Licensor may be the same or different | ||
Copyright ownership can be expressed in a more controlled way using the | ||
DATE_CREATED, DESCRIPTION_WRITER, INSTRUCTIONS, JOB_ID, TITLE, COPYRIGHT_NOTICE, | ||
Owner or owners of the copyright in the licensed image. | ||
PREFIX_IPTC_EXT + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "AOCopyrightNotice"); | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwner"); | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwnerID"), | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwnerId"; | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwnerName"); | ||
Property ARTWORK_OR_OBJECT_DETAIL_COPYRIGHT_NOTICE = Property.internalTextBag( | ||
Property COPYRIGHT = Property.externalText("xmpDM:copyright"); | ||
Property COPYRIGHT_NOTICE = DublinCore.RIGHTS; | ||
Property COPYRIGHT_OWNER = Property.internalTextBag( | ||
Property COPYRIGHT_OWNER_ID = Property.composite(Property.internalTextBag( | ||
Property COPYRIGHT_OWNER_NAME = Property.internalTextBag( | ||
Serves to identify the rights holder/s for the image. The Copyright | ||
String COPYRIGHT_OWNER_ID_WRONG_CASE = | ||
The ID of the owner or owners of the copyright in the licensed image. | ||
The name of the owner or owners of the copyright in the licensed image. | ||
current owner of the copyright of this work with associated intellectual | ||
in the CopyrightNotice. | ||
new Property[]{Property.internalTextBag(IPTC.COPYRIGHT_OWNER_ID_WRONG_CASE)}); | ||
regarding copyright ownership. The ASF licenses this file | ||
the copyrights of this image other rights properties may be used. | ||
standard. These parts Copyright 2010 International Press Telecommunications | ||
this work for additional information regarding copyright ownership. | ||
@deprecated use {@link IPTC#COPYRIGHT_OWNER_ID} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(IPR), Copyright, and various Property Rights. If the Rights element |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
META-INF/LICENSE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
META-INF/NOTICE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
AB38B719F515D34ED9C306CFCCE5B436B8CAC50023F5ACE621D45CBB89AC4C8A | ||
61C62A70B9F4C08AE1C1779CA8F11375E197064992F5E0535EB8AD9679A8DE72 | ||
0D98680156DAEE1AF045DF3CC156B9646A0CACA43BC631F9174F8BEAA10B40C9 | ||
279C45838441742F8D12E7FCB9546C7AD404AE8DE401A80DE5E341B7481FECB9 | ||
0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"The copyright information." | ||
ARTWORK_OR_OBJECT_DETAIL_COPYRIGHT_NOTICE, ARTWORK_OR_OBJECT_DETAIL_CREATOR, | ||
COPYRIGHT_OWNER_ID, COPYRIGHT_OWNER_NAME, IMAGE_CREATOR_ID, IMAGE_CREATOR_NAME, | ||
Contains any necessary copyright notice for claiming the intellectual | ||
Copyright 2016 Norconex Inc. | ||
Copyright Owner, Image Supplier and Licensor may be the same or different | ||
Copyright ownership can be expressed in a more controlled way using the | ||
DATE_CREATED, DESCRIPTION_WRITER, INSTRUCTIONS, JOB_ID, TITLE, COPYRIGHT_NOTICE, | ||
PREFIX_IPTC_EXT + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "AOCopyrightNotice"); | ||
Owner or owners of the copyright in the licensed image. | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwner"); | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwnerID"), | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwnerId"; | ||
PREFIX_PLUS + TikaCoreProperties.NAMESPACE_PREFIX_DELIMITER + "CopyrightOwnerName"); | ||
Property ARTWORK_OR_OBJECT_DETAIL_COPYRIGHT_NOTICE = Property.internalTextBag( | ||
Property COPYRIGHT = Property.externalText("xmpDM:copyright"); | ||
Property COPYRIGHT_NOTICE = DublinCore.RIGHTS; | ||
Property COPYRIGHT_OWNER = Property.internalTextBag( | ||
Property COPYRIGHT_OWNER_ID = Property.composite(Property.internalTextBag( | ||
Property COPYRIGHT_OWNER_NAME = Property.internalTextBag( | ||
Serves to identify the rights holder/s for the image. The Copyright | ||
String COPYRIGHT_OWNER_ID_WRONG_CASE = | ||
The ID of the owner or owners of the copyright in the licensed image. | ||
The name of the owner or owners of the copyright in the licensed image. | ||
current owner of the copyright of this work with associated intellectual | ||
in the CopyrightNotice. | ||
new Property[]{Property.internalTextBag(IPTC.COPYRIGHT_OWNER_ID_WRONG_CASE)}); | ||
regarding copyright ownership. The ASF licenses this file | ||
standard. These parts Copyright 2010 International Press Telecommunications | ||
the copyrights of this image other rights properties may be used. | ||
this work for additional information regarding copyright ownership. | ||
@deprecated use {@link IPTC#COPYRIGHT_OWNER_ID} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(IPR), Copyright, and various Property Rights. If the Rights element |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
META-INF/LICENSE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
META-INF/NOTICE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
8FAA9FD449B96C40ED702C5EE532FCCBF853A848FE372026EB4E1FE8A52A7ACE | ||
9A28F6CA5CA670813F858F51F213FD37A3902E1B49017AEE7EED5A6C04C6C5C4 | ||
84814B3648653F7BE53D330E8D7DBB23B5F2F564F37406A90D21A41A382C71F4 | ||
4093B05996A6AF7CA3312C75DD7E42FFB01D783B0E77773BC0EB358322686452 | ||
0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tika is added as a moduleDependency, but
module-info.java
for runtime-version-manager is not changed? How is it possible that this works? There should be something likerequires org.apache.tika
added to the module descriptor.It compiles because you are using tika in Scala source, but my gut feeling is that it might crash in runtime at some point on
NoClassDefFound
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that the new functionality in
NativeExecCommand
is tested?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we build native image in classpath mode instead of using modulepath? If so, then that might be an explanation of the
module-info
having no effect. Just a thought...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - the
runtime-version-manager
should be just fine when you run it in NI. It might also be fine when you run it in JVM, because we might have theorg.apache.tika
module already in the set of observable modules. Anyway, if the changes work, I am fine with that, I was just surprised that it works.