Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A demonstrációs területre kattintás után látható a wiki tartalom:

 

 

 

 

...

Az első 'helloworld' plugin létrehozása

Az Atlassian SDK kényelmes lehetőséget ad arra, hogy létrehozzunk egy Maven alapú Confluence plugin projektet, egyszerűen a megfelelő helyen adjuk ki az atlas-create-confluence-plugin parancsot:

Code Block
languagebash
$ atlas-create-confluence-plugin
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [com.atlassian.maven.plugins:maven-confluence-plugin:4.0:create] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [confluence:create]
[INFO] Google Analytics Tracking is enabled to collect AMPS usage statistics.
[INFO] Although no personal information is sent, you may disable tracking by adding <allowGoogleTracking>false</allowGoogleTracking> to the amps plugin configuration in your pom.xml
[INFO] Sending event to Google Analytics: AMPS:confluence - SDK First Run - 4.0
[INFO] Sending event to Google Analytics: AMPS:confluence - Create Plugin
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.atlassian.maven.archetypes:confluence-plugin-archetype:RELEASE -> https://maven.atlassian.com/public] found in catalog internal
Define value for groupId: : hu.javaforum.confluence             
Define value for artifactId: : helloworld
Define value for version:  1.0-SNAPSHOT: : 
Define value for package:  hu.javaforum.confluence: : 
Confirm properties configuration:
groupId: hu.javaforum.confluence
artifactId: helloworld
version: 1.0-SNAPSHOT
package: hu.javaforum.confluence
 Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: confluence-plugin-archetype:4.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: hu.javaforum.confluence
[INFO] Parameter: packageName, Value: hu.javaforum.confluence
[INFO] Parameter: package, Value: hu.javaforum.confluence
[INFO] Parameter: artifactId, Value: helloworld
[INFO] Parameter: basedir, Value: /home/work/atlassian-workspace
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] OldArchetype created in dir: /home/work/atlassian-workspace/helloworld
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 52 seconds
[INFO] Finished at: Fri Oct 19 20:43:55 CEST 2012
[INFO] Final Memory: 49M/715M
[INFO] ------------------------------------------------------------------------

Kicsit szószátyár egy eszköz, a sok szöveg között középtájt meg kell adnunk négy alapinformációt:

  • groupId – amely a Maven projekt csoportját azonosítja
  • artifactId – amely a Maven projekt termékét azonosítja
  • version – a verzió
  • package – a létrehozott projektben a Java osztályok csomagneve

Az adatok megadása után a projekt legenerálódik, ezt bármilyen Maven projekt szerkezetet támogató IDE képes megnyitni, vagyis az Atlassian nem köti ki, hogy azt az IDE-t használjuk, amit ők is. A projekt alapvetően tartalmaz mindent, amire szükségünk lehet:

  • egy ExampleMacro nevű osztályt, amely a példa makrót tartalmazza
  • ehhez az osztályhoz egy JUnit tesztet
  • egy integrációs tesztet, amelyhez elindít egy beágyazott Confluence példányt és azon végrehajtja a teszteseteket
  • az atlassian-plugin.xml állományt, amely leírja a plugin jellemzőit
  • "végtelen" mennyiségű függőséget, amely a fordításhoz szükséges

Image AddedLefordíthatjuk az IDE felületéről is, de a parancssoros fordítás izgalmasabb... (smile)

Code Block
$ /opt/apache-maven-3.0.4/bin/mvn clean package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ helloworld ---
[INFO] Deleting /home/work/atlassian-workspace/helloworld/target
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:copy-bundled-dependencies (default-copy-bundled-dependencies) @ helloworld ---
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:compress-resources (default-compress-resources) @ helloworld ---
[INFO] nb warnings: 0, nb errors: 0
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:filter-plugin-descriptor (default-filter-plugin-descriptor) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ helloworld ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /home/work/atlassian-workspace/helloworld/target/classes
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:generate-manifest (default-generate-manifest) @ helloworld ---
[INFO] No manifest instructions found, adding only non-OSGi manifest attributes
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:generate-rest-docs (default-generate-rest-docs) @ helloworld ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/work/atlassian-workspace/helloworld/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ helloworld ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /home/work/atlassian-workspace/helloworld/target/test-classes
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:unit-test (default-unit-test) @ helloworld ---
[INFO] Surefire report directory: /home/work/atlassian-workspace/helloworld/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running hu.javaforum.confluence.ExampleMacroTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-confluence-plugin:4.0:validate-manifest (default-validate-manifest) @ helloworld ---
[INFO] Manifest found, validating...
[INFO] Manifest validated
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:jar (default-jar) @ helloworld ---
[INFO] Building jar: /home/work/atlassian-workspace/helloworld/target/helloworld-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:generate-obr-artifact (default-generate-obr-artifact) @ helloworld ---
[INFO] Skipping OBR generation... no OSGi bundle manifest instructions found in pom.xml
[INFO] 
[INFO] --- maven-confluence-plugin:4.0:test-jar (default-test-jar) @ helloworld ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.166s
[INFO] Finished at: Fri Oct 19 21:37:08 CEST 2012
[INFO] Final Memory: 46M/282M
[INFO] ------------------------------------------------------------------------

Ismét egy bőbeszédű Maven kimenetet látunk, amelynek a lényege a középen található tesztek eredményei (egy futott le, hiba nem volt), illetve a vége, ahol láthatjuk, hogy sikeres volt a csomagkészítés. Ha szeretnénk futtatni az integrációs teszteket is, akkor a package parancs helyett használjuk az install parancsot:

Code Block
$ /opt/apache-maven-3.0.4/bin/mvn clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[...]
[INFO] --- maven-confluence-plugin:4.0:unit-test (default-unit-test) @ helloworld ---
[INFO] Surefire report directory: /home/work/atlassian-workspace/helloworld/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running hu.javaforum.confluence.ExampleMacroTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.1 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-confluence-plugin:4.0:validate-manifest (default-validate-manifest) @ helloworld ---
[INFO] Manifest found, validating...
[INFO] Manifest validated
[INFO] 
[...]
[INFO] Failsafe report directory: /home/work/atlassian-workspace/helloworld/target/group-__no_test_group__/tomcat6x/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running it.IntegrationTestMyPlugin
log4j:WARN No appenders could be found for logger (com.atlassian.confluence.plugin.functest.TesterConfiguration).
log4j:WARN Please initialize the log4j system properly.
[INFO] [talledLocalContainer] 2012-10-19 21:48:48,383 INFO [http-1990-1] [admin.actions.plugins.UploadPluginAction] execute User 'admin' uploaded a new plugin: com.atlassian.confluence.plugin.func-test
[INFO] [talledLocalContainer] 2012-10-19 21:48:50,566 INFO [http-1990-4] [confluence.rpc.auth.TokenAuthenticationInvocationHandler] invokeAuthenticatedMethod Executing remote API method [ reindex ] as user [ admin ]
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 14.672 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Failsafe report directory: /home/work/atlassian-workspace/helloworld/target/group-__no_test_group__/tomcat6x/surefire-reports
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] confluence: Shutting down
[INFO] using codehaus cargo v1.2.3
[INFO] [talledLocalContainer] Tomcat 6.x is stopping...
[...]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:49.945s
[INFO] Finished at: Fri Oct 19 21:49:01 CEST 2012
[INFO] Final Memory: 41M/134M
[INFO] ------------------------------------------------------------------------

Az integrációs tesztekhez a fordítás után el fog indulni egy újabb Confluence példány, amelyen lefutnak az integrációs tesztek, így készüljünk fel arra, hogy ebben a pillanatban akár 4GBájt memóriát is elkér magának a fordítási és tesztelési folyamat, illetve az ideje is közelíti a három percet, pedig csak néhány apró teszt futott le.

Mivel általában működés közben szeretnénk látni a modulunkat, ezért azt telepítenünk kell a már elindított fejlesztői Confluence példányba, erre az atlas-install-plugin parancsot tudjuk használni:

Code Block
$ atlas-install-plugin
Executing: /home/work/atlassian-plugin-sdk-4.0/apache-maven/bin/mvn com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:4.0:install 
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld
[INFO]    task-segment: [com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:4.0:install]
[INFO] ------------------------------------------------------------------------
[INFO] [amps-dispatcher:install]
[INFO] [confluence:install {execution: virtual-execution}]
[INFO] [atlassian-pdk:install]
[INFO] Install Plugin: Uploading 'helloworld-1.0-SNAPSHOT.jar' to server via UPM: http://localhost:1990/confluence
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26 seconds
[INFO] Finished at: Fri Oct 19 21:58:23 CEST 2012
[INFO] Final Memory: 77M/611M
[INFO] ------------------------------------------------------------------------

Siker esetén nézzük meg, hogy egy tetszőleges oldalt szerkesztve megjelenik-e a most telepített beépülő modulunk neve:

Image Added

Ha elfogadjuk a felajánlott makrót, akkor – várt paraméterek híján – nem sokat tudunk vele kezdeni, mint megtekintjük előnézetben a hatását:

Image Added

...

Viewtracker