Skip to end of metadata
Go to start of metadata

Az Atlassian Plugin SDK telepítéséhez remek leírást mellékelnek: https://developer.atlassian.com/display/DOCS/Set+up+the+Atlassian+Plugin+SDK+and+Build+a+Project

A telepítés nem igényel túl mély operációs rendszerbeli jártasságot, az Atlassian a főbb Linux terjesztésekhez is karbantart megfelelő repository állományokat, de például az általam használt openSUSE esetén se kell kétségbe esni, egy egyszerű tar.gz állomány letöltése és kicsomagolása után már egy működőképes SDK áll a rendelkezésünkre:

Parancssor
$ wget https://marketplace.atlassian.com/download/plugins/atlassian-plugin-sdk-tgz
--2012-10-16 21:02:17--  https://marketplace.atlassian.com/download/plugins/atlassian-plugin-sdk-tgz
marketplace.atlassian.com (marketplace.atlassian.com) feloldása... 63.246.22.212
Csatlakozás a következőhöz: marketplace.atlassian.com (marketplace.atlassian.com)[63.246.22.212]:443... kapcsolódva.
HTTP kérés elküldve, várakozás válaszra... 302 Found
Hely: https://maven.atlassian.com/content/groups/public/com/atlassian/amps/atlassian-plugin-sdk/4.0/atlassian-plugin-sdk-4.0.tar.gz [következik]
--2012-10-16 21:02:18--  https://maven.atlassian.com/content/groups/public/com/atlassian/amps/atlassian-plugin-sdk/4.0/atlassian-plugin-sdk-4.0.tar.gz
maven.atlassian.com (maven.atlassian.com) feloldása... 67.221.237.4
Csatlakozás a következőhöz: maven.atlassian.com (maven.atlassian.com)[67.221.237.4]:443... kapcsolódva.
HTTP kérés elküldve, várakozás válaszra... 200 OK
Hossz: 23192663 (22M) [application/x-gzip]
Mentés ide: „atlassian-plugin-sdk-tgz"

100%[==================================================================================================================>] 23.192.663  1,67M/s  idő 14s

2012-10-16 21:02:32 (1,62 MB/s) -- „atlassian-plugin-sdk-tgz" mentve [23192663/23192663]
$
$ tar xzvf atlassian-plugin-sdk-tgz
[...]
$ rm atlassian-plugin-sdk-tgz
$ cd atlassian-plugin-sdk-4.0/
$ bin/atlas-version 
ATLAS Version:    4.0
ATLAS Home:       /home/work/atlassian-plugin-sdk-4.0
ATLAS Scripts:    /home/work/atlassian-plugin-sdk-4.0/bin
ATLAS Maven Home: /home/work/atlassian-plugin-sdk-4.0/apache-maven
--------
Executing: /home/work/atlassian-plugin-sdk-4.0/apache-maven/bin/mvn --version 
Apache Maven 2.1.0 (r755702; 2009-03-18 20:10:27+0100)
Java version: 1.6.0_24
Java home: /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre
Default locale: hu_HU, platform encoding: UTF-8
OS name: "linux" version: "3.4.11-2.16-desktop" arch: "amd64" Family: "unix"

Az SDK csomagot ezzel sikeresen telepítettnek mondhatjuk, a kényelem okán még célszerű létrehozni egy ATLAS_HOME környezeti változót, illetve a PATH mögé beszúrni az SDK alatti bin könyvtárat, hogy ne kelljen állandóan hosszú elérési utakat begépelnünk (erre a célra a .profile állomány vége tökéletesen megfelel):

~/.profile
export ATLAS_HOME=/home/work/atlassian-plugin-sdk-4.0/
export PATH=$PATH:$ATLAS_HOME/bin/

Ezek után hozzunk létre egy munka könyvtárat, ahol az SDK által létrehozott projekteket fogjuk tartani:

$ cd /home/work/
$ mkdir atlassian-workspace
$ cd atlassian-workspace
$ pwd
/home/work/atlassian-workspace

Az Atlassian SDK parancsai kivétel nélkül úgy kezdődnek, hogy atlas-, így egy kis parancssor által támogatott parancs-kiegészítés segítségével láthatjuk, hogy miket tudunk elvégezni:

$ atlas-
atlas-clean                            
atlas-create-crowd-plugin              
atlas-create-jira-plugin-module        
atlas-install-plugin                   
atlas-run-standalone
atlas-cli                              
atlas-create-crowd-plugin-module       
atlas-create-plugin                    
atlas-integration-test                 
atlas-unit-test
atlas-clover                           
atlas-create-fecru-plugin              
atlas-create-refapp-plugin             
atlas-mvn                              
atlas-update
atlas-compile                          
atlas-create-fecru-plugin-module       
atlas-create-refapp-plugin-module      
atlas-package                          
atlas-version
atlas-create-bamboo-plugin             
atlas-create-home-zip                  
atlas-create-stash-plugin              
atlas-release                          
atlas-create-bamboo-plugin-module      
atlas-create-jira4-plugin              
atlas-create-stash-plugin-module       
atlas-release-rollback                 
atlas-create-confluence-plugin         
atlas-create-jira5-plugin              
atlas-debug                            
atlas-ruin                             
atlas-create-confluence-plugin-module  
atlas-create-jira-plugin               
atlas-help                             
atlas-run

Indítsunk el egy fejlesztői Confluence példányt:

$ atlas-run-standalone --product confluence
[...]
[INFO] Starting confluence... (see log at /home/work/atlassian-workspace/amps-standalone/target/confluence-4.3.log)
[...]
[INFO] Starting confluence on the tomcat6x container on ports 1990 (http) and 37638 (rmi)
[...]
[INFO] [stalledLocalDeployer] Deploying [/home/work/atlassian-workspace/amps-standalone/target/confluence/confluence.war] to [/home/work/atlassian-workspace/amps-standalone/target/container/tomcat6x/cargo-confluence-home/webapps]...
[INFO] [talledLocalContainer] Tomcat 6.x starting...
[INFO] [talledLocalContainer] Tomcat 6.x started on port [1990]
[INFO] confluence started successfully in 49s at http://linux-s54h.site:1990/confluence
[INFO] Type Ctrl-D to shutdown gracefully
[INFO] Type Ctrl-C to exit

Az Atlassian SDK (és az Atlassian termékek is mind) Maven alapokon működnek, így az első elindítás során le fogja tölteni a fél világot (ezek láthatóak a kihagyott log részleteknél), így mindenki megnyugodhat: az SDK nem 22MBájt, csak a funkcionális része, a tényleges SDK mérete jó párszor száz MBájt lesz az első futás után, az indítás helyén könnyen össze tud gyűlni néhány GBájtnyi adat (az éppen futtatott Atlassian termékek számától és tartalmától függően):

$ du --max-depth=1 -h
1,4G    ./amps-standalone
1,4G    .

A fentebb hivatkozott oldalt megtekintve egy Confluence oldal fogad minket, ahol az admin névvel és admin jelszóval be tudunk lépni:

A belépés után az előadás első felében már megismert Dashboard látható, annyi különbséggel, hogy ez a Confluence példány egy demonstrációs alappal van feltöltve, illetve az alsó sávban jól láthatóan fejlesztési célokat szolgál (és 5 felhasználóra van limitálva):

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:

$ 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

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

$ /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:

$ /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:

$ 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:

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:

      
      
Page viewed times
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels