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.
pull/436/head
Michael Peter Christen 3 years ago
parent 49cae8ca62
commit 3c86b7b780

Binary file not shown.

@ -1,3 +1,9 @@
buildscript {
dependencies {
classpath "org.mini2Dx:parcl:1.7.1"
}
}
plugins {
id 'java'
id 'maven-publish'
@ -7,6 +13,7 @@ plugins {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: "org.mini2Dx.parcl"
repositories {
flatDir {
@ -31,10 +38,31 @@ java.targetCompatibility = JavaVersion.VERSION_1_8
mainClassName = "net.yacy.yacy"
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) {
options.encoding = 'UTF-8'
}
dependencies {
implementation(fileTree("lib"))
}
}

@ -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/

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

@ -48,7 +48,7 @@ public class Banner {
final serverObjects post,
final serverSwitch env) throws IOException {
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 height = 60;
String bgcolor = "e7effc";
@ -73,7 +73,7 @@ public class Banner {
env.getConfig(
SwitchboardConstants.NETWORK_NAME,
"unspecified").toUpperCase();
// the '+ 1': the own peer is not included in sizeConnected()
final int peers = sb.peers.sizeConnected() + 1;
long nlinks = sb.peers.countActiveURL();
@ -89,7 +89,7 @@ public class Banner {
words = seed.getWordCount();
myppm = Switchboard.currentPPM();
myqph = 60d * sb.averageQPM();
if (sb.peers.mySeed().isVirgin()) {
type = "VIRGIN";
nqph = Math.round(6000d * nqpm) / 100d;

@ -2,7 +2,7 @@
// Jetty9HttpServerImpl
// Copyright 2011 by Florian Richter
// First released 13.04.2011 at http://yacy.net
//
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
@ -11,12 +11,12 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program in the file lgpl21.txt
// If not, see <http://www.gnu.org/licenses/>.
@ -75,19 +75,19 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
public Jetty9HttpServerImpl(int port) {
Switchboard sb = Switchboard.getSwitchboard();
server = new Server();
this.server = new Server();
int cores = ProcessorUtils.availableProcessors();
int acceptors = Math.max(1, Math.min(4, cores/2)); // original: Math.max(1, Math.min(4,cores/8));
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.setName("httpd:"+Integer.toString(port));
connector.setIdleTimeout(9000); // timout in ms when no bytes send / received
connector.setAcceptQueueSize(128);
server.addConnector(connector);
this.server.addConnector(connector);
// add ssl/https connector
boolean useSSL = sb.getConfigBool("server.https", false);
@ -105,14 +105,14 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
https_config.addCustomizer(new SecureRequestCustomizer());
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server,
ServerConnector sslConnector = new ServerConnector(this.server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config));
sslConnector.setPort(sslport);
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
server.addConnector(sslConnector);
this.server.addConnector(sslConnector);
ConcurrentLog.info("SERVER", "SSL support initialized successfully on port " + sslport);
}
}
@ -123,7 +123,8 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
// configure root context
WebAppContext htrootContext = new WebAppContext();
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
try {
htrootContext.setBaseResource(Resource.newResource(htrootpath));
@ -136,7 +137,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
Resource webxml = Resource.newResource(sb.dataPath + "/DATA/SETTINGS/web.xml");
if (webxml.exists()) {
htrootContext.setDescriptor(webxml.getName());
}
}
} catch (IOException ex) {
if (htrootContext.getBaseResource() == null) {
@ -201,7 +202,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
}
// context handler for dispatcher and security (hint: dispatcher requires a context)
ContextHandler context = new ContextHandler();
context.setServer(server);
context.setServer(this.server);
context.setContextPath("/");
context.setHandler(handlers);
context.setMaxFormContentSize(1024 * 1024 * 10); // allow 10MB, large forms may be required during crawl starts with long lists
@ -209,10 +210,10 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
// 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
ContextHandlerCollection allrequesthandlers = new ContextHandlerCollection();
allrequesthandlers.setServer(server);
allrequesthandlers.setServer(this.server);
allrequesthandlers.addHandler(context);
allrequesthandlers.addHandler(htrootContext);
allrequesthandlers.addHandler(new DefaultHandler()); // if not handled by other handler
allrequesthandlers.addHandler(htrootContext);
allrequesthandlers.addHandler(new DefaultHandler()); // if not handled by other handler
YaCyLoginService loginService = new YaCyLoginService();
// this is very important (as it is part of the user password hash)
@ -225,7 +226,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
htrootContext.setSecurityHandler(securityHandler);
// 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
// otherwise don't (to save performance)
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 +"]");
} else {
server.setHandler(crashHandler); // InetAccessHandler not needed
this.server.setHandler(crashHandler); // InetAccessHandler not needed
}
} 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 {
// option to finish running requests on shutdown
// server.setGracefulShutdown(3000);
server.setStopAtShutdown(true);
server.start();
this.server.setStopAtShutdown(true);
this.server.start();
}
/**
@ -283,16 +284,16 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
*/
@Override
public void stop() throws Exception {
server.stop();
server.join();
this.server.stop();
this.server.join();
}
/**
* @return true if ssl/https connector is available
*/
@Override
public boolean withSSL() {
Connector[] clist = server.getConnectors();
public boolean withSSL() {
Connector[] clist = this.server.getConnectors();
for (Connector c:clist) {
if (c.getName().startsWith("ssl")) return true;
}
@ -305,7 +306,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
*/
@Override
public int getSslPort() {
Connector[] clist = server.getConnectors();
Connector[] clist = this.server.getConnectors();
for (Connector c:clist) {
if (c.getName().startsWith("ssl")) {
int port =((ServerConnector)c).getLocalPort();
@ -336,12 +337,12 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
ConcurrentLog.logException(e);
}
try {
if (!server.isRunning() || server.isStopped()) {
server.start();
if (!Jetty9HttpServerImpl.this.server.isRunning() || Jetty9HttpServerImpl.this.server.isStopped()) {
Jetty9HttpServerImpl.this.server.start();
}
// 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 sslport = Switchboard.getSwitchboard().getConfigInt(SwitchboardConstants.SERVER_SSLPORT, 8443);
for (Connector con : cons) {
@ -455,7 +456,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
final KeyStore ks = KeyStore.getInstance("JKS");
ks.load(null,keyStorePwd.toCharArray());
try (
/* Automatically closed by this try-with-resources statement */
/* Automatically closed by this try-with-resources statement */
final FileOutputStream ksOut = new FileOutputStream(keyStoreFileName);
) {
ks.store(ksOut, keyStorePwd.toCharArray());
@ -521,7 +522,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
@Override
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

@ -729,10 +729,17 @@ public final class yacy {
// try to find the application root path within a Mac application
// call com.apple.eio.FileManager.getPathToApplicationBundle();
try {
// these methods will cause a warning: remove them with --illegal-access=permit
final Class<?> comAppleEioFileManagerClass = Class.forName("com.apple.eio.FileManager");
final Method getPathToApplicationBundleMethod = ClassProvider.getStaticMethod(comAppleEioFileManagerClass, "getPathToApplicationBundle", 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) {
e.printStackTrace();
}

Loading…
Cancel
Save