You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -25,62 +25,80 @@ Ready to get started? By the end of this guide, you'll understand how to make a
25
25
26
26
## Getting started
27
27
28
-
Snaps are defined in a single YAML file placed in the root folder of your project. The following example shows the entire *snapcraft.yaml* file for an existing project, [Freeplane](https://github.com/snapcraft-docs/freeplane). Don't worry, we’ll break this down.
28
+
Snaps are defined in a single YAML file placed either in the root folder of your project or in a directory named `snap`. The following example shows the entire *snapcraft.yaml* file for an existing project, [Cal - The Console Calendar Generator](https://github.com/frossm/cal).
29
29
30
-
Using a few lines of yaml and the snapcraft tool, a Java application, it's dependencies and the correct JRE can be packaged as a snap. We’ll break this down.
30
+
Using a few lines of yaml and the snapcraft tool, a Java application, its dependencies and the correct JRE can be packaged as a snap. Don't worry, we’ll break this down.
31
31
32
-
[details=snapcraft.yaml for Freeplane]
32
+
[details=snapcraft.yaml for Cal]
33
33
34
34
```yaml
35
-
name: freeplane
36
-
title: Freeplane
37
-
version: '1.8.1'
38
-
summary: A free tool to structure and organise your information with mind mapping
35
+
name: fcal
36
+
version: '2.7.1'
37
+
summary: Command line calendar display
39
38
description: |
40
-
Freeplane is a free and open source software application that supports
41
-
thinking, sharing information and getting things done at work, in school
42
-
and at home. The core of the software is tools for mind mapping (also known
43
-
as concept mapping or information mapping) and using mapped information.
44
-
45
-
Occupying the middle ground between an editor and a diagramming tool,
46
-
Freeplane allows the user to add content as quickly and naturally as they
47
-
would in a text editor, yet producing structured content that can be
48
-
manipulated as easily as a diagram.
49
-
50
-
Features include ordering ideas in nodes and freely positionable nodes,
The `snapcraft.yaml` file starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store.
91
109
92
110
```yaml
93
-
name: freeplane
94
-
title: Freeplane
95
-
version: '1.8.1'
96
-
summary: A free tool to structure and organise your information with mind mapping
111
+
name: fcal
112
+
version: '2.7.1'
113
+
summary: Command line calendar display
97
114
description: |
98
-
Freeplane is a free and open source software application that supports
99
-
thinking, sharing information and getting things done at work, in school
100
-
and at home. The core of the software is tools for mind mapping (also known
101
-
as concept mapping or information mapping) and using mapped information.
102
-
103
-
Occupying the middle ground between an editor and a diagramming tool,
104
-
Freeplane allows the user to add content as quickly and naturally as they
105
-
would in a text editor, yet producing structured content that can be
106
-
manipulated as easily as a diagram.
107
-
108
-
Features include ordering ideas in nodes and freely positionable nodes,
search/filtering, different export features, printing, password protection
111
-
of nodes/maps and more.
115
+
fCal is a command line calendar utility. It will display a
116
+
calendar on the command line with any month/year requested. Defaults
117
+
to the current year. fCal can also display local holidays. See help.
112
118
```
113
119
114
120
## Base
115
121
116
122
The base keyword declares which _base snap_ to use with your project. A base snap is a special kind of snap that provides a run-time environment alongside a minimal set of libraries that are common to most applications:
117
123
118
124
```yaml
119
-
base: core18
125
+
base: core22
120
126
```
121
-
As used above, [`core18`](https://snapcraft.io/core18) is the current standard base for snap building and is based on [Ubuntu 18.04 LTS](http://releases.ubuntu.com/18.04/).
127
+
As used above, [`core22`](https://snapcraft.io/core22) is the current standard base for snap building and is based on [Ubuntu 22.04 LTS](https://releases.ubuntu.com/22.04/).
122
128
123
129
See [Base snaps](/t/base-snaps/11198) for more details.
124
130
@@ -132,66 +138,88 @@ confinement: devmode
132
138
133
139
Snaps are containerised to ensure more predictable application behaviour and greater security. Unlike other container systems, the shape of this confinement can be changed through a set of interfaces. These are declarations that tell the system to give permission for a specific task, such as accessing a webcam or binding to a network port.
134
140
135
-
It's best to start a snap with the confinement in warning mode, rather than strictly applied. This is indicated through the `devmode` keyword. When a snap is in devmode, runtime confinement violations will be allowed but reported. These can be reviewed by running `journalctl -xe`.
141
+
It's best to start a snap with the confinement in warning mode, rather than strictly applied. This is indicated through the `devmode` keyword. When a snap is in `devmode`, runtime confinement violations will be allowed but reported. These can be reviewed by running `journalctl -xe`.
136
142
137
-
Because devmode is only intended for development, snaps must be set to strict confinement before they can be published as "stable" in the Snap Store. Once an app is working well in devmode, you can review confinement violations, add appropriate interfaces, and switch to strict confinement.
143
+
Because `devmode` is only intended for development, snaps must be set to `strict` confinement before they can be published as "stable" in the Snap Store. Once an app is working well in `devmode`, you can review confinement violations, add appropriate interfaces, and switch to `strict` confinement.
138
144
139
145
## Apps
140
146
141
-
Apps are the commands and services exposed to end users. If your command name matches the snap `name`, users will be able run the command directly. If the names differ, then apps are prefixed with the snap `name` (`freeplane.command-name`, for example). This is to avoid conflicting with apps defined by other installed snaps.
147
+
Apps are the commands and services exposed to end users. If your command name matches the snap `name`, users will be able to run the command directly. If the names differ, then apps are prefixed with the snap `name` (`fcal.command-name`, for example). This is to avoid conflicting with apps defined by other installed snaps.
142
148
143
149
If you don’t want your command prefixed you can request an alias for it on the [Snapcraft forum](https://forum.snapcraft.io/t/process-for-reviewing-aliases-auto-connections-and-track-requests/455). These are set up automatically when your snap is installed from the Snap Store.
Since Freeplane is a desktop application, we use the [`gnome-3-28` extension](/t/the-gnome-3-28-extension/13485) to configure and setup the desktop integration and permissions for the snap. Although Freeplane is a Java Swing application which doesn't need acces to GTK or GNOME, the GNOME extension is still useful because it sets up many toolkit-independent libraries and functionality such as mouse cursor themes, locales and the XDG runtime environment.
161
-
162
159
## Parts
163
160
164
-
Parts define how to build your app. Parts can be anything: programs, libraries, or other assets needed to create and run your application. In this case we have only one: the Freeplane source. In other cases these can point to local directories, remote git repositories or other revision control systems.
161
+
Parts define how to build your app. Parts can be anything: programs, libraries, or other assets needed to create and run your application. These can point to local directories, remote git repositories or other revision control systems.
162
+
In this case we have the following sources:
163
+
* `cal`: A remote git repository that contains the source code for the `Cal` application.
164
+
* `library`: A remote git repository that contains the source code for dependent libraries.
165
+
* `wrapper`: Path to a local directory that contains a wrapper script to run the application in a bash shell.
166
+
167
+
For details on metadata specific to snapcraft parts, see [Snapcraft parts metadata](/t/snapcraft-parts-metadata/8336).
168
+
169
+
The `maven` plugin can build the application using standard parameters. This plugin requires a `pom.xml` in the root of the source tree. For more details on Maven-specific metadata, see [The Maven plugin](/t/the-maven-plugin/4282).
170
+
171
+
The `dump` plugin dumps the content from a specified source. For more details on metadata specific to the `dump` plugin, see [The Dump plugin](/t/the-dump-plugin/8007).
172
+
165
173
166
-
The gradle plugin can build the application using standard parameters. In this case, however, the default build logic of the gradle plugin is not sufficient. While gradle by default build the `jar` target, Freeplane has a `binZip` target which build a handy zip file. We use `gradle-options` to specify that we want to build the `binZip` target and use an [`override-build` scriptlet to add additional logic](/t/scriptlets/4892#heading--overriding-the-build-step) to the build step to extract the zip in the directory which will later get added to the final snap. See the [parts lifecycle docs](/t/parts-lifecycle/12231#heading--parts-directories) for more information on these directories. Since we use the `unzip` command in the build script, we specify it in `build-packages` so it is installed before the build script runs. Finally, we use the `gradle-output-dir` key to point the snapcraft plugin to the location of the built `jar` files for Freeplane.
After you’ve created the snapcraft.yaml, you can build the snap by simply executing the snapcraft command in the project directory:
222
+
After you’ve reviewed the `snapcraft.yaml`, you can build the snap by simply executing the snapcraft command in the project directory:
195
223
196
224
```bash
197
225
$ snapcraft
@@ -200,19 +228,19 @@ $ snapcraft
200
228
The resulting snap can be installed locally. This requires the `--dangerous` flag because the snap is not signed by the Snap Store. The `--devmode` flag acknowledges that you are installing an unconfined application:
If you’re happy with the result, you can commit the snapcraft.yaml to your GitHub repo and [turn on automatic builds](https://build.snapcraft.io) so any further commits automatically get released to edge, without requiring you to manually build locally.
276
+
If you’re happy with the result, you can commit the snapcraft.yaml to your GitHub repo. You can optionally enable [Build from GitHub](/t/build-from-github/26004) so any further commits automatically get released to edge, without requiring you to manually build locally.
249
277
250
278
Congratulations! You've just built and published your first Java snap. For a more in-depth overview of the snap building process, see [Creating a snap](/t/creating-a-snap/6799).
0 commit comments