attempt to make a Mac Release using gradle

This is almost working with many workarounds:
- run rm lib/yacycore.jar
- run ./gradlew clean build bundleNative
- run ant clean all
- run again rm lib/yacycore.jar
- run ./fixMacBuild.sh

The build is then inside build/mac/YaCy.app

Right now this works so far but it does not have the correct release
number inside.

Target is to make this working for Windows releases and to embedd jre
entirely.
This commit is contained in:
Michael Peter Christen 2021-10-25 18:37:39 +02:00
parent 49cae8ca62
commit 3c86b7b780
7 changed files with 76 additions and 36 deletions

BIN
addon/YaCy.icns Normal file

Binary file not shown.

View File

@ -1,3 +1,9 @@
buildscript {
dependencies {
classpath "org.mini2Dx:parcl:1.7.1"
}
}
plugins { plugins {
id 'java' id 'java'
id 'maven-publish' id 'maven-publish'
@ -7,6 +13,7 @@ plugins {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'application' apply plugin: 'application'
apply plugin: "org.mini2Dx.parcl"
repositories { repositories {
flatDir { flatDir {
@ -31,6 +38,27 @@ java.targetCompatibility = JavaVersion.VERSION_1_8
mainClassName = "net.yacy.yacy" mainClassName = "net.yacy.yacy"
applicationDefaultJvmArgs = ["-Xmx1024m"] applicationDefaultJvmArgs = ["-Xmx1024m"]
parcl {
exe {
exeName = "YaCy"
}
app {
vmArgs = ["-Xmx1g"]
appName = "YaCy"
icon = "addon/YaCy.icns"
applicationCategory = "Search-Engine"
displayName = 'YaCy Search Engine'
identifier = 'net.yacy'
copyright = 'Copyright 2021 Michael Peter Christen et al.'
zipName = 'YaCy.zip'
}
linux {
binName = "YaCy"
}
}
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }

3
fixMacBuild.sh Executable file
View File

@ -0,0 +1,3 @@
cp -R htroot build/mac/YaCy.app/Contents/
cp -R defaults build/mac/YaCy.app/Contents/
cp -R langdetect build/mac/YaCy.app/Contents/

1
gradle.properties Normal file
View File

@ -0,0 +1 @@
org.gradle.parallel=true

View File

@ -48,7 +48,7 @@ public class Banner {
final serverObjects post, final serverObjects post,
final serverSwitch env) throws IOException { final serverSwitch env) throws IOException {
final Switchboard sb = (Switchboard) env; final Switchboard sb = (Switchboard) env;
final String pathToImage = "htroot/env/grafics/yacy.png"; final String pathToImage = sb.appPath + "/htroot/env/grafics/yacy.png";
int width = 468; int width = 468;
int height = 60; int height = 60;
String bgcolor = "e7effc"; String bgcolor = "e7effc";

View File

@ -75,18 +75,18 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
public Jetty9HttpServerImpl(int port) { public Jetty9HttpServerImpl(int port) {
Switchboard sb = Switchboard.getSwitchboard(); Switchboard sb = Switchboard.getSwitchboard();
server = new Server(); this.server = new Server();
int cores = ProcessorUtils.availableProcessors(); int cores = ProcessorUtils.availableProcessors();
int acceptors = Math.max(1, Math.min(4, cores/2)); // original: Math.max(1, Math.min(4,cores/8)); int acceptors = Math.max(1, Math.min(4, cores/2)); // original: Math.max(1, Math.min(4,cores/8));
HttpConnectionFactory hcf = new HttpConnectionFactory(); HttpConnectionFactory hcf = new HttpConnectionFactory();
ServerConnector connector = new ServerConnector(server, null, null, null, acceptors, -1, hcf); ServerConnector connector = new ServerConnector(this.server, null, null, null, acceptors, -1, hcf);
connector.setPort(port); connector.setPort(port);
connector.setName("httpd:"+Integer.toString(port)); connector.setName("httpd:"+Integer.toString(port));
connector.setIdleTimeout(9000); // timout in ms when no bytes send / received connector.setIdleTimeout(9000); // timout in ms when no bytes send / received
connector.setAcceptQueueSize(128); connector.setAcceptQueueSize(128);
server.addConnector(connector); this.server.addConnector(connector);
// add ssl/https connector // add ssl/https connector
@ -105,14 +105,14 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
https_config.addCustomizer(new SecureRequestCustomizer()); https_config.addCustomizer(new SecureRequestCustomizer());
// SSL Connector // SSL Connector
ServerConnector sslConnector = new ServerConnector(server, ServerConnector sslConnector = new ServerConnector(this.server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config)); new HttpConnectionFactory(https_config));
sslConnector.setPort(sslport); sslConnector.setPort(sslport);
sslConnector.setName("ssld:" + Integer.toString(sslport)); // name must start with ssl (for withSSL() to work correctly) sslConnector.setName("ssld:" + Integer.toString(sslport)); // name must start with ssl (for withSSL() to work correctly)
sslConnector.setIdleTimeout(9000); // timout in ms when no bytes send / received sslConnector.setIdleTimeout(9000); // timout in ms when no bytes send / received
server.addConnector(sslConnector); this.server.addConnector(sslConnector);
ConcurrentLog.info("SERVER", "SSL support initialized successfully on port " + sslport); ConcurrentLog.info("SERVER", "SSL support initialized successfully on port " + sslport);
} }
} }
@ -123,7 +123,8 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
// configure root context // configure root context
WebAppContext htrootContext = new WebAppContext(); WebAppContext htrootContext = new WebAppContext();
htrootContext.setContextPath("/"); htrootContext.setContextPath("/");
String htrootpath = sb.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT); String htrootpath = sb.appPath + "/" + sb.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT);
ConcurrentLog.info("Jetty9HttpServerImpl", "htrootpath = " + htrootpath);
htrootContext.setErrorHandler(new YaCyErrorHandler()); // handler for custom error page htrootContext.setErrorHandler(new YaCyErrorHandler()); // handler for custom error page
try { try {
htrootContext.setBaseResource(Resource.newResource(htrootpath)); htrootContext.setBaseResource(Resource.newResource(htrootpath));
@ -201,7 +202,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
} }
// context handler for dispatcher and security (hint: dispatcher requires a context) // context handler for dispatcher and security (hint: dispatcher requires a context)
ContextHandler context = new ContextHandler(); ContextHandler context = new ContextHandler();
context.setServer(server); context.setServer(this.server);
context.setContextPath("/"); context.setContextPath("/");
context.setHandler(handlers); context.setHandler(handlers);
context.setMaxFormContentSize(1024 * 1024 * 10); // allow 10MB, large forms may be required during crawl starts with long lists context.setMaxFormContentSize(1024 * 1024 * 10); // allow 10MB, large forms may be required during crawl starts with long lists
@ -209,7 +210,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
// make YaCy handlers (in context) and servlet context handlers available (both contain root context "/") // make YaCy handlers (in context) and servlet context handlers available (both contain root context "/")
// logic: 1. YaCy handlers are called if request not handled (e.g. proxy) then servlets handle it // logic: 1. YaCy handlers are called if request not handled (e.g. proxy) then servlets handle it
ContextHandlerCollection allrequesthandlers = new ContextHandlerCollection(); ContextHandlerCollection allrequesthandlers = new ContextHandlerCollection();
allrequesthandlers.setServer(server); allrequesthandlers.setServer(this.server);
allrequesthandlers.addHandler(context); allrequesthandlers.addHandler(context);
allrequesthandlers.addHandler(htrootContext); allrequesthandlers.addHandler(htrootContext);
allrequesthandlers.addHandler(new DefaultHandler()); // if not handled by other handler allrequesthandlers.addHandler(new DefaultHandler()); // if not handled by other handler
@ -225,7 +226,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
htrootContext.setSecurityHandler(securityHandler); htrootContext.setSecurityHandler(securityHandler);
// wrap all handlers // wrap all handlers
Handler crashHandler = new CrashProtectionHandler(server, allrequesthandlers); Handler crashHandler = new CrashProtectionHandler(this.server, allrequesthandlers);
// check server access restriction and add InetAccessHandler if restrictions are needed // check server access restriction and add InetAccessHandler if restrictions are needed
// otherwise don't (to save performance) // otherwise don't (to save performance)
final String white = sb.getConfig("serverClient", "*"); final String white = sb.getConfig("serverClient", "*");
@ -260,10 +261,10 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
ConcurrentLog.info("SERVER","activated IP access restriction to: [" + loopbackAddress + "," + white +"]"); ConcurrentLog.info("SERVER","activated IP access restriction to: [" + loopbackAddress + "," + white +"]");
} else { } else {
server.setHandler(crashHandler); // InetAccessHandler not needed this.server.setHandler(crashHandler); // InetAccessHandler not needed
} }
} else { } else {
server.setHandler(crashHandler); // InetAccessHandler not needed this.server.setHandler(crashHandler); // InetAccessHandler not needed
} }
} }
@ -274,8 +275,8 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
public void startupServer() throws Exception { public void startupServer() throws Exception {
// option to finish running requests on shutdown // option to finish running requests on shutdown
// server.setGracefulShutdown(3000); // server.setGracefulShutdown(3000);
server.setStopAtShutdown(true); this.server.setStopAtShutdown(true);
server.start(); this.server.start();
} }
/** /**
@ -283,8 +284,8 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
*/ */
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
server.stop(); this.server.stop();
server.join(); this.server.join();
} }
/** /**
@ -292,7 +293,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
*/ */
@Override @Override
public boolean withSSL() { public boolean withSSL() {
Connector[] clist = server.getConnectors(); Connector[] clist = this.server.getConnectors();
for (Connector c:clist) { for (Connector c:clist) {
if (c.getName().startsWith("ssl")) return true; if (c.getName().startsWith("ssl")) return true;
} }
@ -305,7 +306,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
*/ */
@Override @Override
public int getSslPort() { public int getSslPort() {
Connector[] clist = server.getConnectors(); Connector[] clist = this.server.getConnectors();
for (Connector c:clist) { for (Connector c:clist) {
if (c.getName().startsWith("ssl")) { if (c.getName().startsWith("ssl")) {
int port =((ServerConnector)c).getLocalPort(); int port =((ServerConnector)c).getLocalPort();
@ -336,12 +337,12 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
} }
try { try {
if (!server.isRunning() || server.isStopped()) { if (!Jetty9HttpServerImpl.this.server.isRunning() || Jetty9HttpServerImpl.this.server.isStopped()) {
server.start(); Jetty9HttpServerImpl.this.server.start();
} }
// reconnect with new settings (instead to stop/start server, just manipulate connectors // reconnect with new settings (instead to stop/start server, just manipulate connectors
final Connector[] cons = server.getConnectors(); final Connector[] cons = Jetty9HttpServerImpl.this.server.getConnectors();
final int port = Switchboard.getSwitchboard().getLocalPort(); final int port = Switchboard.getSwitchboard().getLocalPort();
final int sslport = Switchboard.getSwitchboard().getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443); final int sslport = Switchboard.getSwitchboard().getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443);
for (Connector con : cons) { for (Connector con : cons) {
@ -521,7 +522,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
@Override @Override
public int getServerThreads() { public int getServerThreads() {
return server == null ? 0 : server.getThreadPool().getThreads() - server.getThreadPool().getIdleThreads(); return this.server == null ? 0 : this.server.getThreadPool().getThreads() - this.server.getThreadPool().getIdleThreads();
} }
@Override @Override

View File

@ -729,10 +729,17 @@ public final class yacy {
// try to find the application root path within a Mac application // try to find the application root path within a Mac application
// call com.apple.eio.FileManager.getPathToApplicationBundle(); // call com.apple.eio.FileManager.getPathToApplicationBundle();
try { try {
// these methods will cause a warning: remove them with --illegal-access=permit
final Class<?> comAppleEioFileManagerClass = Class.forName("com.apple.eio.FileManager"); final Class<?> comAppleEioFileManagerClass = Class.forName("com.apple.eio.FileManager");
final Method getPathToApplicationBundleMethod = ClassProvider.getStaticMethod(comAppleEioFileManagerClass, "getPathToApplicationBundle", null); final Method getPathToApplicationBundleMethod = ClassProvider.getStaticMethod(comAppleEioFileManagerClass, "getPathToApplicationBundle", null);
final String apppath = (String) getPathToApplicationBundleMethod.invoke(null); final String apppath = (String) getPathToApplicationBundleMethod.invoke(null);
System.out.println("PathToApplicationBundle = " + apppath); System.out.println("PathToApplicationBundle = " + apppath); // PathToApplicationBundle = /Users/admin/git/rc1/build/YaCy.app
if (apppath != null && apppath.endsWith(".app")) {
// modify the applicationRoot path to within the app file
applicationRoot = new File(apppath + "/Contents");
System.setProperty("user.dir", applicationRoot.getAbsolutePath()); // required since nasty code elswhere is using it
System.setProperty("user.home", applicationRoot.getAbsolutePath()); // well
}
} catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException | IllegalArgumentException e) { } catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }