Gradle upload a custom-generated jar file to Nexus

Do this: apply plugin: ‘maven-publish’ publishing { publications { maven( MavenPublication ) { artifact theTaskThatGeneratesJar } } repositories { maven { def releasesRepoUrl = http://…/repositories/releases/’ def snapshotsRepoUrl = ‘http://…/repositories/snapshots/’ url = version.endsWith(‘SNAPSHOT’) ? snapshotsRepoUrl : releasesRepoUrl credentials { username ‘xxx’ password ‘xxx’ } } } }

Read process output in Java without hanging the main thread

/** * 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 …

Read process output in Java without hanging the main thread Read More »

Quick log4j set up

<!– pom.xml –> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.7</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.7</version> </dependency> <!– src/main/resources/log4j.xml –> <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE log4j:configuration SYSTEM “log4j.dtd”> <log4j:configuration xmlns:log4j=””> <appender name=”my-file-appender” class=”org.apache.log4j.FileAppender”> <param name=”file” value=”some.file” /> <param name=”append” value=”true” /> <param name=”encoding” value=”UTF-8″ /> <layout class=”org.apache.log4j.PatternLayout”> <param name=”ConversionPattern” value=”%d %t %-5p %c – %m%n” /> </layout> </appender> <appender name=”console” …

Quick log4j set up Read More »

Dynamic file name in log4j’s file appender

In your log4j.xml, set the file name as a variable <appender name=”my-file-appender” class=”org.apache.log4j.FileAppender”> <param name=”file” value=”${myFilePath}” /> <!– … –> </appender> Then in your java code, make sure the following is called before the first getLogger() call System.setProperty(“myFilePath”, someFilePath);

Quartz concepts

Basic concepts Job: What to do Trigger: When to do it Scheduler: The director to associate triggers to jobs and to invoke the trigger A job can be associated with several triggers, but a trigger should not be used to trigger more than one job Go into details for some depth JobKey = Job Name …

Quartz concepts Read More »

How to prevent Quartz from re-firing a job while it is still running

Answer: use @DisallowConcurrentExecution Example Without this annotation import java.time.LocalTime; import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class HelloJob implements Job { @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { System.out.println(Thread.currentThread().getName() + “:Job started at ” +; try { Thread.sleep(10 * 1000); } catch (InterruptedException e) { throw new RuntimeException(e); } System.out.println(Thread.currentThread().getName() + …

How to prevent Quartz from re-firing a job while it is still running Read More »