Skip to content

Commit 2ce4c3b

Browse files
authored
[BAEL-9532] Supporting code for jdeb module (#19002)
* [BAEL-6602] Copying text to clipboard in Java * [BAEL-5774] Constructor vs. initialize() in JavaFX * [BAEL-5774] fix: classes and contructor names * [BAEL-5774] Updated class names in accordance to the article * [BAEL-5774] Proper arguments for MetricsCollector and User constructors * [BAEL-5774] userService properly initialized * [BAEL-5774] Moved the snippets to a standalone javafx-2 module * [BAEL-9532] module and supporting code for jdeb
1 parent 2fc9134 commit 2ce4c3b

File tree

7 files changed

+219
-0
lines changed

7 files changed

+219
-0
lines changed

jdeb/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store

jdeb/build.xml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="simple-cal" default="deb" basedir=".">
3+
4+
<property name="app.name" value="simple-cal"/>
5+
<property name="app.version" value="1.0-SNAPSHOT"/>
6+
<property name="build.dir" location="target"/>
7+
<property name="dist.dir" location="${build.dir}/dist"/>
8+
<property name="control.dir" location="src/main/resources/deb/control"/>
9+
10+
<path id="jdeb.classpath">
11+
<fileset dir="lib" includes="jdeb-*.jar"/>
12+
</path>
13+
14+
<taskdef name="deb" classname="org.vafer.jdeb.ant.DebTask" classpathref="jdeb.classpath"/>
15+
16+
<target name="deb" depends="jar">
17+
<echo message="Creating Debian package ${app.name}_${app.version}_all.deb"/>
18+
19+
<deb destFile="${build.dir}/${app.name}_${app.version}_all.deb"
20+
controlDir="${control.dir}"
21+
name="${app.name}"
22+
version="${app.version}"
23+
revision="1"
24+
type="deb">
25+
26+
<data src="${build.dir}/${app.name}.jar"
27+
type="file">
28+
<mapper type="perm"
29+
prefix="/usr/share/${app.name}"/>
30+
</data>
31+
32+
<data src="src/main/resources/${app.name}"
33+
type="file">
34+
<mapper type="perm"
35+
prefix="/usr/bin"
36+
filemode="755"/>
37+
</data>
38+
39+
<data type="template">
40+
<paths>
41+
<path>/var/log/${app.name}</path>
42+
</paths>
43+
</data>
44+
45+
</deb>
46+
</target>
47+
48+
<target name="jar">
49+
<echo message="Creating JAR file (implementation omitted)"/>
50+
<mkdir dir="${build.dir}"/>
51+
<jar destfile="${build.dir}/${app.name}.jar">
52+
</jar>
53+
</target>
54+
55+
<target name="clean">
56+
<delete dir="${build.dir}"/>
57+
</target>
58+
59+
</project>

jdeb/pom.xml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.baeldung</groupId>
8+
<artifactId>parent-modules</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>simple-cal</artifactId>
13+
<packaging>jar</packaging>
14+
<version>1.0-SNAPSHOT</version>
15+
<name>jdeb</name>
16+
17+
<properties>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<jdeb.version>1.14</jdeb.version>
20+
</properties>
21+
22+
<build>
23+
<plugins>
24+
<plugin>
25+
<groupId>org.apache.maven.plugins</groupId>
26+
<artifactId>maven-compiler-plugin</artifactId>
27+
<version>3.14.1</version>
28+
<configuration>
29+
<source>${maven.compiler.source}</source>
30+
<target>${maven.compiler.target}</target>
31+
</configuration>
32+
</plugin>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-jar-plugin</artifactId>
36+
<version>3.4.2</version>
37+
<configuration>
38+
<archive>
39+
<manifest>
40+
<mainClass>com.baeldung.Main</mainClass>
41+
</manifest>
42+
</archive>
43+
</configuration>
44+
</plugin>
45+
<plugin>
46+
<artifactId>jdeb</artifactId>
47+
<groupId>org.vafer</groupId>
48+
<version>${jdeb.version}</version>
49+
<executions>
50+
<execution>
51+
<phase>package</phase>
52+
<goals>
53+
<goal>jdeb</goal>
54+
</goals>
55+
<configuration>
56+
<compression>gzip</compression>
57+
<controlDir>${basedir}/src/main/resources/deb/control</controlDir>
58+
<dataSet>
59+
<data>
60+
<src>${project.build.directory}/${project.build.finalName}.jar</src>
61+
<type>file</type>
62+
<mapper>
63+
<type>perm</type>
64+
<prefix>/opt/${project.artifactId}</prefix>
65+
</mapper>
66+
</data>
67+
<data>
68+
<src>src/main/resources/${project.artifactId}</src>
69+
<type>file</type>
70+
<mapper>
71+
<type>perm</type>
72+
<prefix>/usr/bin</prefix>
73+
<filemode>755</filemode>
74+
</mapper>
75+
</data>
76+
<data>
77+
<type>template</type>
78+
<paths>
79+
<path>/var/log/${project.artifactId}</path>
80+
</paths>
81+
</data>
82+
</dataSet>
83+
</configuration>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung;
2+
3+
import java.time.LocalDate;
4+
import java.time.YearMonth;
5+
6+
public class Main {
7+
public static void main(String[] args) {
8+
LocalDate today = LocalDate.now();
9+
YearMonth ym = YearMonth.from(today);
10+
int days = ym.lengthOfMonth();
11+
int start = ym.atDay(1).getDayOfWeek().getValue();
12+
13+
System.out.println("Mo Tu We Th Fr Sa Su");
14+
for (int i = 1; i < start; i++) System.out.print(" ");
15+
for (int d = 1; d <= days; d++) {
16+
String out = (d == today.getDayOfMonth()) ? + d + "*" : String.format("%2d", d);
17+
System.out.print(out + " ");
18+
if ((d + start - 1) % 7 == 0) System.out.println();
19+
}
20+
}
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Package: simple-cal
2+
Version: 1.0-SNAPSHOT
3+
Section: utils
4+
Priority: optional
5+
Architecture: all
6+
Depends: openjdk-25-jre
7+
Maintainer: Haidar Ali <[email protected]>
8+
Description: A CLI calendar that simply prints the current month.

jdeb/src/main/resources/simple-cal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
java -jar /opt/simple-cal/simple-cal-1.0-SNAPSHOT.jar "$@"

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@
680680
<module>javax-sound</module>
681681
<module>javaxval</module>
682682
<module>javaxval-2</module>
683+
<module>jdeb</module>
683684
<module>jetbrains-annotations</module>
684685
<module>jgit</module>
685686
<module>jmh</module>
@@ -1161,6 +1162,7 @@
11611162
<module>javax-sound</module>
11621163
<module>javaxval</module>
11631164
<module>javaxval-2</module>
1165+
<module>jdeb</module>
11641166
<module>jetbrains-annotations</module>
11651167
<module>jgit</module>
11661168
<module>jmh</module>

0 commit comments

Comments
 (0)